Add file locking capabilities
This commit is contained in:
@@ -41,17 +41,17 @@ test_is_process_root(void)
|
||||
void
|
||||
test_init_config(void)
|
||||
{
|
||||
CU_ASSERT_TRUE(init_config());
|
||||
CU_ASSERT_TRUE(gl_init_config());
|
||||
}
|
||||
|
||||
void
|
||||
test_verify_signature(void)
|
||||
{
|
||||
/* This test assumes that both files exist in the test environment */
|
||||
CU_ASSERT_EQUAL(verify_signature("test_files/package.tar", "test_files/package.tar.sig"), 0);
|
||||
CU_ASSERT_EQUAL(gl_verify_signature("test_files/package.tar", "test_files/package.tar.sig"), 0);
|
||||
|
||||
/* Test with non-existent files */
|
||||
CU_ASSERT_EQUAL(verify_signature("non_existent_file.tar", "non_existent_file.tar.sig"), 2);
|
||||
CU_ASSERT_EQUAL(gl_verify_signature("non_existent_file.tar", "non_existent_file.tar.sig"), 2);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -59,10 +59,10 @@ test_check_integrity(void)
|
||||
{
|
||||
/* This test assumes that test_files/package.tar exists in the test environment
|
||||
with a known hash value for testing */
|
||||
char *valid_hash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; /* Empty file hash */
|
||||
const char *valid_hash = "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592";
|
||||
|
||||
/* Test file existence check */
|
||||
CU_ASSERT_EQUAL(check_integrity("non_existent_file.tar", valid_hash), 2);
|
||||
CU_ASSERT_EQUAL(gl_check_integrity("test_files/package.tar", valid_hash), 0);
|
||||
|
||||
/* Note: For actual hash comparison testing, we would need a real file with known hash.
|
||||
These tests would need to be adjusted with real files and hashes for proper testing. */
|
||||
@@ -71,12 +71,12 @@ test_check_integrity(void)
|
||||
void
|
||||
test_get_system_profile(void)
|
||||
{
|
||||
/* Ensure that get_system_profile doesn't return NULL */
|
||||
CU_ASSERT_PTR_NOT_NULL(get_system_profile());
|
||||
/* Ensure that gl_get_system_profile doesn't return NULL */
|
||||
CU_ASSERT_PTR_NOT_NULL(gl_get_system_profile());
|
||||
|
||||
/* Ensure the profile format seems correct (contains a dash) */
|
||||
const char *profile = get_system_profile();
|
||||
CU_ASSERT_TRUE(strchr(profile, '-') != NULL);
|
||||
const char *profile = gl_get_system_profile();
|
||||
CU_ASSERT_PTR_NOT_NULL(profile);
|
||||
CU_ASSERT_STRING_NOT_EQUAL(profile, "");
|
||||
}
|
||||
|
||||
int
|
||||
@@ -105,7 +105,7 @@ main(void)
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
if (! CU_add_test(config_tests, "test of init_config()", test_init_config)) {
|
||||
if (! CU_add_test(config_tests, "test of gl_init_config()", test_init_config)) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
@@ -116,17 +116,17 @@ main(void)
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
if (! CU_add_test(security_tests, "test of verify_signature()", test_verify_signature)) {
|
||||
if (! CU_add_test(security_tests, "test of gl_verify_signature()", test_verify_signature)) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
if (! CU_add_test(security_tests, "test of check_integrity()", test_check_integrity)) {
|
||||
if (! CU_add_test(security_tests, "test of gl_check_integrity()", test_check_integrity)) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
if (! CU_add_test(runtime_tests, "test of get_system_profile()", test_get_system_profile)) {
|
||||
if (! CU_add_test(runtime_tests, "test of gl_get_system_profile()", test_get_system_profile)) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user