self.assertTrue(code == 123)
def test_environ(self):
- r = self.pakfire.execute(["/bin/sh", "-c", "echo ${VAR1}"],
+ r = self.pakfire.execute(["/command", "echo-environ", "VAR1"],
environ={"VAR1" : "VAL1"})
self.assertIsNone(r)
return 0;
}
+static int echo_environ(int argc, char* argv[]) {
+ for (int i = 0; i < argc; i++) {
+ const char* value = secure_getenv(argv[i]);
+ if (!value) {
+ fprintf(stderr, "Variable %s is not set\n", argv[i]);
+ return 1;
+ }
+
+ printf("%s\n", value);
+ }
+
+ return 0;
+}
+
static int exit_with_code(int argc, char* argv[]) {
if (argc < 1) {
fprintf(stderr, "exit-with-code requires an argument\n");
if (strcmp(command, "echo") == 0)
callback = echo;
+ // Echo Environment
+ else if (strcmp(command, "echo-environ") == 0)
+ callback = echo_environ;
+
// Exit with code
else if (strcmp(command, "exit-with-code") == 0)
callback = exit_with_code;