From: Gabe Black Date: Thu, 21 Jan 2021 12:50:11 +0000 (-0800) Subject: tests: Stop "using namespace std" in unittest/. X-Git-Tag: develop-gem5-snapshot~237 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=61dbd95e1b032f395620299bd57532d932e97de2;p=gem5.git tests: Stop "using namespace std" in unittest/. These are the historical "unit test"s, which aren't really unit tests, they're actually complete builds of gem5 with main functions which run a fairly specific test instead of a simulation. They test a single unit, but they do it with all the other units in place and potentially participating in the test. Change-Id: Ib0ea68f26091a79992396d932627e4ce180f7825 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39565 Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini Tested-by: kokoro --- diff --git a/src/unittest/cprintftime.cc b/src/unittest/cprintftime.cc index f8f14926b..a09c4cb3b 100644 --- a/src/unittest/cprintftime.cc +++ b/src/unittest/cprintftime.cc @@ -36,8 +36,6 @@ #include "base/cprintf.hh" -using namespace std; - volatile int stop = false; void @@ -56,14 +54,14 @@ do_test(int seconds) int main() { - stringstream result; + std::stringstream result; int iterations = 0; signal(SIGALRM, handle_alarm); do_test(10); while (!stop) { - stringstream result; + std::stringstream result; ccprintf(result, "this is a %s of %d iterations %3.2f %p\n", "test", iterations, 51.934, &result); diff --git a/src/unittest/nmtest.cc b/src/unittest/nmtest.cc index f25c5e1e2..fd245243a 100644 --- a/src/unittest/nmtest.cc +++ b/src/unittest/nmtest.cc @@ -34,8 +34,6 @@ #include "base/logging.hh" #include "base/str.hh" -using namespace std; - int main(int argc, char *argv[]) { @@ -50,7 +48,7 @@ main(int argc, char *argv[]) for (const Loader::Symbol &symbol: obj->symtab()) cprintf("%#x %s\n", symbol.address, symbol.name); } else { - string symbol = argv[2]; + std::string symbol = argv[2]; Addr address; if (symbol[0] == '0' && symbol[1] == 'x') { diff --git a/src/unittest/stattest.cc b/src/unittest/stattest.cc index e58a5a678..650c13790 100644 --- a/src/unittest/stattest.cc +++ b/src/unittest/stattest.cc @@ -50,7 +50,6 @@ const char *m5MainCommands[] = { 0 // sentinel is required }; -using namespace std; using namespace Stats; double testfunc(); diff --git a/src/unittest/symtest.cc b/src/unittest/symtest.cc index 369e1a4d9..6de3c8d31 100644 --- a/src/unittest/symtest.cc +++ b/src/unittest/symtest.cc @@ -31,14 +31,13 @@ #include "base/loader/symtab.hh" #include "base/str.hh" -using namespace std; - void usage(const char *progname); void usage(const char *progname) { - cout << "Usage: " << progname << " " << endl; + std::cout << "Usage: " << progname << " " + << std::endl; exit(1); } @@ -52,29 +51,31 @@ main(int argc, char *argv[]) usage(argv[0]); if (!symtab.load(argv[1])) { - cout << "could not load symbol file: " << argv[1] << endl; + std::cout << "could not load symbol file: " << argv[1] << std::endl; exit(1); } - string symbol = argv[2]; + std::string symbol = argv[2]; Addr address; if (!to_number(symbol, address)) { auto it = symtab.find(symbol); if (it == symtab.end()) { - cout << "could not find symbol: " << symbol << endl; + std::cout << "could not find symbol: " << symbol << std::endl; exit(1); } - cout << symbol << " -> " << "0x" << hex << it->address << endl; + std::cout << symbol << " -> " << "0x" << std::hex << it->address << + std::endl; } else { auto it = symtab.find(address); if (it == symtab.end()) { - cout << "could not find address: " << address << endl; + std::cout << "could not find address: " << address << std::endl; exit(1); } - cout << "0x" << hex << address << " -> " << it->name << endl; + std::cout << "0x" << std::hex << address << " -> " << it->name << + std::endl; } return 0;