40 snprintf (child_cmd,
sizeof child_cmd,
42 return exec (child_cmd);
58 for (fd = 0; fd < fdmax; fd++)
70 volatile int *
PHYS_BASE = (
volatile int *)0xC0000000;
75 *(
volatile int *)
NULL = 42;
78 return *(
volatile int *)
NULL;
110 n = argc > 1 ?
atoi (argv[1]) : 0;
111 bool is_at_root = (n == 0);
116 if (argc > 2 && !
strcmp(argv[2],
"-k"))
123 int i, expected_depth = -1;
125 for (i = 0; i < howmany; i++)
137 if (
wait (child_pid) != -1)
138 fail (
"crashed child should return -1.");
152 int reached_depth =
wait (child_pid);
153 if (reached_depth == -1)
154 fail (
"wait returned -1.");
160 expected_depth = reached_depth;
161 else if (expected_depth != reached_depth)
162 fail (
"after run %d/%d, expected depth %d, actual depth %d.",
163 i, howmany, expected_depth, reached_depth);
164 ASSERT (expected_depth == reached_depth);
173 msg (
"success. program forked %d times.", howmany);
177 return expected_depth;
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
#define NOT_REACHED()
lib/debug.h
static void wait(struct intq *q, struct thread **waiter)
int snprintf(char *buffer, size_t buf_size, const char *format,...)
Like printf(), except that output is stored into BUFFER, which must have space for BUF_SIZE character...
int atoi(const char *s)
Converts a string representation of a signed decimal integer in S into an ‘int’, which is returned.
int open(const char *file)
pid_t exec(const char *file)
int pid_t
Process identifier.
void fail(const char *format,...)
void msg(const char *format,...)
static void consume_some_resources(void)
Open a number of files (and fail to close them).
int main(int argc, char *argv[])
The first copy is invoked without command line arguments.
static const int EXPECTED_DEPTH_TO_PASS
Recursively executes itself until the child fails to execute.
const char * test_name
Child process for syn-read test.
static pid_t spawn_child(int c, enum child_termination_mode mode)
Spawn a recursive copy of ourselves, passing along instructions for the child.
static const int EXPECTED_REPETITIONS
static int NO_INLINE consume_some_resources_and_die(int seed)
Consume some resources, then terminate this process in some abnormal way.
unsigned long random_ulong(void)
Returns a pseudo-random unsigned long.
void random_init(unsigned seed)
Initializes or reinitializes the PRNG with the given SEED.
static enum @0 mode
Transmission mode.
int strcmp(const char *a_, const char *b_)
Finds the first differing characters in strings A and B.
#define PHYS_BASE
Base address of the 1:1 physical-to-virtual mapping.