tests: Add otcore unit tests

This just stubs out the basic infrastructure, to be expanded upon.
This commit is contained in:
Colin Walters 2023-08-22 13:04:12 -04:00
parent 16b97d8a40
commit e3f0c4d49c
2 changed files with 45 additions and 1 deletions

View File

@ -262,7 +262,7 @@ else
EXTRA_DIST += $(js_installed_tests)
endif
_installed_or_uninstalled_test_programs = tests/test-varint tests/test-ot-unix-utils tests/test-bsdiff tests/test-mutable-tree \
_installed_or_uninstalled_test_programs = tests/test-varint tests/test-ot-unix-utils tests/test-bsdiff tests/test-otcore tests/test-mutable-tree \
tests/test-keyfile-utils tests/test-ot-opt-utils tests/test-ot-tool-util \
tests/test-checksum tests/test-lzma tests/test-rollsum \
tests/test-basic-c tests/test-sysroot-c tests/test-pull-c tests/test-repo tests/test-include-ostree-h tests/test-kargs \
@ -365,6 +365,9 @@ tests_test_varint_LDADD = $(TESTS_LDADD)
tests_test_bsdiff_CFLAGS = $(TESTS_CFLAGS)
tests_test_bsdiff_LDADD = libbsdiff.la $(TESTS_LDADD)
tests_test_otcore_CFLAGS = $(AM_CFLAGS) $(OT_INTERNAL_GIO_UNIX_CFLAGS) -I$(srcdir)/src/libotutil -I$(srcdir)/src/libotcore -I$(srcdir)/libglnx
tests_test_otcore_LDADD = $(OT_INTERNAL_GIO_UNIX_LIBS) libotcore.la libglnx.la
tests_test_checksum_SOURCES = \
src/libostree/ostree-core.c \
src/libostree/ostree-varint.c \

41
tests/test-otcore.c Normal file
View File

@ -0,0 +1,41 @@
/*
* SPDX-License-Identifier: LGPL-2.0+
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "otcore.h"
static void
test_ed25519 (void)
{
g_autoptr (GBytes) empty = g_bytes_new_static ("", 0);
bool valid = false;
g_autoptr (GError) error = NULL;
if (otcore_validate_ed25519_signature (empty, empty, empty, &valid, &error))
g_assert_not_reached ();
g_assert (error != NULL);
g_clear_error (&error);
}
int
main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
otcore_ed25519_init ();
g_test_add_func ("/ed25519", test_ed25519);
return g_test_run ();
}