Skip to content

Commit 7b68356

Browse files
committed
Automatic filenames are now written relative to cwd
Instead of them being relative to the scenario file, they are now placed in the current working directory. This makes more sense. Closes #399
1 parent c98d546 commit 7b68356

File tree

6 files changed

+51
-43
lines changed

6 files changed

+51
-43
lines changed

CHANGES.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
BREAKING(!) changes in 3.6.0
2+
============================
3+
4+
* Automatic filenames (trace files, error files, etc..) are now created in
5+
the current working directory instead of in the directory of the scenario
6+
file. (Issue #399, reported by @sergey-safarov.)
7+
* Only validates SSL certficate if CA-file is separately specified!
8+
(PR #335, by Patrick Wildt @bluerise.)
9+
10+
111
Bugs fixed in 3.6.0
212
===================
313

@@ -9,8 +19,6 @@ Bugs fixed in 3.6.0
919
Changes in 3.6.0
1020
================
1121

12-
* BEWARE: Only validates SSL certficate if CA-file is separately specified!
13-
(PR #335, by Patrick Wildt @bluerise.)
1422
* Added PAGER by default to the extremely large sipp help output.
1523
* Removed unused RTPStream code concerning video streams. Also
1624
consolidated the rtpstream audio port usage to reuse the global

src/call.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@
4545
#include <iterator>
4646
#include <sstream>
4747
#include <vector>
48+
49+
#include <assert.h>
50+
#include <stdarg.h>
4851
#include <sys/types.h>
4952
#include <sys/wait.h>
50-
#include <assert.h>
5153

5254
#ifdef PCAPPLAY
5355
#include "send_packets.h"
5456
#endif
57+
5558
#include "sipp.hpp"
5659
#include "auth.hpp"
5760
#include "deadcall.hpp"
@@ -1060,28 +1063,29 @@ char * call::send_scene(int index, int *send_status, int *len)
10601063
void call::do_bookkeeping(message *curmsg)
10611064
{
10621065
/* If this message increments a counter, do it now. */
1063-
if(int counter = curmsg -> counter) {
1064-
computeStat(CStat::E_ADD_GENERIC_COUNTER, 1, counter - 1);
1066+
if (curmsg -> counter) {
1067+
computeStat(CStat::E_ADD_GENERIC_COUNTER, 1, curmsg->counter - 1);
10651068
}
10661069

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

1072-
if(int rtd = curmsg -> stop_rtd) {
1075+
if (curmsg->stop_rtd) {
1076+
int rtd = curmsg->stop_rtd;
10731077
if (!rtd_done[rtd - 1]) {
10741078
unsigned long long start = start_time_rtd[rtd - 1];
10751079
unsigned long long end = getmicroseconds();
10761080

1077-
if(dumpInRtt) {
1081+
if (dumpInRtt) {
10781082
call_scenario->stats->computeRtt(start, end, rtd);
10791083
}
10801084

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

1084-
if (!curmsg -> repeat_rtd) {
1088+
if (!curmsg->repeat_rtd) {
10851089
rtd_done[rtd - 1] = true;
10861090
}
10871091
}

src/logger.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@
4141
#include <string.h>
4242
#include <sys/types.h>
4343
#include <unistd.h>
44+
4445
#include "logger.hpp"
45-
#include "screen.hpp"
46-
#include "sipp.hpp"
4746

4847
#define SIPP_ENDL "\r\n"
4948

src/screen.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,21 @@
2121
* Screen.cpp : Simple curses & logfile encapsulation
2222
*/
2323

24-
#include "stat.hpp"
25-
#include "sipp.hpp"
2624

25+
#include <stdarg.h>
2726
#include <curses.h>
2827
#include <stdio.h>
2928
#include <stdlib.h>
3029
#include <string.h>
3130
#include <signal.h>
32-
#include <screen.hpp>
3331
#include <errno.h>
3432
#include <sys/time.h>
3533
#include <sys/resource.h>
36-
37-
#ifdef __SUNOS
38-
#include <stdarg.h>
39-
#endif
40-
4134
#include <unistd.h>
4235

36+
#include "screen.hpp"
37+
#include "sipp.hpp"
38+
4339
/* Export these so others needn't include curses.h */
4440
int key_backspace = KEY_BACKSPACE;
4541
int key_dc = KEY_DC;

src/send_packets.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ float2timer(float time, struct timeval *tvp)
8888
static char* find_file(const char* filename)
8989
{
9090
char *fullpath;
91-
if (filename[0] == '/' || !scenario_path) {
91+
if (filename[0] == '/' || !*scenario_path) {
9292
return strdup(filename);
9393
}
9494

9595
fullpath = malloc(MAX_PATH);
96-
snprintf(fullpath, MAX_PATH, "%s/%s", scenario_path, filename);
96+
snprintf(fullpath, MAX_PATH, "%s%s", scenario_path, filename);
9797

9898
if (access(fullpath, R_OK) < 0) {
9999
free(fullpath);

src/sipp.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,18 +1149,20 @@ static void set_scenario(const char* name)
11491149
free(scenario_file);
11501150
free(scenario_path);
11511151

1152-
const char* ext = strrchr(name, '.');
1153-
if (ext && strcmp(ext, ".xml") == 0) {
1154-
scenario_file = strndup(name, ext - name);
1152+
const char* sep = strrchr(name, '/');
1153+
if (sep) {
1154+
++sep; // include slash
1155+
scenario_path = strndup(name, sep - name);
11551156
} else {
1156-
scenario_file = strdup(name);
1157+
scenario_path = strdup("");
1158+
sep = name;
11571159
}
11581160

1159-
const char* sep = strrchr(scenario_file, '/');
1160-
if (sep) {
1161-
scenario_path = strndup(scenario_file, sep - scenario_file);
1161+
const char* ext = strrchr(sep, '.');
1162+
if (ext && strcmp(ext, ".xml") == 0) {
1163+
scenario_file = strndup(sep, ext - sep);
11621164
} else {
1163-
scenario_path = NULL;
1165+
scenario_file = strdup(sep);
11641166
}
11651167
}
11661168

@@ -1636,7 +1638,9 @@ int main(int argc, char *argv[])
16361638
case SIPP_OPTION_SCENARIO:
16371639
REQUIRE_ARG();
16381640
CHECK_PASS();
1639-
if (!strcmp(argv[argi - 1], "-sf")) {
1641+
if (main_scenario) {
1642+
ERROR("Internal error, main_scenario already set");
1643+
} else if (!strcmp(argv[argi - 1], "-sf")) {
16401644
set_scenario(argv[argi]);
16411645
if (useLogf == 1) {
16421646
rotate_logfile();
@@ -1645,10 +1649,9 @@ int main(int argc, char *argv[])
16451649
main_scenario->stats->setFileName(scenario_file, ".csv");
16461650
} else if (!strcmp(argv[argi - 1], "-sn")) {
16471651
int i = find_scenario(argv[argi]);
1648-
1649-
main_scenario = new scenario(0, i);
16501652
set_scenario(argv[argi]);
1651-
main_scenario->stats->setFileName(argv[argi], ".csv");
1653+
main_scenario = new scenario(0, i);
1654+
main_scenario->stats->setFileName(scenario_file, ".csv");
16521655
} else if (!strcmp(argv[argi - 1], "-sd")) {
16531656
int i = find_scenario(argv[argi]);
16541657
fprintf(stdout, "%s", default_scenario[i]);
@@ -1870,9 +1873,13 @@ int main(int argc, char *argv[])
18701873
lose_packets = 1;
18711874
}
18721875

1873-
/* trace file setting */
1876+
/* If no scenario was selected, choose the uac one */
18741877
if (scenario_file == NULL) {
1875-
set_scenario("sipp");
1878+
assert(main_scenario == NULL);
1879+
int i = find_scenario("uac");
1880+
set_scenario("uac");
1881+
main_scenario = new scenario(0, i);
1882+
main_scenario->stats->setFileName(scenario_file, ".csv");
18761883
}
18771884

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

19301937

19311938
if (dumpInRtt == 1) {
1932-
main_scenario->stats->initRtt((char*)scenario_file, (char*)".csv",
1939+
main_scenario->stats->initRtt(scenario_file, ".csv",
19331940
report_freq_dumpRtt);
19341941
}
19351942

@@ -1964,12 +1971,6 @@ int main(int argc, char *argv[])
19641971
}
19651972
}
19661973

1967-
/* Load default scenario in case nothing was loaded */
1968-
if (!main_scenario) {
1969-
main_scenario = new scenario(0, 0);
1970-
main_scenario->stats->setFileName("uac", ".csv");
1971-
sprintf(scenario_file,"uac");
1972-
}
19731974
/*
19741975
if (!ooc_scenario) {
19751976
ooc_scenario = new scenario(0, find_scenario("ooc_default"));

0 commit comments

Comments
 (0)