changeset 432:db4b6169a99d

1) implemented checkRuntimeErrorMessage 2) fixed norun test cases
author thomask
date Fri, 15 Apr 2005 08:55:00 +0000
parents 61ec77e09b1e
children b310cc8b0391
files dstress.c norun/auto_05.d norun/main_05.d norun/throw_04.d norun/throw_05.d todo.txt
diffstat 6 files changed, 131 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/dstress.c	Fri Apr 15 01:59:35 2005 +0000
+++ b/dstress.c	Fri Apr 15 08:55:00 2005 +0000
@@ -24,6 +24,8 @@
  *
  */                                             
 
+// Beware: the code doesn't care about freeing allocated memory
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -166,7 +168,7 @@
 	if(back == NULL){
 		back = getenv("dflags");
 		if(back==NULL){
-			back = "";
+			 back = calloc(1,1);
 		}
 	}
 	return back;
@@ -267,8 +269,7 @@
 		strcat(gdc, line);
 		strcat(gdc, ": ");
 	}else{
-		dmd=NULL;
-		gdc=NULL;
+		return 1;
 	}
 
 	/* fix filenames */
@@ -300,12 +301,126 @@
 		back=1;
 	}
 
-	/* @todo@ check format of all other messages */
 	return back;
 }
 
-int checkRuntimeErrorMessage(const char* file, const char* line, const char* buffer){
-	/* @todo@ */
+int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){
+	// Phobos(dmd & gdc): dir/file.d(2)
+
+	char* file;
+	char* line;
+	char* phobos;
+	char* phobosLong;
+
+	char* begin;
+	char* end1;
+	char* end2;
+
+	int back=0;
+
+	/* clean arguments */
+	if(strcmp(file_, "")!=0){
+		file = malloc(strlen(file_)+1);
+		strcpy(file, file_);
+	}else{
+		file=NULL;
+	}
+	
+	if(strcmp(line_, "")!=0){
+		line = malloc(strlen(line_)+1);
+		strcpy(line, line_);
+	}else{
+		line=NULL;
+	}
+	
+	/* gen patterns*/
+	if(file!=NULL){
+		if(line!=NULL){
+			phobos = malloc(strlen(file)+strlen(line)+5);
+			phobos[0]='\x00';
+			if(begin=rindex(file,'/')){
+				begin++;
+			}else if(begin=rindex(file,'\\')){
+				begin++;
+			}else{
+				begin=file;
+			}
+			end1=rindex(file,'.');
+			strncat(phobos, begin, end1-begin);
+			strcat(phobos, "(");
+			strcat(phobos, line);
+			strcat(phobos, ")");
+
+			phobosLong = malloc(strlen(file)+strlen(line)+5);
+			phobosLong[0]='\x00';
+			strcat(phobosLong, file);
+			strcat(phobosLong, "(");
+			strcat(phobosLong, line);
+			strcat(phobosLong, ")");
+
+		}else{
+			phobos = malloc(strlen(file)+2);
+			phobos[0]='\x00';
+			if(begin=rindex(file,'/')){
+				begin++;
+			}else if(begin=rindex(file,'\\')){
+				begin++;
+			}else{
+				begin=file;
+			}
+			end1=rindex(file,'.');
+			strncat(phobos, begin, end1-begin);
+			strcat(phobos, "(");
+
+			phobosLong = malloc(strlen(file)+2);
+			phobosLong[0]='\x00';
+			strcat(phobosLong, file);
+			strcat(phobosLong, "(");
+		}
+	}else if(line!=NULL){
+		phobos = malloc(strlen(line)+3);
+		phobos[0]='\x00';
+		strcat(phobos, "(");
+		strcat(phobos, line);
+		strcat(phobos, ")");
+		
+		phobosLong=NULL;
+	}else{
+		return 1;
+	}
+
+	/* fix filenames */
+#ifdef WIN32
+	end1="/";
+	end2="\\";
+#else
+	end1="\\";
+	end2="/";
+#endif
+
+	if(phobos){
+		while( (begin=strchr(phobos, end1[0])) ){
+			begin[0]=end2[0];
+		}
+	}
+
+	if(phobosLong){
+		while( (begin=strchr(phobosLong, end1[0])) ){
+			begin[0]=end2[0];
+		}
+		while(phobosLong[0]==end2[0]){
+			phobosLong++;
+		}
+	}
+	/* specific error messages */
+		
+	if( (phobos && strstr(buffer, phobos))
+		|| (phobosLong && strstr(buffer, phobosLong)))
+	{
+		back=1;
+	}
+ 
+	return back;	
 	return 1;
 }
 
@@ -524,6 +639,7 @@
 		fprintf(stderr, "--------\n");
 	}else{
 		printf("@bug@ %d (%s)\n", modus, arg[2]);
+		return -1;
 	}
 	return 0;
 }
--- a/norun/auto_05.d	Fri Apr 15 01:59:35 2005 +0000
+++ b/norun/auto_05.d	Fri Apr 15 08:55:00 2005 +0000
@@ -6,7 +6,7 @@
 // @date@	2005-03-25
 // @uri@	news:d2175a$2u8h$1@digitaldaemon.com
 
-// __DSTRESS_ELINE__ 27
+// __DSTRESS_ELINE__ 23
 
 module dstress.norun.auto_05;
 
@@ -20,11 +20,11 @@
 
 void autotest(){
 	auto AutoClass c = new AutoClass();
- 	b = c;   // this should be forbidden?
+ 	b = c;   // this should be forbidden
 }
 
 int main(){
 	autotest();
  	b.test();   // "access violation"
- 	return 1;
-}
\ No newline at end of file
+ 	return 0;
+}
--- a/norun/main_05.d	Fri Apr 15 01:59:35 2005 +0000
+++ b/norun/main_05.d	Fri Apr 15 08:55:00 2005 +0000
@@ -2,7 +2,7 @@
 // $Date$
 // $Author$
 
-// __DSTRESS_ELINE__ 9
+// __DSTRESS_ELINE__ 10
 
 module dstress.norun.main_05;
 
--- a/norun/throw_04.d	Fri Apr 15 01:59:35 2005 +0000
+++ b/norun/throw_04.d	Fri Apr 15 08:55:00 2005 +0000
@@ -2,8 +2,6 @@
 // $Date$
 // $Author$
 
-// __DSTRESS_ELINE__
-
 module dstress.norun.throw_04;
 
 static ~this(){
@@ -12,4 +10,4 @@
 
 int main(){
 	return 0;
-}
\ No newline at end of file
+}
--- a/norun/throw_05.d	Fri Apr 15 01:59:35 2005 +0000
+++ b/norun/throw_05.d	Fri Apr 15 08:55:00 2005 +0000
@@ -2,14 +2,12 @@
 // $Date$
 // $Author$
 
-// __DSTRESS_ELINE__
+module dstress.norun.throw_05;
 
-module dstress.norun.throw_04;
-
-static ~this(){
+static this(){
 	throw new Exception("Message\n");
 }
 
 int main(){
 	return 0;
-}
\ No newline at end of file
+}
--- a/todo.txt	Fri Apr 15 01:59:35 2005 +0000
+++ b/todo.txt	Fri Apr 15 08:55:00 2005 +0000
@@ -6,7 +6,6 @@
 * update/check the Windows bat generator (./beta)
 
 dstress.c:
-* check messages: compile->generic, runtime->spezific&generic
 * MSWindows: implement crashRun (stop pop-up for segfaulting test cases / createProcess)
 
 Benchmark: