mirror of
https://github.com/clearlinux/clr-boot-manager.git
synced 2026-09-06 21:51:43 +00:00
tests: Add complete suite for cbm_files_match
This is just part of improving coverage within clr-boot-manager, and is a critical requirement given that we have changed how we determine that two files differ. With that said, we still do have the test harness that makes heavy use of cbm_files_match, and one can clearly see that by deliberately inverting logic in paths within cbm_files_match, the harness tests then completely fail. Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
This commit is contained in:
@@ -7,6 +7,10 @@ EXTRA_DIST = ${top_srcdir}/README.md \
|
||||
${top_srcdir}/HACKING \
|
||||
${top_srcdir}/findstatic.pl \
|
||||
${top_srcdir}/tests/data/blobfile \
|
||||
${top_srcdir}/tests/data/match \
|
||||
${top_srcdir}/tests/data/match1 \
|
||||
${top_srcdir}/tests/data/nomatch1 \
|
||||
${top_srcdir}/tests/data/nomatch2 \
|
||||
${top_srcdir}/sgcheck.suppressions \
|
||||
${top_srcdir}/data/clr-boot-manager-booted.service \
|
||||
${top_srcdir}/compat/kernel_updater.sh \
|
||||
|
||||
@@ -22,6 +22,40 @@
|
||||
#include "log.h"
|
||||
#include "nica/files.h"
|
||||
|
||||
START_TEST(bootman_match_test)
|
||||
{
|
||||
const char *source_match = TOP_DIR "/tests/data/match";
|
||||
const char *good_match = TOP_DIR "/tests/data/match1";
|
||||
const char *bad_match_data = TOP_DIR "/tests/data/nomatch1";
|
||||
const char *bad_match_len = TOP_DIR "/tests/data/nomatch2";
|
||||
/* In a clean environment, anyway. */
|
||||
const char *non_exist_path = "PATHTHATWONT@EXIST!";
|
||||
|
||||
/* Known good */
|
||||
fail_if(!cbm_files_match(source_match, good_match), "Known matches failed to match");
|
||||
|
||||
/* Known different data */
|
||||
fail_if(cbm_files_match(source_match, bad_match_data),
|
||||
"Shouldn't match files with different data");
|
||||
|
||||
/* Known different data + length */
|
||||
fail_if(cbm_files_match(source_match, bad_match_len),
|
||||
"Shouldn't match files with different length");
|
||||
|
||||
/* Known missing target, with source present */
|
||||
fail_if(cbm_files_match(source_match, non_exist_path),
|
||||
"Shouldn't match with non existent target");
|
||||
|
||||
/* Known missing source with existing target */
|
||||
fail_if(cbm_files_match(non_exist_path, source_match),
|
||||
"Shouldn't match with non existent source");
|
||||
|
||||
/* Known missing both */
|
||||
fail_if(cbm_files_match(non_exist_path, non_exist_path),
|
||||
"Shouldn't match non existent files");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(bootman_uuid_test)
|
||||
{
|
||||
if (geteuid() != 0) {
|
||||
@@ -70,6 +104,7 @@ static Suite *core_suite(void)
|
||||
|
||||
s = suite_create("bootman_files");
|
||||
tc = tcase_create("bootman_files");
|
||||
tcase_add_test(tc, bootman_match_test);
|
||||
tcase_add_test(tc, bootman_uuid_test);
|
||||
tcase_add_test(tc, bootman_mount_test);
|
||||
tcase_add_test(tc, bootman_find_boot);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
This file is for matching.
|
||||
@@ -0,0 +1 @@
|
||||
This file is for matching.
|
||||
@@ -0,0 +1 @@
|
||||
This file is for matching!
|
||||
@@ -0,0 +1 @@
|
||||
This file is for matching. It differs in length
|
||||
Reference in New Issue
Block a user