Browse Source

Quality: added active cells tester (basic functionality)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6893 8c9fc860-2736-0410-a75d-ab315db34111
felixf 9 years ago
parent
commit
19228d6043
3 changed files with 169 additions and 14 deletions
  1. 133 0
      source/ActiveCells.Execution.Test
  2. 19 6
      source/ActiveCellsRuntime.mod
  3. 17 8
      source/Fox.Tool

+ 133 - 0
source/ActiveCells.Execution.Test

@@ -0,0 +1,133 @@
+# Oberon language test and validation suite
+# options 	--mayTrap --prolog="Compiler.Compile -p=Win32G --cellsAreObjects TesterInput.txt" --command="SystemTools.Free Test Tester;ActiveCellsRunner.Execute Test.Cellnet" --logFile="ActiveCells.ExecutionTest.Log" --result="ActiveCells.Execution.Test.Diff"
+
+# test halt and assert statements and simple procedure call (basics for the test suite)
+
+positive: tester module
+
+	MODULE Tester; 
+
+	IMPORT Kernel;
+	TYPE Tester* = OBJECT
+		VAR 
+			set: SET;
+			timeout: Kernel.Timer;
+		
+			PROCEDURE Await*(s: SET): BOOLEAN;
+			BEGIN{EXCLUSIVE}
+				AWAIT(s <= set) OR (31 IN set);
+				RETURN ~(31 IN set);
+			END Await;
+			
+			PROCEDURE Done*(i: LONGINT);
+			BEGIN{EXCLUSIVE}
+				INCL(set, i);
+			END Done;
+			
+			PROCEDURE Error;
+			BEGIN{EXCLUSIVE}
+				IF ~(31 IN set) THEN
+					INCL(set, 31); 
+					timeout.Wakeup;
+				END;
+			END Error;
+			
+			PROCEDURE Assert*(b: BOOLEAN);
+			BEGIN
+				IF ~b THEN Error END;
+			END Assert;
+			
+		BEGIN{ACTIVE}
+			NEW(timeout);
+			timeout.Sleep(500);
+			Error;
+		END Tester;
+		
+	END Tester.
+
+	MODULE Test;
+	TYPE
+		Cellnet = CELLNET
+		BEGIN
+		END Cellnet;
+		
+	END Test.
+
+negative: simple communication with error
+
+	MODULE Test;
+
+	IMPORT Tester;
+		
+	VAR tester: Tester.Tester; 
+
+	TYPE
+		Out = CELL (out: PORT OUT);
+		VAR data: LONGINT;
+		BEGIN
+			data := 122;
+			out << data;
+			tester.Done(1);
+		END Out;
+
+		In = CELL(in: PORT IN);
+		VAR data: LONGINT;
+		BEGIN
+			data << in;
+			tester.Assert(data = 123);
+			tester.Done(0);
+		END In;
+
+
+		Cellnet = CELLNET
+		VAR in: In; out: Out;
+		BEGIN
+			NEW(tester); 
+			NEW(in);
+			NEW(out);
+			CONNECT(out.out, in.in);
+			ASSERT(tester.Await({0,1}));
+			TRACE("done");
+		END Cellnet;
+		
+	END Test.
+
+positive: simple communication without error
+
+	MODULE Test;
+
+	IMPORT Tester;
+		
+	VAR tester: Tester.Tester; 
+
+	TYPE
+		Out = CELL (out: PORT OUT);
+		VAR data: LONGINT;
+		BEGIN
+			data := 123;
+			out << data;
+			tester.Done(1);
+		END Out;
+
+		In = CELL(in: PORT IN);
+		VAR data: LONGINT;
+		BEGIN
+			data << in;
+			tester.Assert(data = 123);
+			tester.Done(0);
+		END In;
+
+
+		Cellnet = CELLNET
+		VAR in: In; out: Out;
+		BEGIN
+			NEW(tester); 
+			NEW(in);
+			NEW(out);
+			CONNECT(out.out, in.in);
+			ASSERT(tester.Await({0,1}));
+			TRACE("done");
+		END Cellnet;
+		
+	END Test.
+

+ 19 - 6
source/ActiveCellsRuntime.mod

@@ -90,6 +90,7 @@ type
 		proc: procedure {DELEGATE};
 		context: Context;
 		finished: boolean;
+		error-: boolean;
 		
 		procedure & Init*(context: Context);
 		begin
@@ -99,15 +100,26 @@ type
 		end Init;
 		
 		procedure Start*(p: procedure{DELEGATE}; doWait: boolean);
-		begin{EXCLUSIVE}
-			proc := p;
-			await(~doWait or finished);
+			begin{EXCLUSIVE}
+				proc := p;
+				await(~doWait or finished);
 		end Start;
 		
-	begin{ACTIVE,EXCLUSIVE}
-		await(proc # nil);
+	begin{ACTIVE}
+		begin{EXCLUSIVE}
+			await(proc # nil);
+		end;
 		proc;
-		finished := true;
+		begin{EXCLUSIVE}
+			finished := true
+		end;
+		finally
+		begin{EXCLUSIVE}
+			if ~finished then
+				error := true;
+				finished := true;
+			end;
+		end;
 	end Launcher;
 	
 	procedure GetContext(): Context;
@@ -437,6 +449,7 @@ type
 			end;
 			new(launcher, context); 
 			launcher.Start(starter.P, true);
+			assert(~launcher.error);
 		else 
 			Reflection.Report(Commands.GetContext().out, m.refs, offset);
 		end;

+ 17 - 8
source/Fox.Tool

@@ -1,10 +1,8 @@
 Fox - Flexible Oberon Cross Compiler
 Build and Test Tool
-(c) Felix Friedrich (fof), ETH Zürich, 2008-2015
+(c) Felix Friedrich (fof), ETH Zürich, 2008-2016
 Conceptual design of the compiler has been worked out together with Florian Negele.
 
-compile the compiler
-
 
 Compiler.Compile --noInterfaceCheck
 (* 
@@ -46,23 +44,24 @@ SystemTools.Timer elapsed ~ SystemTools.Ln ~
 ~
 
 compiler options:
-	-p 	--print			flag		printout source code (for debugging)
+	 	--print			flag		printout source code (for debugging)
 		--silent			flag		do not printout success messages
 	-c	--check			flag		semantically check module (auto-check if backend is installed)
 	-e	--traceError	flag		report a stack traceback for each error (for debugging)
 	-I	--interface		flag		printout interface (for debugging)
-	-i	--info			flag		report more detailed information in error messages and in printout (for debugging)
+	-i	--info				flag		report more detailed information in error messages and in printout (for debugging)
 	-b	--backend		string	specification of backend (such as, for example, -b=AMD or -b=Intermediate)
-	-f	--findPC		integer	specification of a pc to be located in code
+	-f	--findPC			integer	specification of a pc to be located in code
 		--symbolFile	string	specification of a symbol file format (example: --symbolFile=Binary)
 		--objectFile		string	specification of an object file format(example: --objectFile=Binary)
 		--activeCells	flag		use active cells language extension
 	-w	--warnings		flag		show warnings
 		--darwinHost	flag		use Darwin (MacOSX) calling convention for ext. C procedures
-		--hardware		string	hardware generation hint for ActiveCells
+		--hardware	string	hardware generation hint for ActiveCells
 	-d	--documentation	string	install documentation engine
 	-S	--sourcePath	string	specification of a source path
-	-D 	--destPath		string	specification of a destination path
+	-D --destPath		string	specification of a destination path
+	-p 	--platform		string	compiler options for platforms such as ARMA2, Win32G, defined in FoxCompiler.Mod
 
 backend options (intermediate and AMD)
 		--trace			string	display trace information for sections (--trace=* : all sections)
@@ -90,19 +89,29 @@ AMD backend options
 		--traceable				flag			include instructions in procedure call in order to make a trace possible -- for debugging only
 		--useFPU				flag			use FPU for floating point computations (in contrast to SSE and SSE2)
 		
+ARM backend options
+		--useFPU32				flag			use FPU (32 bit) for floating point computations
+		--useFPU64				flag			use FPU (64 bit and 32 bit) for floating point computations
 
+ActiveCells options
+		--cellsAreObjects	flag	Cells are compiled to (active) Objects. For simulation/emulation and for code generation.
 
 
 
 run regression tests
 
+SystemTools.DoCommands
 	FoxTest.Compile	 -l=Test.Log  Oberon.Compilation.Test Oberon.Compilation.AMD64TestDiff ~
 	FoxTest.Compile	-l=Test.Log Oberon.Execution.Test Oberon.Execution.AMD64TestDiff ~
+	FoxTest.Compile	-l=Test.Log ActiveCells.Execution.Test ActiveCells.Execution.TestDiff ~
 
+~
 
 open regression test files
 PET.Open Oberon.Compilation.Test ~
 PET.Open Oberon.Execution.Test ~
+
+
 PET.Open MathArrays.Compilation.Test ~
 PET.Open MathArrays.Execution.Test ~