diff options
author | Gabe Black <gabeblack@google.com> | 2017-11-22 18:02:13 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2017-11-27 22:14:37 +0000 |
commit | 3dfb2ef499ed35f999b215817283f4ea45837bf2 (patch) | |
tree | 3116324df7a739cb0b2c10e8ac80be11e0b8f9fd /src/unittest/initest.cc | |
parent | be62a45749dcc4eca09042eea52c04eb7f2ab864 (diff) | |
download | gem5-3dfb2ef499ed35f999b215817283f4ea45837bf2.tar.xz |
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 <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/unittest/initest.cc')
-rw-r--r-- | src/unittest/initest.cc | 77 |
1 files changed, 20 insertions, 57 deletions
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 << " <ini file>\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: - // '--<section>:<parameter>=<value>' - - if (!simConfigDB.add(arg_str + 2)) { - // parse error - ccprintf(cerr, - "Could not parse configuration argument '%s'\n" - "Expecting --<section>:<parameter>=<value>\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; |