aboutsummaryrefslogtreecommitdiff
path: root/tests/gensquashfs/filemap_xattr.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-01-31 11:30:46 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-01-31 18:04:25 +0100
commit72c8155d9fc0eaeac72c053f46ebb7b231d4596a (patch)
tree5758865289c52fa93f56e3fe743bb40c283c5233 /tests/gensquashfs/filemap_xattr.c
parentcdccc69c62579b0c13b35fad0728079652b8f3c9 (diff)
Reintegrate test code with library code
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/gensquashfs/filemap_xattr.c')
-rw-r--r--tests/gensquashfs/filemap_xattr.c98
1 files changed, 0 insertions, 98 deletions
diff --git a/tests/gensquashfs/filemap_xattr.c b/tests/gensquashfs/filemap_xattr.c
deleted file mode 100644
index d258d89..0000000
--- a/tests/gensquashfs/filemap_xattr.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * filemap_xattr.c
- *
- * Copyright (C) 2022 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include "util/test.h"
-#include "mkfs.h"
-
-static const char *dev_selinux = "system_u:object_r:device_t:s0";
-static const char *zero_selinux = "system_u:object_r:zero_device_t:s0";
-static const char *rfkill_selinux = "system_u:object_r:wireless_device_t:s0";
-
-static const sqfs_u8 rfkill_acl[] = {
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x06, 0x00,
- 0xe8, 0x03, 0x00, 0x00, 0x04, 0x00, 0x06, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0x10, 0x00, 0x06, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0x20, 0x00, 0x04, 0x00,
- 0xff, 0xff, 0xff, 0xff
-};
-
-int main(int argc, char **argv)
-{
- struct XattrMapPattern *pat;
- struct XattrMapEntry *ent;
- struct XattrMap *map;
- int ret;
- (void)argc; (void)argv;
-
- map = xattr_open_map_file(TEST_PATH);
- TEST_NOT_NULL(map);
-
- /* the third pattern */
- pat = map->patterns;
- TEST_NOT_NULL(pat);
- TEST_STR_EQUAL(pat->path, "dev/rfkill");
-
- ent = pat->entries;
- TEST_NOT_NULL(ent);
- TEST_STR_EQUAL(ent->key, "system.posix_acl_access");
-
- TEST_EQUAL_UI(ent->value_len, sizeof(rfkill_acl));
- ret = memcmp(ent->value, rfkill_acl, ent->value_len);
- TEST_EQUAL_I(ret, 0);
-
- ent = ent->next;
- TEST_NOT_NULL(ent);
- TEST_STR_EQUAL(ent->key, "security.selinux");
-
- TEST_EQUAL_UI(ent->value_len, strlen(rfkill_selinux));
- ret = memcmp(ent->value, rfkill_selinux, ent->value_len);
- TEST_EQUAL_I(ret, 0);
-
- ent = ent->next;
- TEST_NULL(ent);
-
- /* the second pattern */
- pat = pat->next;
- TEST_NOT_NULL(pat);
- TEST_STR_EQUAL(pat->path, "dev/zero");
-
- ent = pat->entries;
- TEST_NOT_NULL(ent);
- TEST_STR_EQUAL(ent->key, "security.selinux");
-
- TEST_EQUAL_UI(ent->value_len, strlen(zero_selinux));
- ret = memcmp(ent->value, zero_selinux, ent->value_len);
- TEST_EQUAL_I(ret, 0);
-
- ent = ent->next;
- TEST_NULL(ent);
-
- /* the first pattern */
- pat = pat->next;
- TEST_NOT_NULL(pat);
- TEST_STR_EQUAL(pat->path, "dev");
-
- ent = pat->entries;
- TEST_NOT_NULL(ent);
- TEST_STR_EQUAL(ent->key, "security.selinux");
-
- TEST_EQUAL_UI(ent->value_len, strlen(dev_selinux));
- ret = memcmp(ent->value, dev_selinux, ent->value_len);
- TEST_EQUAL_I(ret, 0);
-
- ent = ent->next;
- TEST_NULL(ent);
-
- /* no more patterns */
- pat = pat->next;
- TEST_NULL(pat);
-
- xattr_close_map_file(map);
- return EXIT_SUCCESS;
-}