From: Michael Tremer Date: Wed, 3 Aug 2022 15:59:54 +0000 (+0000) Subject: tests: command: Rename pid to print-pid X-Git-Tag: 0.9.28~594 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c4ef634f00e32efa37271f3a5c90478d699ee24;p=pakfire.git tests: command: Rename pid to print-pid Signed-off-by: Michael Tremer --- diff --git a/tests/python/execute.py b/tests/python/execute.py index 29b373802..987036916 100755 --- a/tests/python/execute.py +++ b/tests/python/execute.py @@ -104,7 +104,7 @@ class Test(unittest.TestCase): # The PID must be 1 self.assertEqual(message, "1") - self.pakfire.execute(["/command", "pid"], logging_callback=checkpid) + self.pakfire.execute(["/command", "print-pid"], logging_callback=checkpid) def test_nice(self): self.pakfire.execute(["/command", "print-nice"], nice=5) diff --git a/tests/stub/command.c b/tests/stub/command.c index 53b0714b9..c37f73495 100644 --- a/tests/stub/command.c +++ b/tests/stub/command.c @@ -155,22 +155,22 @@ static int lines(int argc, char* argv[]) { return 0; } -static int pid(int argc, char* argv[]) { - pid_t pid = getpid(); - if (!pid) - return 1; +static int print_nice(int argc, char* argv[]) { + int nice = getpriority(PRIO_PROCESS, 0); - // Print the PID - printf("%d\n", pid); + // Print the nice level + printf("%d\n", nice); return 0; } -static int print_nice(int argc, char* argv[]) { - int nice = getpriority(PRIO_PROCESS, 0); +static int print_pid(int argc, char* argv[]) { + pid_t pid = getpid(); + if (!pid) + return 1; - // Print the nice level - printf("%d\n", nice); + // Print the PID + printf("%d\n", pid); return 0; } @@ -208,14 +208,14 @@ int main(int argc, char* argv[]) { else if (strcmp(command, "lines") == 0) callback = lines; - // Print PID - else if (strcmp(command, "pid") == 0) - callback = pid; - // Print nice level else if (strcmp(command, "print-nice") == 0) callback = print_nice; + // Print PID + else if (strcmp(command, "print-pid") == 0) + callback = print_pid; + // Exit if no callback has been set if (!callback) { fprintf(stderr, "Unknown command: %s\n", command);