From 3dfb2ef499ed35f999b215817283f4ea45837bf2 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 22 Nov 2017 18:02:13 -0800 Subject: tests: Build the input file into the initest unit test. This breaks an external dependency and makes the expected command line conform to the other unit tests. Also get rid of some ancient tests which test adding to the ini's contents based on command line arguments. This test still needs to be modified so that it actually checks whether what happened was correct. Change-Id: I2c9ea9fa79781bceb5cd3d1419870924e8bbd45f Reviewed-on: https://gem5-review.googlesource.com/6081 Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- src/unittest/initest.cc | 77 +++++++++++++----------------------------------- src/unittest/initest.ini | 17 ----------- 2 files changed, 20 insertions(+), 74 deletions(-) delete mode 100644 src/unittest/initest.ini (limited to 'src/unittest') diff --git a/src/unittest/initest.cc b/src/unittest/initest.cc index 7e103aa50..222fcabae 100644 --- a/src/unittest/initest.cc +++ b/src/unittest/initest.cc @@ -39,72 +39,35 @@ using namespace std; -char *progname; +namespace { -void usage(); +std::istringstream iniFile(R"ini_file( +[General] + Test1=BARasdf + Test2=bar -void -usage() -{ - cout << "Usage: " << progname << " \n"; - exit(1); -} +[Junk] +Test3=yo +Test4=mama -#if 0 -char *defines = getenv("CONFIG_DEFINES"); -if (defines) { - char *c = defines; - while ((c = strchr(c, ' ')) != NULL) { - *c++ = '\0'; - count++; - } - count++; -} +[Foo] +Foo1=89 +Foo2=384 -#endif +[General] +Test3=89 + +[Junk] +Test4+=mia +)ini_file"); + +}; int main(int argc, char *argv[]) { IniFile simConfigDB; - - progname = argv[0]; - - for (int i = 1; i < argc; ++i) { - char *arg_str = argv[i]; - - // if arg starts with '-', parse as option, - // else treat it as a configuration file name and load it - if (arg_str[0] == '-') { - // switch on second char - switch (arg_str[1]) { - case '-': - // command-line configuration parameter: - // '--
:=' - - if (!simConfigDB.add(arg_str + 2)) { - // parse error - ccprintf(cerr, - "Could not parse configuration argument '%s'\n" - "Expecting --
:=\n", - arg_str); - exit(0); - } - break; - - default: - usage(); - } - } - else { - // no '-', treat as config file name - - if (!simConfigDB.load(arg_str)) { - cprintf("Error processing file %s\n", arg_str); - exit(1); - } - } - } + simConfigDB.load(iniFile); string value; diff --git a/src/unittest/initest.ini b/src/unittest/initest.ini deleted file mode 100644 index 212c7902e..000000000 --- a/src/unittest/initest.ini +++ /dev/null @@ -1,17 +0,0 @@ -[General] - Test1=BARasdf - Test2=bar - -[Junk] -Test3=yo -Test4=mama - -[Foo] -Foo1=89 -Foo2=384 - -[General] -Test3=89 - -[Junk] -Test4+=mia -- cgit v1.2.3