Skip to content

Commit

Permalink
Automatic filenames are now written relative to cwd
Browse files Browse the repository at this point in the history
Instead of them being relative to the scenario file, they are now placed in the
current working directory. This makes more sense.

Closes #399
  • Loading branch information
wdoekes committed May 27, 2019
1 parent c98d546 commit 90ab1ef
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 43 deletions.
12 changes: 10 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
BREAKING(!) changes in 3.6.0
============================

* Automatic filenames (trace files, error files, etc..) are now created in
the current working directory instead of in the directory of the scenario
file. (Issue #399, reported by @sergey-safarov.)
* Only validates SSL certficate if CA-file is separately specified!
(PR #335, by Patrick Wildt @bluerise.)


Bugs fixed in 3.6.0
===================

Expand All @@ -9,8 +19,6 @@ Bugs fixed in 3.6.0
Changes in 3.6.0
================

* BEWARE: Only validates SSL certficate if CA-file is separately specified!
(PR #335, by Patrick Wildt @bluerise.)
* Added PAGER by default to the extremely large sipp help output.
* Removed unused RTPStream code concerning video streams. Also
consolidated the rtpstream audio port usage to reuse the global
Expand Down
20 changes: 12 additions & 8 deletions src/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@
#include <iterator>
#include <sstream>
#include <vector>

#include <assert.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <assert.h>

#ifdef PCAPPLAY
#include "send_packets.h"
#endif

#include "sipp.hpp"
#include "auth.hpp"
#include "deadcall.hpp"
Expand Down Expand Up @@ -1060,28 +1063,29 @@ char * call::send_scene(int index, int *send_status, int *len)
void call::do_bookkeeping(message *curmsg)
{
/* If this message increments a counter, do it now. */
if(int counter = curmsg -> counter) {
computeStat(CStat::E_ADD_GENERIC_COUNTER, 1, counter - 1);
if (curmsg -> counter) {
computeStat(CStat::E_ADD_GENERIC_COUNTER, 1, curmsg->counter - 1);
}

/* If this message can be used to compute RTD, do it now */
if(int rtd = curmsg -> start_rtd) {
start_time_rtd[rtd - 1] = getmicroseconds();
if (curmsg->start_rtd) {
start_time_rtd[curmsg->start_rtd - 1] = getmicroseconds();
}

if(int rtd = curmsg -> stop_rtd) {
if (curmsg->stop_rtd) {
int rtd = curmsg->stop_rtd;
if (!rtd_done[rtd - 1]) {
unsigned long long start = start_time_rtd[rtd - 1];
unsigned long long end = getmicroseconds();

if(dumpInRtt) {
if (dumpInRtt) {
call_scenario->stats->computeRtt(start, end, rtd);
}

computeStat(CStat::E_ADD_RESPONSE_TIME_DURATION,
(end - start) / 1000, rtd - 1);

if (!curmsg -> repeat_rtd) {
if (!curmsg->repeat_rtd) {
rtd_done[rtd - 1] = true;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

#include "logger.hpp"
#include "screen.hpp"
#include "sipp.hpp"

#define SIPP_ENDL "\r\n"

Expand Down
12 changes: 4 additions & 8 deletions src/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,21 @@
* Screen.cpp : Simple curses & logfile encapsulation
*/

#include "stat.hpp"
#include "sipp.hpp"

#include <stdarg.h>
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <screen.hpp>
#include <errno.h>
#include <sys/time.h>
#include <sys/resource.h>

#ifdef __SUNOS
#include <stdarg.h>
#endif

#include <unistd.h>

#include "screen.hpp"
#include "sipp.hpp"

/* Export these so others needn't include curses.h */
int key_backspace = KEY_BACKSPACE;
int key_dc = KEY_DC;
Expand Down
4 changes: 2 additions & 2 deletions src/send_packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ float2timer(float time, struct timeval *tvp)
static char* find_file(const char* filename)
{
char *fullpath;
if (filename[0] == '/' || !scenario_path) {
if (filename[0] == '/' || !*scenario_path) {
return strdup(filename);
}

fullpath = malloc(MAX_PATH);
snprintf(fullpath, MAX_PATH, "%s/%s", scenario_path, filename);
snprintf(fullpath, MAX_PATH, "%s%s", scenario_path, filename);

if (access(fullpath, R_OK) < 0) {
free(fullpath);
Expand Down
44 changes: 23 additions & 21 deletions src/sipp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,18 +1149,20 @@ static void set_scenario(const char* name)
free(scenario_file);
free(scenario_path);

const char* ext = strrchr(name, '.');
if (ext && strcmp(ext, ".xml") == 0) {
scenario_file = strndup(name, ext - name);
const char* sep = strrchr(name, '/');
if (sep) {
++sep; // include slash
scenario_path = strndup(name, sep - name);
} else {
scenario_file = strdup(name);
scenario_path = strdup("");
sep = name;
}

const char* sep = strrchr(scenario_file, '/');
if (sep) {
scenario_path = strndup(scenario_file, sep - scenario_file);
const char* ext = strrchr(sep, '.');
if (ext && strcmp(ext, ".xml") == 0) {
scenario_file = strndup(sep, ext - sep);
} else {
scenario_path = NULL;
scenario_file = strdup(sep);
}
}

Expand Down Expand Up @@ -1636,7 +1638,9 @@ int main(int argc, char *argv[])
case SIPP_OPTION_SCENARIO:
REQUIRE_ARG();
CHECK_PASS();
if (!strcmp(argv[argi - 1], "-sf")) {
if (main_scenario) {
ERROR("Internal error, main_scenario already set");
} else if (!strcmp(argv[argi - 1], "-sf")) {
set_scenario(argv[argi]);
if (useLogf == 1) {
rotate_logfile();
Expand All @@ -1645,10 +1649,9 @@ int main(int argc, char *argv[])
main_scenario->stats->setFileName(scenario_file, ".csv");
} else if (!strcmp(argv[argi - 1], "-sn")) {
int i = find_scenario(argv[argi]);

main_scenario = new scenario(0, i);
set_scenario(argv[argi]);
main_scenario->stats->setFileName(argv[argi], ".csv");
main_scenario = new scenario(0, i);
main_scenario->stats->setFileName(scenario_file, ".csv");
} else if (!strcmp(argv[argi - 1], "-sd")) {
int i = find_scenario(argv[argi]);
fprintf(stdout, "%s", default_scenario[i]);
Expand Down Expand Up @@ -1870,9 +1873,13 @@ int main(int argc, char *argv[])
lose_packets = 1;
}

/* trace file setting */
/* If no scenario was selected, choose the uac one */
if (scenario_file == NULL) {
set_scenario("sipp");
assert(main_scenario == NULL);
int i = find_scenario("uac");
set_scenario("uac");
main_scenario = new scenario(0, i);
main_scenario->stats->setFileName(scenario_file, ".csv");
}

#ifdef USE_TLS
Expand Down Expand Up @@ -1929,7 +1936,7 @@ int main(int argc, char *argv[])


if (dumpInRtt == 1) {
main_scenario->stats->initRtt((char*)scenario_file, (char*)".csv",
main_scenario->stats->initRtt(scenario_file, ".csv",
report_freq_dumpRtt);
}

Expand Down Expand Up @@ -1964,12 +1971,6 @@ int main(int argc, char *argv[])
}
}

/* Load default scenario in case nothing was loaded */
if (!main_scenario) {
main_scenario = new scenario(0, 0);
main_scenario->stats->setFileName("uac", ".csv");
sprintf(scenario_file,"uac");
}
/*
if (!ooc_scenario) {
ooc_scenario = new scenario(0, find_scenario("ooc_default"));
Expand Down Expand Up @@ -2122,5 +2123,6 @@ int main(int argc, char *argv[])
#endif

free(scenario_file);
free(scenario_path);
sipp_exit(EXIT_TEST_RES_UNKNOWN);
}

0 comments on commit 90ab1ef

Please sign in to comment.