Commit 4598d9ab authored by Mickaël Salaün's avatar Mickaël Salaün

selftests/landlock: Add clang-format exceptions

In preparation to a following commit, add clang-format on and
clang-format off stanzas around constant definitions and the TEST_F_FORK
macro.  This enables to keep aligned values, which is much more readable
than packed definitions.

Add other clang-format exceptions for FIXTURE() and
FIXTURE_VARIANT_ADD() declarations to force space before open brace,
which is reported by checkpatch.pl .

Link: https://lore.kernel.org/r/20220506160513.523257-4-mic@digikod.net
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
parent 06a1c40a
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* this to be possible, we must not call abort() but instead exit smoothly * this to be possible, we must not call abort() but instead exit smoothly
* (hence the step print). * (hence the step print).
*/ */
/* clang-format off */
#define TEST_F_FORK(fixture_name, test_name) \ #define TEST_F_FORK(fixture_name, test_name) \
static void fixture_name##_##test_name##_child( \ static void fixture_name##_##test_name##_child( \
struct __test_metadata *_metadata, \ struct __test_metadata *_metadata, \
...@@ -71,6 +72,7 @@ ...@@ -71,6 +72,7 @@
FIXTURE_DATA(fixture_name) __attribute__((unused)) *self, \ FIXTURE_DATA(fixture_name) __attribute__((unused)) *self, \
const FIXTURE_VARIANT(fixture_name) \ const FIXTURE_VARIANT(fixture_name) \
__attribute__((unused)) *variant) __attribute__((unused)) *variant)
/* clang-format on */
#ifndef landlock_create_ruleset #ifndef landlock_create_ruleset
static inline int landlock_create_ruleset( static inline int landlock_create_ruleset(
......
...@@ -221,8 +221,9 @@ static void remove_layout1(struct __test_metadata *const _metadata) ...@@ -221,8 +221,9 @@ static void remove_layout1(struct __test_metadata *const _metadata)
EXPECT_EQ(0, remove_path(dir_s3d2)); EXPECT_EQ(0, remove_path(dir_s3d2));
} }
FIXTURE(layout1) { /* clang-format off */
}; FIXTURE(layout1) {};
/* clang-format on */
FIXTURE_SETUP(layout1) FIXTURE_SETUP(layout1)
{ {
...@@ -376,6 +377,8 @@ TEST_F_FORK(layout1, inval) ...@@ -376,6 +377,8 @@ TEST_F_FORK(layout1, inval)
ASSERT_EQ(0, close(ruleset_fd)); ASSERT_EQ(0, close(ruleset_fd));
} }
/* clang-format off */
#define ACCESS_FILE ( \ #define ACCESS_FILE ( \
LANDLOCK_ACCESS_FS_EXECUTE | \ LANDLOCK_ACCESS_FS_EXECUTE | \
LANDLOCK_ACCESS_FS_WRITE_FILE | \ LANDLOCK_ACCESS_FS_WRITE_FILE | \
...@@ -396,6 +399,8 @@ TEST_F_FORK(layout1, inval) ...@@ -396,6 +399,8 @@ TEST_F_FORK(layout1, inval)
LANDLOCK_ACCESS_FS_MAKE_BLOCK | \ LANDLOCK_ACCESS_FS_MAKE_BLOCK | \
ACCESS_LAST) ACCESS_LAST)
/* clang-format on */
TEST_F_FORK(layout1, file_access_rights) TEST_F_FORK(layout1, file_access_rights)
{ {
__u64 access; __u64 access;
...@@ -452,6 +457,8 @@ struct rule { ...@@ -452,6 +457,8 @@ struct rule {
__u64 access; __u64 access;
}; };
/* clang-format off */
#define ACCESS_RO ( \ #define ACCESS_RO ( \
LANDLOCK_ACCESS_FS_READ_FILE | \ LANDLOCK_ACCESS_FS_READ_FILE | \
LANDLOCK_ACCESS_FS_READ_DIR) LANDLOCK_ACCESS_FS_READ_DIR)
...@@ -460,6 +467,8 @@ struct rule { ...@@ -460,6 +467,8 @@ struct rule {
ACCESS_RO | \ ACCESS_RO | \
LANDLOCK_ACCESS_FS_WRITE_FILE) LANDLOCK_ACCESS_FS_WRITE_FILE)
/* clang-format on */
static int create_ruleset(struct __test_metadata *const _metadata, static int create_ruleset(struct __test_metadata *const _metadata,
const __u64 handled_access_fs, const struct rule rules[]) const __u64 handled_access_fs, const struct rule rules[])
{ {
...@@ -2070,8 +2079,9 @@ TEST_F_FORK(layout1, proc_pipe) ...@@ -2070,8 +2079,9 @@ TEST_F_FORK(layout1, proc_pipe)
ASSERT_EQ(0, close(pipe_fds[1])); ASSERT_EQ(0, close(pipe_fds[1]));
} }
FIXTURE(layout1_bind) { /* clang-format off */
}; FIXTURE(layout1_bind) {};
/* clang-format on */
FIXTURE_SETUP(layout1_bind) FIXTURE_SETUP(layout1_bind)
{ {
...@@ -2411,8 +2421,9 @@ static const char (*merge_sub_files[])[] = { ...@@ -2411,8 +2421,9 @@ static const char (*merge_sub_files[])[] = {
* └── work * └── work
*/ */
FIXTURE(layout2_overlay) { /* clang-format off */
}; FIXTURE(layout2_overlay) {};
/* clang-format on */
FIXTURE_SETUP(layout2_overlay) FIXTURE_SETUP(layout2_overlay)
{ {
......
...@@ -59,7 +59,9 @@ static int test_ptrace_read(const pid_t pid) ...@@ -59,7 +59,9 @@ static int test_ptrace_read(const pid_t pid)
return 0; return 0;
} }
FIXTURE(hierarchy) { }; /* clang-format off */
FIXTURE(hierarchy) {};
/* clang-format on */
FIXTURE_VARIANT(hierarchy) { FIXTURE_VARIANT(hierarchy) {
const bool domain_both; const bool domain_both;
...@@ -83,7 +85,9 @@ FIXTURE_VARIANT(hierarchy) { ...@@ -83,7 +85,9 @@ FIXTURE_VARIANT(hierarchy) {
* \ P2 -> P1 : allow * \ P2 -> P1 : allow
* 'P2 * 'P2
*/ */
/* clang-format off */
FIXTURE_VARIANT_ADD(hierarchy, allow_without_domain) { FIXTURE_VARIANT_ADD(hierarchy, allow_without_domain) {
/* clang-format on */
.domain_both = false, .domain_both = false,
.domain_parent = false, .domain_parent = false,
.domain_child = false, .domain_child = false,
...@@ -98,7 +102,9 @@ FIXTURE_VARIANT_ADD(hierarchy, allow_without_domain) { ...@@ -98,7 +102,9 @@ FIXTURE_VARIANT_ADD(hierarchy, allow_without_domain) {
* | P2 | * | P2 |
* '------' * '------'
*/ */
/* clang-format off */
FIXTURE_VARIANT_ADD(hierarchy, allow_with_one_domain) { FIXTURE_VARIANT_ADD(hierarchy, allow_with_one_domain) {
/* clang-format on */
.domain_both = false, .domain_both = false,
.domain_parent = false, .domain_parent = false,
.domain_child = true, .domain_child = true,
...@@ -112,7 +118,9 @@ FIXTURE_VARIANT_ADD(hierarchy, allow_with_one_domain) { ...@@ -112,7 +118,9 @@ FIXTURE_VARIANT_ADD(hierarchy, allow_with_one_domain) {
* ' * '
* P2 * P2
*/ */
/* clang-format off */
FIXTURE_VARIANT_ADD(hierarchy, deny_with_parent_domain) { FIXTURE_VARIANT_ADD(hierarchy, deny_with_parent_domain) {
/* clang-format on */
.domain_both = false, .domain_both = false,
.domain_parent = true, .domain_parent = true,
.domain_child = false, .domain_child = false,
...@@ -127,7 +135,9 @@ FIXTURE_VARIANT_ADD(hierarchy, deny_with_parent_domain) { ...@@ -127,7 +135,9 @@ FIXTURE_VARIANT_ADD(hierarchy, deny_with_parent_domain) {
* | P2 | * | P2 |
* '------' * '------'
*/ */
/* clang-format off */
FIXTURE_VARIANT_ADD(hierarchy, deny_with_sibling_domain) { FIXTURE_VARIANT_ADD(hierarchy, deny_with_sibling_domain) {
/* clang-format on */
.domain_both = false, .domain_both = false,
.domain_parent = true, .domain_parent = true,
.domain_child = true, .domain_child = true,
...@@ -142,7 +152,9 @@ FIXTURE_VARIANT_ADD(hierarchy, deny_with_sibling_domain) { ...@@ -142,7 +152,9 @@ FIXTURE_VARIANT_ADD(hierarchy, deny_with_sibling_domain) {
* | P2 | * | P2 |
* '-------------' * '-------------'
*/ */
/* clang-format off */
FIXTURE_VARIANT_ADD(hierarchy, allow_sibling_domain) { FIXTURE_VARIANT_ADD(hierarchy, allow_sibling_domain) {
/* clang-format on */
.domain_both = true, .domain_both = true,
.domain_parent = false, .domain_parent = false,
.domain_child = false, .domain_child = false,
...@@ -158,7 +170,9 @@ FIXTURE_VARIANT_ADD(hierarchy, allow_sibling_domain) { ...@@ -158,7 +170,9 @@ FIXTURE_VARIANT_ADD(hierarchy, allow_sibling_domain) {
* | '------' | * | '------' |
* '-----------------' * '-----------------'
*/ */
/* clang-format off */
FIXTURE_VARIANT_ADD(hierarchy, allow_with_nested_domain) { FIXTURE_VARIANT_ADD(hierarchy, allow_with_nested_domain) {
/* clang-format on */
.domain_both = true, .domain_both = true,
.domain_parent = false, .domain_parent = false,
.domain_child = true, .domain_child = true,
...@@ -174,7 +188,9 @@ FIXTURE_VARIANT_ADD(hierarchy, allow_with_nested_domain) { ...@@ -174,7 +188,9 @@ FIXTURE_VARIANT_ADD(hierarchy, allow_with_nested_domain) {
* | P2 | * | P2 |
* '-----------------' * '-----------------'
*/ */
/* clang-format off */
FIXTURE_VARIANT_ADD(hierarchy, deny_with_nested_and_parent_domain) { FIXTURE_VARIANT_ADD(hierarchy, deny_with_nested_and_parent_domain) {
/* clang-format on */
.domain_both = true, .domain_both = true,
.domain_parent = true, .domain_parent = true,
.domain_child = false, .domain_child = false,
...@@ -192,7 +208,9 @@ FIXTURE_VARIANT_ADD(hierarchy, deny_with_nested_and_parent_domain) { ...@@ -192,7 +208,9 @@ FIXTURE_VARIANT_ADD(hierarchy, deny_with_nested_and_parent_domain) {
* | '------' | * | '------' |
* '-----------------' * '-----------------'
*/ */
/* clang-format off */
FIXTURE_VARIANT_ADD(hierarchy, deny_with_forked_domain) { FIXTURE_VARIANT_ADD(hierarchy, deny_with_forked_domain) {
/* clang-format on */
.domain_both = true, .domain_both = true,
.domain_parent = true, .domain_parent = true,
.domain_child = true, .domain_child = true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment