Merge pull request #12884 from mrc0mmand/numapolicy-test
test: introduce TEST-36-NUMAPOLICY
This commit is contained in:
@@ -18,8 +18,8 @@ const ExitStatusMapping exit_status_mappings[256] = {
|
||||
* 8…63 │ (Currently unmapped)
|
||||
* 64…78 │ BSD defined exit codes
|
||||
* 79…199 │ (Currently unmapped)
|
||||
* 200…241 │ systemd's private error codes (might be extended to 254 in future development)
|
||||
* 242…254 │ (Currently unmapped, but see above)
|
||||
* 200…242 │ systemd's private error codes (might be extended to 254 in future development)
|
||||
* 243…254 │ (Currently unmapped, but see above)
|
||||
*
|
||||
* 255 │ EXIT_EXCEPTION (We use this to propagate exit-by-signal events. It's frequently used by others apps (like bash)
|
||||
* │ to indicate exit reason that cannot really be expressed in a single exit status value — such as a propagated
|
||||
@@ -99,7 +99,7 @@ const ExitStatusMapping exit_status_mappings[256] = {
|
||||
const char* exit_status_to_string(int code, ExitStatusClass class) {
|
||||
if (code < 0 || (size_t) code >= ELEMENTSOF(exit_status_mappings))
|
||||
return NULL;
|
||||
return FLAGS_SET(exit_status_mappings[code].class, class) ? exit_status_mappings[code].name : NULL;
|
||||
return class & exit_status_mappings[code].class ? exit_status_mappings[code].name : NULL;
|
||||
}
|
||||
|
||||
const char* exit_status_class(int code) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "exit-status.h"
|
||||
#include "string-util.h"
|
||||
#include "tests.h"
|
||||
|
||||
static void test_exit_status_to_string(void) {
|
||||
@@ -31,11 +32,21 @@ static void test_exit_status_from_string(void) {
|
||||
assert_se(exit_status_from_string("FAILURE") == 1);
|
||||
}
|
||||
|
||||
static void test_exit_status_NUMA_POLICY(void) {
|
||||
log_info("/* %s */", __func__);
|
||||
|
||||
assert_se(streq(exit_status_to_string(EXIT_NUMA_POLICY, EXIT_STATUS_FULL), "NUMA_POLICY"));
|
||||
assert_se(streq(exit_status_to_string(EXIT_NUMA_POLICY, EXIT_STATUS_SYSTEMD), "NUMA_POLICY"));
|
||||
assert_se(!exit_status_to_string(EXIT_NUMA_POLICY, EXIT_STATUS_BSD));
|
||||
assert_se(!exit_status_to_string(EXIT_NUMA_POLICY, EXIT_STATUS_LSB));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
test_exit_status_to_string();
|
||||
test_exit_status_from_string();
|
||||
test_exit_status_NUMA_POLICY();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user