libredirect: add test for 'bind'
This commit is contained in:
@@ -124,7 +124,7 @@ else
|
||||
installCheckPhase = ''
|
||||
(
|
||||
source "$hook/nix-support/setup-hook"
|
||||
NIX_REDIRECTS="/foo/bar/test=${coreutils}/bin/true:/bar/baz=$(mktemp -d)" ./test
|
||||
NIX_REDIRECTS="/foo/bar/test=${coreutils}/bin/true:/bar/baz=$(mktemp -d):/run/sock=$PWD/test.sock" ./test
|
||||
)
|
||||
'';
|
||||
|
||||
|
||||
@@ -8,16 +8,32 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#define TESTDIR "/bar/baz"
|
||||
#define TESTPATH "/foo/bar/test"
|
||||
#define TESTSOCK "/run/sock"
|
||||
#define SUBTEST "./test sub"
|
||||
|
||||
extern char **environ;
|
||||
|
||||
void test_bind(void) {
|
||||
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
assert(fd != -1);
|
||||
struct sockaddr_un addr = {
|
||||
.sun_family = AF_UNIX,
|
||||
.sun_path = TESTSOCK,
|
||||
};
|
||||
unlink(TESTSOCK);
|
||||
int ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
|
||||
assert(ret == 0);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void test_spawn(void) {
|
||||
pid_t pid;
|
||||
int ret;
|
||||
@@ -160,6 +176,7 @@ int main(int argc, char *argv[])
|
||||
assert(mktemp(buf) == buf);
|
||||
assert_mktemp_path(TESTDIR "/temp", "", buf);
|
||||
|
||||
test_bind();
|
||||
test_spawn();
|
||||
test_system();
|
||||
test_stat_with_null_path();
|
||||
|
||||
Reference in New Issue
Block a user