Merge pull request #16955 from keszybz/test-execute-cleanup
One patch for test-execute and assorted cleanups
This commit is contained in:
+23
-2
@@ -543,7 +543,29 @@ static void test_exec_supplementarygroups(Manager *m) {
|
||||
test(__func__, m, "exec-supplementarygroups-multiple-groups-withuid.service", 0, CLD_EXITED);
|
||||
}
|
||||
|
||||
static char* private_directory_bad(Manager *m) {
|
||||
/* This mirrors setup_exec_directory(). */
|
||||
|
||||
for (ExecDirectoryType dt = 0; dt < _EXEC_DIRECTORY_TYPE_MAX; dt++) {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
struct stat st;
|
||||
|
||||
assert_se(p = path_join(m->prefix[dt], "private"));
|
||||
|
||||
if (stat(p, &st) >= 0 &&
|
||||
(st.st_mode & (S_IRWXG|S_IRWXO)))
|
||||
return TAKE_PTR(p);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void test_exec_dynamicuser(Manager *m) {
|
||||
_cleanup_free_ char *bad = private_directory_bad(m);
|
||||
if (bad) {
|
||||
log_warning("%s: %s has bad permissions, skipping test.", __func__, bad);
|
||||
return;
|
||||
}
|
||||
|
||||
test(__func__, m, "exec-dynamicuser-fixeduser.service", can_unshare ? 0 : EXIT_NAMESPACE, CLD_EXITED);
|
||||
if (check_user_has_group_with_same_name("adm"))
|
||||
@@ -782,7 +804,6 @@ typedef struct test_entry {
|
||||
#define entry(x) {x, #x}
|
||||
|
||||
static int run_tests(UnitFileScope scope, const test_entry tests[], char **patterns) {
|
||||
const test_entry *test = NULL;
|
||||
_cleanup_(manager_freep) Manager *m = NULL;
|
||||
int r;
|
||||
|
||||
@@ -795,7 +816,7 @@ static int run_tests(UnitFileScope scope, const test_entry tests[], char **patte
|
||||
assert_se(r >= 0);
|
||||
assert_se(manager_startup(m, NULL, NULL) >= 0);
|
||||
|
||||
for (test = tests; test && test->f; test++)
|
||||
for (const test_entry *test = tests; test->f; test++)
|
||||
if (strv_fnmatch_or_empty(patterns, test->name, FNM_NOESCAPE))
|
||||
test->f(m);
|
||||
else
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
DISABLE_WARNING_TYPE_LIMITS;
|
||||
|
||||
#define info_no_sign(t) \
|
||||
printf("%s → %zu bits, %zu byte alignment\n", STRINGIFY(t), \
|
||||
sizeof(t)*CHAR_BIT, \
|
||||
__alignof__(t))
|
||||
|
||||
#define info(t) \
|
||||
printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t), \
|
||||
sizeof(t)*CHAR_BIT, \
|
||||
@@ -37,6 +42,12 @@ enum BigEnum2 {
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
int (*function_pointer)(void);
|
||||
|
||||
info_no_sign(function_pointer);
|
||||
info_no_sign(void*);
|
||||
info(char*);
|
||||
|
||||
info(char);
|
||||
info(signed char);
|
||||
info(unsigned char);
|
||||
|
||||
Reference in New Issue
Block a user