Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Remove logfile after test #88

Merged
merged 2 commits into from
Mar 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/web100srv_unit_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ void make_certificate_files(char *private_key_file, char *certificate_file) {
CHECK(system(create_certificate_command_line) == 0);
}


#define LOGFILE_TEMPLATE "/tmp/web100srv.log-XXXXXX"

/** Starts the web100srv process. Either args must be NULL or the last element
* of **args must be NULL. */
pid_t start_server(int port, char **extra_args) {
Expand All @@ -66,10 +69,17 @@ pid_t start_server(int port, char **extra_args) {
siginfo_t server_status;
char port_string[6]; // 32767 is the max port, so must hold 5 digits + \0
int rv;
char *args_for_exec[256] = {"./web100srv", "--snaplog", "--tcpdump", "--cputime", "--log_dir", "/tmp", "--port", NULL};
char *args_for_exec[256] = {"./web100srv", "--snaplog", "--tcpdump",
"--cputime", "--log_dir", "/tmp", "-l", LOGFILE_TEMPLATE, "--port", NULL};
int exec_args_index = 0;
// Should be set to the first index of args_for_exec that is NULL
while (args_for_exec[exec_args_index] != NULL) exec_args_index++;
// set exec_args_index to the first index of args_for_exec that is NULL
while (args_for_exec[exec_args_index] != NULL) {
// along the way, fill in the template for the test logs
if (strcmp(args_for_exec[exec_args_index], LOGFILE_TEMPLATE) == 0) {
mkstemp(args_for_exec[exec_args_index]);
}
exec_args_index++;
}
log_println(1, "Starting the server");
if ((server_pid = fork()) == 0) {
sprintf(port_string, "%d", port);
Expand Down