[flang] Fix length handling in character kind implicit conversion (#74586)
[llvm-project.git] / libc / test / integration / src / unistd / execve_test.cpp
blobfb1a83da6385667b83baf927903a079844b949f8
1 //===-- Unittests for execve ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/sys/wait/waitpid.h"
10 #include "src/unistd/execve.h"
11 #include "src/unistd/fork.h"
13 #include "test/IntegrationTest/test.h"
15 #include <signal.h>
16 #include <sys/wait.h>
18 void fork_and_execv_normal_exit(char **envp) {
19 pid_t pid = LIBC_NAMESPACE::fork();
20 if (pid == 0) {
21 const char *path = "libc_execv_test_normal_exit";
22 char *const argv[] = {
23 const_cast<char *>("execv_test_normal_exit"),
24 nullptr,
26 LIBC_NAMESPACE::execve(path, argv, envp);
28 ASSERT_TRUE(pid > 0);
29 int status;
30 pid_t cpid = LIBC_NAMESPACE::waitpid(pid, &status, 0);
31 ASSERT_TRUE(cpid > 0);
32 ASSERT_EQ(cpid, pid);
33 ASSERT_TRUE(WIFEXITED(status));
36 void fork_and_execv_signal_exit(char **envp) {
37 pid_t pid = LIBC_NAMESPACE::fork();
38 if (pid == 0) {
39 const char *path = "libc_execv_test_signal_exit";
40 char *const argv[] = {
41 const_cast<char *>("execv_test_normal_exit"),
42 nullptr,
44 LIBC_NAMESPACE::execve(path, argv, envp);
46 ASSERT_TRUE(pid > 0);
47 int status;
48 pid_t cpid = LIBC_NAMESPACE::waitpid(pid, &status, 0);
49 ASSERT_TRUE(cpid > 0);
50 ASSERT_EQ(cpid, pid);
51 ASSERT_FALSE(WIFEXITED(status));
52 ASSERT_TRUE(WTERMSIG(status) == SIGUSR1);
55 TEST_MAIN(int argc, char **argv, char **envp) {
56 fork_and_execv_normal_exit(envp);
57 fork_and_execv_signal_exit(envp);
58 return 0;