summaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2008-10-02 11:26:59 -0700
committerNathan Binkert <nate@binkert.org>2008-10-02 11:26:59 -0700
commit52493b27202fb61aaae74779ebcd91ca8f2bbc2c (patch)
treeeafc46fbeb182b85c766910dfcef544df2e1723a /src/unittest
parent67a2918abc057f8f6d693d8acadd70bf9337cf44 (diff)
downloadgem5-52493b27202fb61aaae74779ebcd91ca8f2bbc2c.tar.xz
unittest: Cleanup unit tests. Follow style. Garbage Collect.
--HG-- rename : src/unittest/rangemaptest2.cc => src/unittest/rangemultimaptest.cc
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/bitvectest.cc48
-rw-r--r--src/unittest/circletest.cc55
-rw-r--r--src/unittest/foo.ini1
-rw-r--r--src/unittest/initest.ini14
-rw-r--r--src/unittest/lru_test.cc85
-rw-r--r--src/unittest/offtest.cc72
-rw-r--r--src/unittest/paramtest.cc107
-rw-r--r--src/unittest/rangemaptest.cc3
-rw-r--r--src/unittest/rangemultimaptest.cc (renamed from src/unittest/rangemaptest2.cc)14
-rw-r--r--src/unittest/rangetest.cc57
-rw-r--r--src/unittest/sized_test.cc70
-rw-r--r--src/unittest/strnumtest.cc63
-rw-r--r--src/unittest/tracetest.cc56
13 files changed, 122 insertions, 523 deletions
diff --git a/src/unittest/bitvectest.cc b/src/unittest/bitvectest.cc
index 440a150a3..2f01d636f 100644
--- a/src/unittest/bitvectest.cc
+++ b/src/unittest/bitvectest.cc
@@ -35,34 +35,34 @@
int
main()
{
- vector<bool> v1(100);
+ vector<bool> v1(100);
- v1[0] = true;
- v1.resize(500);
- v1[100] = true;
- v1[499] = true;
- v1.resize(10000);
- v1[9999] = true;
+ v1[0] = true;
+ v1.resize(500);
+ v1[100] = true;
+ v1[499] = true;
+ v1.resize(10000);
+ v1[9999] = true;
- cout << "v1.size() = " << v1.size() << "\n";
- for (int i = 0; i < v1.size(); i++)
- if (v1[i])
- cout << "v1[" << i << "] = " << v1[i] << "\n";
+ cout << "v1.size() = " << v1.size() << "\n";
+ for (int i = 0; i < v1.size(); i++)
+ if (v1[i])
+ cout << "v1[" << i << "] = " << v1[i] << "\n";
- cout << "\n";
+ cout << "\n";
- vector<bool> v2 = v1;
+ vector<bool> v2 = v1;
- for (int i = 0; i < v2.size(); i++)
- if (v2[i])
- cout << "v2[" << i << "] = " << v2[i] << "\n";
+ for (int i = 0; i < v2.size(); i++)
+ if (v2[i])
+ cout << "v2[" << i << "] = " << v2[i] << "\n";
- cout << "v1 " << ((v1 == v2) ? "==" : "!=") << " v2" << "\n";
- v2[8583] = true;
- cout << "v1 " << ((v1 == v2) ? "==" : "!=") << " v2" << "\n";
- v1[8583] = true;
- cout << "v1 " << ((v1 == v2) ? "==" : "!=") << " v2" << "\n";
- v1.resize(100000);
- cout << "v1 " << ((v1 == v2) ? "==" : "!=") << " v2" << "\n";
- cout << flush;
+ cout << "v1 " << ((v1 == v2) ? "==" : "!=") << " v2" << "\n";
+ v2[8583] = true;
+ cout << "v1 " << ((v1 == v2) ? "==" : "!=") << " v2" << "\n";
+ v1[8583] = true;
+ cout << "v1 " << ((v1 == v2) ? "==" : "!=") << " v2" << "\n";
+ v1.resize(100000);
+ cout << "v1 " << ((v1 == v2) ? "==" : "!=") << " v2" << "\n";
+ cout << flush;
}
diff --git a/src/unittest/circletest.cc b/src/unittest/circletest.cc
index f072cf044..c6fce0f8f 100644
--- a/src/unittest/circletest.cc
+++ b/src/unittest/circletest.cc
@@ -34,14 +34,15 @@
#include "base/circlebuf.hh"
-char *strings[] =
-{ "This is the first test\n",
- "he went with his woman to the store\n",
- "the man with the bat hit the woman with the hat\n",
- "that that is is that that was\n",
- "sue sells sea shells by the sea shore\n",
- "go to the store and buy me some milk and bread\n",
- "the friendly flight attendants spoke soothingly to the frightened passengers in their native languages\n"
+char *strings[] = {
+ "This is the first test\n",
+ "he went with his woman to the store\n",
+ "the man with the bat hit the woman with the hat\n",
+ "that that is is that that was\n",
+ "sue sells sea shells by the sea shore\n",
+ "go to the store and buy me some milk and bread\n",
+ "the friendly flight attendants spoke soothingly to "
+ "the frightened passengers in their native languages\n"
};
const int num_strings = sizeof(strings) / sizeof(char *);
@@ -49,26 +50,26 @@ const int num_strings = sizeof(strings) / sizeof(char *);
int
main()
{
- CircleBuf buf(1024);
+ CircleBuf buf(1024);
- for (int count = 0; count < 100; count++)
- buf.write(strings[count % num_strings]);
- buf.read(STDOUT_FILENO);
- write(STDOUT_FILENO, "<\n", 2);
+ for (int count = 0; count < 100; count++)
+ buf.write(strings[count % num_strings]);
+ buf.read(STDOUT_FILENO);
+ write(STDOUT_FILENO, "<\n", 2);
- for (int count = 0; count < 100; count++)
- buf.write(strings[count % num_strings]);
- buf.read(STDOUT_FILENO, 100);
- write(STDOUT_FILENO, "<\n", 2);
+ for (int count = 0; count < 100; count++)
+ buf.write(strings[count % num_strings]);
+ buf.read(STDOUT_FILENO, 100);
+ write(STDOUT_FILENO, "<\n", 2);
- buf.flush();
- buf.write("asdfa asdf asd fasdf asdf\n");
- buf.write("");
- buf.write("");
- buf.write("");
- buf.write("");
- buf.write("");
- buf.write("");
- buf.read(STDOUT_FILENO);
- write(STDOUT_FILENO, "<\n", 2);
+ buf.flush();
+ buf.write("asdfa asdf asd fasdf asdf\n");
+ buf.write("");
+ buf.write("");
+ buf.write("");
+ buf.write("");
+ buf.write("");
+ buf.write("");
+ buf.read(STDOUT_FILENO);
+ write(STDOUT_FILENO, "<\n", 2);
}
diff --git a/src/unittest/foo.ini b/src/unittest/foo.ini
index 534a4e001..0f91c1fd6 100644
--- a/src/unittest/foo.ini
+++ b/src/unittest/foo.ini
@@ -1,4 +1,3 @@
-#define JUNK
[Foo]
Foo1=89
Foo2=384
diff --git a/src/unittest/initest.ini b/src/unittest/initest.ini
deleted file mode 100644
index ebf2719d8..000000000
--- a/src/unittest/initest.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-#define JUNK
-// General stuff
-#define FOO(X) BAR##X
-[General]
- Test1=FOO(asdf)
- Test2=bar
-
-#ifdef JUNK
-[Junk] // This is the junk
-Test3=yo
-Test4=mama
-#endif
-
-#include "foo.ini"
diff --git a/src/unittest/lru_test.cc b/src/unittest/lru_test.cc
deleted file mode 100644
index d10eb1dd0..000000000
--- a/src/unittest/lru_test.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2003-2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Dave Greene
- * Nathan Binkert
- */
-
-#include <iostream>
-#include "bhgp.hh"
-
-int main(void)
-{
- typedef AssociativeTable<unsigned int, unsigned int> tableType;
- tableType table(10, 4); // 40 entry table
-
- std::cout << "Initial state:" << std::endl;
- table.dump();
-
- std::cout << "Inserting (2, 1)" << std::endl;
- table[2] = 1;
- table.dump();
-
- std::cout << "Inserting (5, 2)" << std::endl;
- table[5] = 2;
- table.dump();
-
- std::cout << "Inserting (10 + 2, 3)" << std::endl;
- table[10 + 2] = 3;
- table.dump();
-
- tableType::const_iterator i = table.find(2);
- assert(i != table.end());
- std::cout << "Accessed 2: " << *i << std::endl;
- table.dump();
-
- i = table.find(10 + 2);
- assert(i != table.end());
- std::cout << "Accessed 10 + 2: " << *i << std::endl;
- table.dump();
-
- i = table.find(34);
- assert(i == table.end());
-
- std::cout << "Inserting (2 * 10 + 2, 4)" << std::endl;
- table[2 * 10 + 2] = 4;
- table.dump();
-
- std::cout << "Replacing (10 + 2) with 5" << std::endl;
- table[10 + 2] = 5;
- table.dump();
-
- std::cout << "Inserting (3 * 10 + 2, 6)" << std::endl;
- table[3 * 10 + 2] = 6;
- table.dump();
-
- std::cout << "Inserting (4 * 10 + 2, 7)" << std::endl;
- table[4 * 10 + 2] = 7;
- table.dump();
-
- return(0);
-}
diff --git a/src/unittest/offtest.cc b/src/unittest/offtest.cc
deleted file mode 100644
index ebfb2515c..000000000
--- a/src/unittest/offtest.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2002-2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
- */
-
-#include <sys/types.h>
-#include <stddef.h>
-#include <stdio.h>
-#include "dev/pcireg.h"
-
-int
-main()
-{
-#define POFFSET(x) \
- printf("offsetof(PCIConfig, hdr."#x") = %d\n", \
- offsetof(PCIConfig, hdr.x))
-
- POFFSET(vendor);
- POFFSET(device);
- POFFSET(command);
- POFFSET(status);
- POFFSET(revision);
- POFFSET(progIF);
- POFFSET(subClassCode);
- POFFSET(classCode);
- POFFSET(cacheLineSize);
- POFFSET(latencyTimer);
- POFFSET(headerType);
- POFFSET(bist);
- POFFSET(pci0.baseAddr0);
- POFFSET(pci0.baseAddr1);
- POFFSET(pci0.baseAddr2);
- POFFSET(pci0.baseAddr3);
- POFFSET(pci0.baseAddr4);
- POFFSET(pci0.baseAddr5);
- POFFSET(pci0.cardbusCIS);
- POFFSET(pci0.subsystemVendorID);
- POFFSET(pci0.expansionROM);
- POFFSET(pci0.reserved0);
- POFFSET(pci0.reserved1);
- POFFSET(pci0.interruptLine);
- POFFSET(pci0.interruptPin);
- POFFSET(pci0.minimumGrant);
- POFFSET(pci0.minimumLatency);
-
- return 0;
-}
diff --git a/src/unittest/paramtest.cc b/src/unittest/paramtest.cc
deleted file mode 100644
index e513ab981..000000000
--- a/src/unittest/paramtest.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2002-2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
- */
-
-//
-// This file is not part of the regular simulator. It is solely for
-// testing the parameter code. Edit the Makefile to add param_test.cc
-// to the sources list, then use configs/test.ini as the configuration
-// file.
-//
-#include "sim/sim_object.hh"
-#include "mem/cache/cache.hh"
-
-class ParamTest : public SimObject
-{
- public:
- ParamTest(string name)
- : SimObject(name)
- {
- }
-
- virtual ~ParamTest() {}
-};
-
-enum Enum1Type { Enum0 };
-enum Enum2Type { Enum10 };
-
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(ParamTest)
-
- Param<int> intparam;
- VectorParam<int> vecint;
- Param<string> stringparam;
- VectorParam<string> vecstring;
- Param<bool> boolparam;
- VectorParam<bool> vecbool;
- SimObjectParam<BaseMemory *> memobj;
- SimObjectVectorParam<BaseMemory *> vecmemobj;
- SimpleEnumParam<Enum1Type> enum1;
- MappedEnumParam<Enum2Type> enum2;
- SimpleEnumVectorParam<Enum1Type> vecenum1;
- MappedEnumVectorParam<Enum2Type> vecenum2;
-
-END_DECLARE_SIM_OBJECT_PARAMS(ParamTest)
-
-const char *enum1_strings[] =
-{
- "zero", "one", "two", "three"
-};
-
-const EnumParamMap enum2_map[] =
-{
- { "ten", 10 },
- { "twenty", 20 },
- { "thirty", 30 },
- { "forty", 40 }
-};
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(ParamTest)
-
- INIT_PARAM(intparam, "intparam"),
- INIT_PARAM(vecint, "vecint"),
- INIT_PARAM(stringparam, "stringparam"),
- INIT_PARAM(vecstring, "vecstring"),
- INIT_PARAM(boolparam, "boolparam"),
- INIT_PARAM(vecbool, "vecbool"),
- INIT_PARAM(memobj, "memobj"),
- INIT_PARAM(vecmemobj, "vecmemobj"),
- INIT_ENUM_PARAM(enum1, "enum1", enum1_strings),
- INIT_ENUM_PARAM(enum2, "enum2", enum2_map),
- INIT_ENUM_PARAM(vecenum1, "vecenum1", enum1_strings),
- INIT_ENUM_PARAM(vecenum2, "vecenum2", enum2_map)
-
-END_INIT_SIM_OBJECT_PARAMS(ParamTest)
-
-
-CREATE_SIM_OBJECT(ParamTest)
-{
- return new ParamTest(getInstanceName());
-}
-
-REGISTER_SIM_OBJECT("ParamTest", ParamTest)
diff --git a/src/unittest/rangemaptest.cc b/src/unittest/rangemaptest.cc
index 983a41520..36223ed9c 100644
--- a/src/unittest/rangemaptest.cc
+++ b/src/unittest/rangemaptest.cc
@@ -35,7 +35,8 @@
using namespace std;
-int main()
+int
+main()
{
range_map<Addr,int> r;
diff --git a/src/unittest/rangemaptest2.cc b/src/unittest/rangemultimaptest.cc
index b253dbe86..a110256c9 100644
--- a/src/unittest/rangemaptest2.cc
+++ b/src/unittest/rangemultimaptest.cc
@@ -28,20 +28,22 @@
* Authors: Ali Saidi
*/
-#include <iostream>
#include <cassert>
+#include <iostream>
+
#include "sim/host.hh"
#include "base/range_map.hh"
using namespace std;
-int main()
+int
+main()
{
- range_multimap<Addr,int> r;
+ typedef range_multimap<Addr, int> multimap_t;
- range_multimap<Addr,int>::iterator i;
- std::pair<range_multimap<Addr,int>::iterator,range_multimap<Addr,int>::iterator>
- jk;
+ multimap_t r;
+ multimap_t::iterator i;
+ std::pair<multimap_t::iterator, multimap_t::iterator> jk;
i = r.insert(RangeIn<Addr>(10,40),5);
assert(i != r.end());
diff --git a/src/unittest/rangetest.cc b/src/unittest/rangetest.cc
index b7a68ab44..eab2f39a8 100644
--- a/src/unittest/rangetest.cc
+++ b/src/unittest/rangetest.cc
@@ -38,39 +38,40 @@ using namespace std;
int
main()
{
- Range<int> r1(make_pair(9, 28));
- Range<unsigned> r2("0x1000:+0x100");
+ Range<int> r1(make_pair(9, 28));
+ Range<unsigned> r2("0x1000:+0x100");
- cout << r1 << "\n"
- << r2 << "\n";
+ cout << r1 << "\n"
+ << r2 << "\n";
-#define RANGETEST(X, C, Y) \
- cout << X << " "#C" " << Y << " => " << ((X C Y) ? "true" : "false") << "\n"
+#define RANGETEST(X, C, Y) \
+ cout << X << " "#C" " << Y << " => " << \
+ ((X C Y) ? "true" : "false") << "\n"
#define TESTEM(X, Y) do { \
- RANGETEST(X, < , Y); \
- RANGETEST(X, <=, Y); \
- RANGETEST(X, > , Y); \
- RANGETEST(X, >=, Y); \
- RANGETEST(X, ==, Y); \
- RANGETEST(X, !=, Y); \
- RANGETEST(Y, < , X); \
- RANGETEST(Y, <=, X); \
- RANGETEST(Y, > , X); \
- RANGETEST(Y, >=, X); \
- RANGETEST(Y, ==, X); \
- RANGETEST(Y, !=, X); \
-} while (0)
+ RANGETEST(X, < , Y); \
+ RANGETEST(X, <=, Y); \
+ RANGETEST(X, > , Y); \
+ RANGETEST(X, >=, Y); \
+ RANGETEST(X, ==, Y); \
+ RANGETEST(X, !=, Y); \
+ RANGETEST(Y, < , X); \
+ RANGETEST(Y, <=, X); \
+ RANGETEST(Y, > , X); \
+ RANGETEST(Y, >=, X); \
+ RANGETEST(Y, ==, X); \
+ RANGETEST(Y, !=, X); \
+ } while (0)
- TESTEM(8, r1);
- TESTEM(9, r1);
- TESTEM(27, r1);
- TESTEM(28, r1);
+ TESTEM(8, r1);
+ TESTEM(9, r1);
+ TESTEM(27, r1);
+ TESTEM(28, r1);
- TESTEM(0x0fff, r2);
- TESTEM(0x1000, r2);
- TESTEM(0x10ff, r2);
- TESTEM(0x1100, r2);
+ TESTEM(0x0fff, r2);
+ TESTEM(0x1000, r2);
+ TESTEM(0x10ff, r2);
+ TESTEM(0x1100, r2);
- return 0;
+ return 0;
}
diff --git a/src/unittest/sized_test.cc b/src/unittest/sized_test.cc
deleted file mode 100644
index f1bf7528f..000000000
--- a/src/unittest/sized_test.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2002-2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Dave Greene
- * Nathan Binkert
- */
-
-#include <iostream>
-#include <algorithm>
-
-#include "sized.hh"
-#include <queue>
-#include <typeinfo>
-
-template<typename C>
-void print(C &cont)
-{
- std::cout << std::endl;
- std::cout << "Printing " << typeid(cont).name() << std::endl;
- while (!cont.empty()) {
- std::cout << cont.front() << " ";
- cont.pop();
- }
- std::cout << std::endl;
-}
-
-int main(void)
-{
- sized<std::queue<int>, sized_error_policy<std::queue<int> > >
- error_queue(10);
- sized<std::queue<int>, sized_drop_policy<std::queue<int> > >
- drop_queue(5);
-
- for (int i = 0; i < 10; ++i) {
- error_queue.push(i);
- }
-
- for (int i = 0; i < 3; ++i) {
- drop_queue.push(i);
- }
-
- print(error_queue);
- print(drop_queue);
-
- return(0);
-}
diff --git a/src/unittest/strnumtest.cc b/src/unittest/strnumtest.cc
index ea28e35df..0e234884d 100644
--- a/src/unittest/strnumtest.cc
+++ b/src/unittest/strnumtest.cc
@@ -28,8 +28,7 @@
* Authors: Nathan Binkert
*/
-#include <iostream.h>
-
+#include <iostream>
#include <string>
#include <vector>
@@ -40,39 +39,39 @@ using namespace std;
int
main(int argc, char *argv[])
{
- if (argc != 2) {
- cout << "Usage: " << argv[0] << " <number>\n";
- exit(1);
- }
+ if (argc != 2) {
+ cout << "Usage: " << argv[0] << " <number>\n";
+ exit(1);
+ }
- string s = argv[1];
+ string s = argv[1];
#define OUTVAL(valtype, type) do { \
- valtype value; \
- cout << "TYPE = " #valtype "\n"; \
- if (to_number(s, value)) { \
- cout << "Number(" << s << ") = " << dec \
- << (unsigned long long)(unsigned type)value << "\n" \
- << "Number(" << s << ") = " << dec \
- << (signed long long)(signed type)value << "\n" \
- << "Number(" << s << ") = 0x" << hex \
- << (unsigned long long)(unsigned type)value << "\n" \
- << "Number(" << s << ") = 0" << oct \
- << (unsigned long long)(unsigned type)value << "\n\n"; \
- } else \
- cout << "Number(" << s << ") is invalid\n\n"; \
- } while (0)
+ valtype value; \
+ cout << "TYPE = " #valtype "\n"; \
+ if (to_number(s, value)) { \
+ cout << "Number(" << s << ") = " << dec \
+ << (unsigned long long)(unsigned type)value << "\n" \
+ << "Number(" << s << ") = " << dec \
+ << (signed long long)(signed type)value << "\n" \
+ << "Number(" << s << ") = 0x" << hex \
+ << (unsigned long long)(unsigned type)value << "\n" \
+ << "Number(" << s << ") = 0" << oct \
+ << (unsigned long long)(unsigned type)value << "\n\n"; \
+ } else \
+ cout << "Number(" << s << ") is invalid\n\n"; \
+ } while (0)
- OUTVAL(signed long long, long long);
- OUTVAL(unsigned long long, long long);
- OUTVAL(signed long, long);
- OUTVAL(unsigned long, long);
- OUTVAL(signed int, int);
- OUTVAL(unsigned int, int);
- OUTVAL(signed short, short);
- OUTVAL(unsigned short, short);
- OUTVAL(signed char, char);
- OUTVAL(unsigned char, char);
+ OUTVAL(signed long long, long long);
+ OUTVAL(unsigned long long, long long);
+ OUTVAL(signed long, long);
+ OUTVAL(unsigned long, long);
+ OUTVAL(signed int, int);
+ OUTVAL(unsigned int, int);
+ OUTVAL(signed short, short);
+ OUTVAL(unsigned short, short);
+ OUTVAL(signed char, char);
+ OUTVAL(unsigned char, char);
- return 0;
+ return 0;
}
diff --git a/src/unittest/tracetest.cc b/src/unittest/tracetest.cc
deleted file mode 100644
index b1343aac3..000000000
--- a/src/unittest/tracetest.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2003-2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
- */
-
-#include "sim/host.hh"
-#include "base/trace.hh"
-
-using namespace std;
-
-Tick curTick = 0;
-
-struct foo
-{
- foo()
- {
- char foo[9] = "testing";
- DPRINTF(Loader, "%s\n", foo);
- }
-};
-
-int
-main()
-{
- Trace::flags[Trace::Loader] = true;
- Trace::dprintf_stream = &cout;
-
- foo f;
-
- return 0;
-}