Gabe Black has submitted this change and it was merged. (
https://gem5-review.googlesource.com/6081 )
Change subject: tests: Build the input file into the initest unit test.
......................................................................
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 <[email protected]>
Maintainer: Andreas Sandberg <[email protected]>
---
M src/unittest/initest.cc
D src/unittest/initest.ini
2 files changed, 20 insertions(+), 74 deletions(-)
Approvals:
Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
diff --git a/src/unittest/initest.cc b/src/unittest/initest.cc
index 7e103aa..222fcab 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;
diff --git a/src/unittest/initest.ini b/src/unittest/initest.ini
deleted file mode 100644
index 212c790..0000000
--- 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
--
To view, visit https://gem5-review.googlesource.com/6081
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2c9ea9fa79781bceb5cd3d1419870924e8bbd45f
Gerrit-Change-Number: 6081
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Assignee: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-CC: Nikos Nikoleris <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev