Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/27688 )

Change subject: util: Add stub unit tests for the call types in the m5 utility.
......................................................................

util: Add stub unit tests for the call types in the m5 utility.

These will be filled out in later changes. This CL just adds the
plumbing to the build script.

Change-Id: If58ea023d0c85eae0160f88217c83fca70346da2
---
M util/m5/SConstruct
M util/m5/src/SConscript
A util/m5/src/call_type/addr.test.cc
A util/m5/src/call_type/inst.test.cc
A util/m5/src/call_type/semi.test.cc
5 files changed, 124 insertions(+), 7 deletions(-)



diff --git a/util/m5/SConstruct b/util/m5/SConstruct
index cb67b50..da9543e 100644
--- a/util/m5/SConstruct
+++ b/util/m5/SConstruct
@@ -43,8 +43,8 @@
     return os.path.abspath(str(d))

 # Universal settings.
-main.Append(CXXFLAGS=[ '-O2' ])
-main.Append(CCFLAGS=[ '-O2' ])
+main.Append(CXXFLAGS=[ '-O2', '-g' ])
+main.Append(CCFLAGS=[ '-O2', '-g' ])
 main.Append(CPPPATH=[ common_include ])

 # Propogate the environment's PATH setting.
@@ -62,7 +62,7 @@
 main.SetOption('duplicate', 'soft-copy')

 def build_gtest_env(env):
-    gtest_env = env.Clone(OBJSUFFIX='.to')
+    gtest_env = env.Clone(OBJSUFFIX='.to', SHOBJSUFFIX='.sto')
     gtest_env.Append(CPPFLAGS=[ '${GTEST_CPPFLAGS}' ])
     gtest_env.Append(LIBS=[ '${GTEST_LIBS}' ])
     return gtest_env
diff --git a/util/m5/src/SConscript b/util/m5/src/SConscript
index a8a5d8d..9420199 100644
--- a/util/m5/src/SConscript
+++ b/util/m5/src/SConscript
@@ -42,7 +42,9 @@

 all_call_types = list(env['CALL_TYPE'].values())
 call_types = list([ ct for ct in all_call_types if ct.enabled ])
-m5ops = list([ 'variant/${VARIANT}/%s' % ct.impl_file for ct in call_types ])
+m5ops = { ct.name: 'variant/${VARIANT}/%s' % ct.impl_file
+          for ct in call_types }
+all_m5ops = list(m5ops.values())

 default_call_type = list([ ct for ct in call_types if ct.default ])
 assert len(default_call_type) == 1, \
@@ -56,7 +58,7 @@
 #
 # The m5 library for use in other C/C++ programs.
 #
-libm5 = static_env.StaticLibrary('out/m5', [ m5_mmap ] + m5ops)
+libm5 = static_env.StaticLibrary('out/m5', [ m5_mmap ] + all_m5ops)

commands = env.SConscript('command/SConscript', exports={ "env": static_env })

@@ -76,7 +78,20 @@
# The shared version of the m5 op call sights, used by mutliple targets below.
 shared_env = env.Clone()
 shared_env.Append(ASFLAGS='-DM5OP_PIC')
-m5op_shared = shared_env.SharedObject(m5ops)
+m5op_shared = shared_env.SharedObject(all_m5ops)
+
+#
+# Unit tests for enabled call types.
+#
+call_type_shared = shared_env.SharedObject(call_type)
+args_shared = shared_env.SharedObject(args)
+m5_mmap_shared = shared_env.SharedObject(m5_mmap)
+for ct in call_types:
+    ct_env = shared_env.Clone()
+    ct_env.Append(CXXFLAGS=[ '-DCALL_TYPE_IS_DEFAULT=false' ])
+ ct_env.GTest('call_type/%s' % ct.name, 'call_type/%s.test.cc' % ct.name, + 'call_type/%s.cc' % ct.name, call_type_shared, args_shared,
+                 m5_mmap_shared, m5ops[ct.name])

 if env['HAVE_JAVA']:
     #
@@ -106,4 +121,4 @@
     # Extract the include paths needed for lua51 using pkg-config.
     lua_env.ParseConfig('pkg-config --cflags lua51')
     lib = lua_env.SharedLibrary('out/gem5OpLua',
-                                [ lua, m5_mmap ] + m5op_shared)
+                                [ lua, m5_mmap_shared ] + m5op_shared)
diff --git a/util/m5/src/call_type/addr.test.cc b/util/m5/src/call_type/addr.test.cc
new file mode 100644
index 0000000..42b7341
--- /dev/null
+++ b/util/m5/src/call_type/addr.test.cc
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * 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.
+ */
+
+#include <gtest/gtest.h>
+
+#include "call_type.hh"
+
+TEST(AddrCallType, Sum)
+{
+}
diff --git a/util/m5/src/call_type/inst.test.cc b/util/m5/src/call_type/inst.test.cc
new file mode 100644
index 0000000..e4a8520
--- /dev/null
+++ b/util/m5/src/call_type/inst.test.cc
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * 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.
+ */
+
+#include <gtest/gtest.h>
+
+#include "call_type.hh"
+
+TEST(InstCallType, Sum)
+{
+}
diff --git a/util/m5/src/call_type/semi.test.cc b/util/m5/src/call_type/semi.test.cc
new file mode 100644
index 0000000..10f3d0e
--- /dev/null
+++ b/util/m5/src/call_type/semi.test.cc
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * 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.
+ */
+
+#include <gtest/gtest.h>
+
+#include "call_type.hh"
+
+TEST(SemiCallType, Sum)
+{
+}

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/27688
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: If58ea023d0c85eae0160f88217c83fca70346da2
Gerrit-Change-Number: 27688
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to