mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-10 05:46:48 +00:00
Add a regression test
This commit is contained in:
parent
8600278a5f
commit
f8429b2735
42
test/apps/clone3/clone_files.c
Normal file
42
test/apps/clone3/clone_files.c
Normal file
@ -0,0 +1,42 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "../network/test.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static char child_stack[4096];
|
||||
#define CHILD_STACK_TOP \
|
||||
(child_stack + sizeof(child_stack) / sizeof(child_stack[0]))
|
||||
|
||||
static int fd1, fd2;
|
||||
|
||||
static int child_close(void *arg)
|
||||
{
|
||||
CHECK(close(fd2));
|
||||
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
FN_TEST(clone_files_and_close)
|
||||
{
|
||||
pid_t pid;
|
||||
int status;
|
||||
|
||||
fd1 = TEST_SUCC(open("/dev/null", O_RDONLY));
|
||||
fd2 = TEST_SUCC(open("/dev/null", O_RDONLY));
|
||||
|
||||
pid = TEST_SUCC(clone(&child_close, CHILD_STACK_TOP,
|
||||
CLONE_FILES | SIGCHLD, NULL, NULL, NULL, NULL));
|
||||
|
||||
TEST_RES(wait(&status),
|
||||
_ret == pid && WIFEXITED(status) && WEXITSTATUS(status) == 0);
|
||||
|
||||
TEST_SUCC(close(fd1));
|
||||
TEST_ERRNO(close(fd2), EBADF);
|
||||
}
|
||||
END_TEST()
|
@ -11,6 +11,7 @@ echo "Start process test......"
|
||||
# These test programs are sorted by name.
|
||||
tests="
|
||||
clone3/clone_exit_signal
|
||||
clone3/clone_files
|
||||
clone3/clone_no_exit_signal
|
||||
clone3/clone_process
|
||||
cpu_affinity/cpu_affinity
|
||||
|
Loading…
x
Reference in New Issue
Block a user