aboutsummaryrefslogtreecommitdiffstats
path: root/roms/skiboot/libstb/test
diff options
context:
space:
mode:
Diffstat (limited to 'roms/skiboot/libstb/test')
-rw-r--r--roms/skiboot/libstb/test/Makefile.check42
-rw-r--r--roms/skiboot/libstb/test/run-stb-container.c21
-rw-r--r--roms/skiboot/libstb/test/t.containerbin0 -> 4096 bytes
-rw-r--r--roms/skiboot/libstb/test/t.container.out70
4 files changed, 133 insertions, 0 deletions
diff --git a/roms/skiboot/libstb/test/Makefile.check b/roms/skiboot/libstb/test/Makefile.check
new file mode 100644
index 000000000..6911e0aeb
--- /dev/null
+++ b/roms/skiboot/libstb/test/Makefile.check
@@ -0,0 +1,42 @@
+# -*-Makefile-*-
+LIBSTB_TEST := libstb/test/run-stb-container
+
+HOSTCFLAGS+=-I . -I include
+
+libstb/test/print-stb-container-check: libstb/print-container libstb/test/print-stb-container-q
+
+libstb/test/print-stb-container-q: libstb/print-container
+ $(call Q, TEST , $(VALGRIND) libstb/print-container -I libstb/test/t.container |diff -u libstb/test/t.container.out -, $< t.container)
+
+.PHONY : libstb-check
+libstb-check: $(LIBSTB_TEST:%=%-check) libstb/test/print-stb-container-check
+libstb-check: $(LIBSTB_TEST_NOSTUB:%=%-check)
+
+.PHONY : libstb-coverage
+libstb-coverage: $(LIBSTB_TEST:%=%-gcov-run)
+libstb-coverage: $(LIBSTB_TEST_NOSTUB:%=%-gcov-run)
+
+check: libstb-check
+coverage: libstb-coverage
+
+$(LIBSTB_TEST:%=%-gcov-run) : %-run: %
+ $(call QTEST, TEST-COVERAGE ,$< , $<)
+
+$(LIBSTB_TEST:%=%-check) : %-check: %
+ $(call QTEST, RUN-TEST ,$(VALGRIND) $<, $<)
+
+$(LIBSTB_TEST) : core/test/stubs.o
+
+$(LIBSTB_TEST) : % : %.c
+ $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) -O0 -g -I include -I . -I libfdt -o $@ $< core/test/stubs.o, $<)
+
+$(LIBSTB_TEST:%=%-gcov): %-gcov : %.c %
+ $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) $(HOSTGCOVCFLAGS) -I include -I . -I libfdt -lgcov -o $@ $< core/test/stubs.o, $<)
+
+-include $(wildcard libstb/test/*.d)
+
+clean: libstb-test-clean
+
+libstb-test-clean:
+ $(RM) -f libstb/test/*.[od] $(LIBSTB_TEST) $(LIBSTB_TEST:%=%-gcov)
+ $(RM) -f libstb/test/*.gcda libstb/test/*.gcno
diff --git a/roms/skiboot/libstb/test/run-stb-container.c b/roms/skiboot/libstb/test/run-stb-container.c
new file mode 100644
index 000000000..2f078759a
--- /dev/null
+++ b/roms/skiboot/libstb/test/run-stb-container.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+/* Copyright 2016 IBM Corp. */
+
+#include <config.h>
+
+#include "../container.c"
+
+#include <assert.h>
+
+int main(void)
+{
+ ROM_container_raw *c = malloc(SECURE_BOOT_HEADERS_SIZE);
+ assert(stb_is_container(NULL, 0) == false);
+ assert(stb_is_container(NULL, SECURE_BOOT_HEADERS_SIZE) == false);
+ c->magic_number = cpu_to_be32(ROM_MAGIC_NUMBER + 1);
+ assert(stb_is_container(c, SECURE_BOOT_HEADERS_SIZE) == false);
+ c->magic_number = cpu_to_be32(ROM_MAGIC_NUMBER);
+ assert(stb_is_container(c, SECURE_BOOT_HEADERS_SIZE) == true);
+
+ return 0;
+}
diff --git a/roms/skiboot/libstb/test/t.container b/roms/skiboot/libstb/test/t.container
new file mode 100644
index 000000000..cca142e77
--- /dev/null
+++ b/roms/skiboot/libstb/test/t.container
Binary files differ
diff --git a/roms/skiboot/libstb/test/t.container.out b/roms/skiboot/libstb/test/t.container.out
new file mode 100644
index 000000000..cd113eebb
--- /dev/null
+++ b/roms/skiboot/libstb/test/t.container.out
@@ -0,0 +1,70 @@
+Container:
+magic: 0x17082011
+version: 0x01
+container_size: 0x00000000 (0)
+target_hrmor: 0x00000000
+stack_pointer: 0x00000000
+hw_pkey_a: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+hw_pkey_b: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+hw_pkey_c: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+HW keys hash (calculated):
+ 03bb354bfebb6f7e2bf5bd30e76c1942587d26cf78200d47db84bc002912ed58f62037e6258b484ed37211a0
+ ad006050a027dc16d4c6182487acd34e57dc6c69
+
+Prefix Header:
+ver_alg:
+ version: 0001
+ hash_alg: 01 (SHA512)
+ sig_alg: 01 (SHA512/ECDSA-521)
+code_start_offset: 00000000
+reserved: 00000000
+flags: 00000000
+sw_key_count: 00
+payload_size: 00000000
+payload_hash: 00000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 000000000000000000000000000000000000000000000000
+ecid_count: 00
+
+Prefix Data:
+hw_sig_a: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+hw_sig_b: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+hw_sig_c: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+
+Software Header:
+ver_alg:
+ version: 0000
+ hash_alg: 00 (UNKNOWN)
+ sig_alg: 00 (UNKNOWN)
+code_start_offset: 00000000
+reserved: 00000000
+reserved (ASCII):
+flags: 00000000
+reserved_0: 00
+payload_size: 00000000 (0)
+payload_hash: 00000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 000000000000000000000000000000000000000000000000
+ecid_count: 00
+
+Software Signatures:
+sw_sig_p: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+sw_sig_q: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+sw_sig_r: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+