self.pakfire.execute(["/usr/bin/does-not-exist"])
def test_execute_output(self):
- self.pakfire.execute(["/bin/bash", "--help"])
+ self.pakfire.execute(["/command", "echo", "123"])
# Run a command with a lot of output which exceeds the buffer size
self.pakfire.execute(["/usr/bin/openssl", "rand", "-hex", "65536"])
self.pakfire.execute(["/usr/bin/openssl", "rand", "-base64", "4096"])
# Multiple newlines in one read
- self.pakfire.execute(["/usr/bin/printf", "1\n2\n3\n"])
+ self.pakfire.execute(["/command", "echo", "1\n2\n3"])
def test_execute_logger(self):
def log(priority, message):
#include <stdlib.h>
#include <string.h>
+static int echo(int argc, char* argv[]) {
+ for (int i = 0; i < argc; i++) {
+ printf("%s\n", argv[i]);
+ }
+
+ return 0;
+}
+
static int exit_with_code(int argc, char* argv[]) {
if (argc < 1) {
fprintf(stderr, "exit-with-code requires an argument\n");
int (*callback)(int argc, char* argv[]) = NULL;
const char* command = argv[1];
+ // Echo
+ if (strcmp(command, "echo") == 0)
+ callback = echo;
+
// Exit with code
- if (strcmp(command, "exit-with-code") == 0) {
+ else if (strcmp(command, "exit-with-code") == 0)
callback = exit_with_code;
- }
// Exit if no callback has been set
if (!callback) {