Skip to content

Commit

Permalink
Merge pull request #2999 from cgwalters/add-oscore-units
Browse files Browse the repository at this point in the history
tests: Add otcore unit tests
  • Loading branch information
jmarrero authored Aug 23, 2023
2 parents aa8ad20 + e3f0c4d commit 37f247d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile-tests.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
41 changes: 41 additions & 0 deletions tests/test-otcore.c
Original file line number Diff line number Diff line change
@@ -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 ();
}

0 comments on commit 37f247d

Please sign in to comment.