Changeset View
Changeset View
Standalone View
Standalone View
tests/freebsd_test_suite/macros.h
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
#define ATF_REQUIRE_KERNEL_MODULE(_mod_name) do { \ | #define ATF_REQUIRE_KERNEL_MODULE(_mod_name) do { \ | ||||
if (modfind(_mod_name) == -1) { \ | if (modfind(_mod_name) == -1) { \ | ||||
atf_tc_skip("module %s could not be resolved: %s", \ | atf_tc_skip("module %s could not be resolved: %s", \ | ||||
_mod_name, strerror(errno)); \ | _mod_name, strerror(errno)); \ | ||||
} \ | } \ | ||||
} while(0) | } while(0) | ||||
#define ATF_REQUIRE_OSRELDATE(_version) do { \ | |||||
int _osreldate; \ | |||||
size_t _len; \ | |||||
\ | |||||
_len = sizeof(_osreldate); \ | |||||
if (sysctlbyname("kern.osreldate", &_osreldate, &_len, NULL, \ | |||||
0) == -1) \ | |||||
atf_libc_error(errno, "Failed to read kern.osreldate"); \ | |||||
if (_osreldate < (_version)) \ | |||||
atf_tc_skip("kernel version %d is too old (%d required)", \ | |||||
_osreldate, _version); \ | |||||
} while (0) | |||||
ngie: This seems like a bit of an unnecessary hoop to jump through, especially because it can be… | |||||
jhbAuthorUnsubmitted Not Done Inline ActionsIf you think a compile time test (vs run-time) is fine I'm ok with that. jhb: If you think a compile time test (vs run-time) is fine I'm ok with that. | |||||
#define PLAIN_REQUIRE_FEATURE(_feature_name, _exit_code) do { \ | #define PLAIN_REQUIRE_FEATURE(_feature_name, _exit_code) do { \ | ||||
if (feature_present(_feature_name) == 0) { \ | if (feature_present(_feature_name) == 0) { \ | ||||
printf("kernel feature (%s) not present\n", \ | printf("kernel feature (%s) not present\n", \ | ||||
_feature_name); \ | _feature_name); \ | ||||
_exit(_exit_code); \ | _exit(_exit_code); \ | ||||
} \ | } \ | ||||
} while(0) | } while(0) | ||||
#define PLAIN_REQUIRE_KERNEL_MODULE(_mod_name, _exit_code) do { \ | #define PLAIN_REQUIRE_KERNEL_MODULE(_mod_name, _exit_code) do { \ | ||||
if (modfind(_mod_name) == -1) { \ | if (modfind(_mod_name) == -1) { \ | ||||
printf("module %s could not be resolved: %s\n", \ | printf("module %s could not be resolved: %s\n", \ | ||||
_mod_name, strerror(errno)); \ | _mod_name, strerror(errno)); \ | ||||
_exit(_exit_code); \ | |||||
} \ | |||||
} while(0) | |||||
#define PLAIN_REQUIRE_OSRELDATE(_version, _exit_code) do { \ | |||||
int _osreldate; \ | |||||
size_t _len; \ | |||||
\ | |||||
_len = sizeof(_osreldate); \ | |||||
if (sysctlbyname("kern.osreldate", &_osreldate, &_len, NULL, \ | |||||
0) == -1) { \ | |||||
printf("Failed to read kern.osreldate: %s\n", \ | |||||
strerror(errno)); \ | |||||
_exit(1); \ | |||||
} \ | |||||
if (_osreldate < (_version)) { \ | |||||
printf("kernel version %d is too old (%d required)", \ | |||||
_osreldate, _version); \ | |||||
_exit(_exit_code); \ | _exit(_exit_code); \ | ||||
} \ | } \ | ||||
} while(0) | } while (0) | ||||
#endif | #endif |
This seems like a bit of an unnecessary hoop to jump through, especially because it can be changed by jail(8). What I was proposing was something more along the lines of the following in the test(s):
We could make an official macro for it that doesn't require the kern.osrelease poking though...