Add tests for --inherit-argv0
and --chdir DIR
This commit is contained in:
parent
64da82731d
commit
d8375fbccb
3 changed files with 29 additions and 4 deletions
14
pkgs/test/make-binary-wrapper/chdir.c
Normal file
14
pkgs/test/make-binary-wrapper/chdir.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
// makeCWrapper /path/to/executable \
|
||||
--chdir /usr/local/bin
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
assert_success(chdir("/usr/local/bin"));
|
||||
argv[0] = "/path/to/executable";
|
||||
return execv("/path/to/executable", argv);
|
||||
}
|
|
@ -22,14 +22,16 @@ let
|
|||
};
|
||||
};
|
||||
tests = {
|
||||
add-flags = makeGoldenTest { name = "add-flags"; filename = ./add-flags.c; };
|
||||
argv0 = makeGoldenTest { name = "argv0"; filename = ./argv0.c; };
|
||||
basic = makeGoldenTest { name = "basic"; filename = ./basic.c; };
|
||||
combination = makeGoldenTest { name = "combination"; filename = ./combination.c; };
|
||||
argv0 = makeGoldenTest { name = "argv0"; filename = ./argv0.c; };
|
||||
inherit_argv0 = makeGoldenTest { name = "inherit-argv0"; filename = ./inherit-argv0.c; };
|
||||
env = makeGoldenTest { name = "env"; filename = ./env.c; };
|
||||
invalid_env = makeGoldenTest { name = "invalid-env"; filename = ./invalid-env.c; };
|
||||
prefix = makeGoldenTest { name = "prefix"; filename = ./prefix.c; };
|
||||
suffix = makeGoldenTest { name = "suffix"; filename = ./suffix.c; };
|
||||
invalid-env = makeGoldenTest { name = "invalid-env"; filename = ./invalid-env.c; };
|
||||
add_flags = makeGoldenTest { name = "add-flags"; filename = ./add-flags.c; };
|
||||
chdir = makeGoldenTest { name = "chdir"; filename = ./chdir.c; };
|
||||
combination = makeGoldenTest { name = "combination"; filename = ./combination.c; };
|
||||
};
|
||||
in runCommand "make-binary-wrapper-test" {
|
||||
passthru = tests;
|
||||
|
|
9
pkgs/test/make-binary-wrapper/inherit-argv0.c
Normal file
9
pkgs/test/make-binary-wrapper/inherit-argv0.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
// makeCWrapper /path/to/executable \
|
||||
--inherit-argv0
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return execv("/path/to/executable", argv);
|
||||
}
|
Loading…
Reference in a new issue