From 424c2c771c578d06da66df4a1bd86fe162ff295b Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Thu, 6 Aug 2015 16:00:10 +0200 Subject: [PATCH] Simple test system started. To test it just run the following: cd tests perl start.pl Then wait until you hopefully see the result of the first test! --- DRAMSys/tests/simple/expected.txt | 9 +++ DRAMSys/tests/simple/test.pl | 56 +++++++++++++++++ DRAMSys/tests/start.pl | 100 ++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 DRAMSys/tests/simple/expected.txt create mode 100644 DRAMSys/tests/simple/test.pl create mode 100644 DRAMSys/tests/start.pl diff --git a/DRAMSys/tests/simple/expected.txt b/DRAMSys/tests/simple/expected.txt new file mode 100644 index 00000000..56b5e7d9 --- /dev/null +++ b/DRAMSys/tests/simple/expected.txt @@ -0,0 +1,9 @@ +Info: /OSCI/SystemC: Simulation stopped by user. +sim.dram0 Total Energy: 4322095.399584 +sim.dram0 Average Power: 12.680122 +sim.dram1 Total Energy: 2157481.552032 +sim.dram1 Average Power: 6.404758 +sim.dram2 Total Energy: 3293520.001632 +sim.dram2 Average Power: 9.667110 +sim.dram3 Total Energy: 2216673.062784 +sim.dram3 Average Power: 6.580476A diff --git a/DRAMSys/tests/simple/test.pl b/DRAMSys/tests/simple/test.pl new file mode 100644 index 00000000..e91fb713 --- /dev/null +++ b/DRAMSys/tests/simple/test.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl -w +# Copyright (c) 2015, University of Kaiserslautern +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. 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. +# +# 3. Neither the name of the copyright holder 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 HOLDER +# 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: +# Matthias Jung +# + +# Test Simple: +# This test runs the simulation with standard configuration + +use File::Compare; + +# Run Simulation: +chdir("../../../build/simulator/"); +`./dramSys > ../../DRAMSys/tests/simple/output.txt`; + +chdir("../../DRAMSys/tests/simple"); + +`cat output.txt | tail -n 9 > current.txt`; + +if(compare("current.txt","expected.txt") == 0) +{ + exit 0 +} +else +{ + exit -1 +} diff --git a/DRAMSys/tests/start.pl b/DRAMSys/tests/start.pl new file mode 100644 index 00000000..d7f41e88 --- /dev/null +++ b/DRAMSys/tests/start.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w +# Copyright (c) 2015, University of Kaiserslautern +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. 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. +# +# 3. Neither the name of the copyright holder 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 HOLDER +# 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: +# Matthias Jung +# + +use warnings; +use strict; +use Term::ANSIColor; + +print color("red")," |||\n"; +print color("red")," +---+ Microelectronic Systems\n"; +print color("red"),"=| |= Design Research Group\n"; +print color("red"),"=| |= ", color("blue"),"University of Kaiserslautern\n"; +print color("red")," +---+\n"; +print color("red")," ||| ", color("green"),"DRAMSys Automated Test System\n", color("reset"); + +# Get number of Cores: +my $numberOfCores = `cat /proc/cpuinfo | grep processor | wc -l`; + +# Navigate to Build Folder +chdir("../../"); +`mkdir build >/dev/null 2>&1`; +chdir("build/"); + +# Build the Project: +print color("reset"),"\nBuild Project\t"; +`qmake ../DRAMSys/dram.vp.system.pro >/dev/null 2>&1`; +`make -j$numberOfCores >/dev/null 2>&1`; + +# Check if Build was sucessful: +if( -e "./simulator/dramSys" ) +{ + print color("reset"),"[ ", color("green"), "done", color("reset"), " ]\n"; +} +else +{ + print color("reset"),"[ ", color("red"), "fail", color("reset"), " ]\n"; + exit -1; +} + +# Find all tests: +# Navigate to Build Folder +chdir("../DRAMSys/tests"); +my @tests = split(/\n/,`find -iname test.pl`); + +# Run Tests: +foreach(@tests) +{ + if($_ =~ /\.\/([\w\d]+)\/test\.pl/) + { + my $name = $1; + chdir("./$name"); + print color("reset"),"Test: ".$name."\t"; + `perl test.pl`; + + if( $? == 0 ) + { + print color("reset"),"[ ", color("green"), "done", color("reset"), " ]\n"; + } + else + { + print color("reset"),"[ ", color("red"), "fail", color("reset"), " ]\n"; + } + chdir("../"); + } + else + { + exit -1; + } +}