Add support for running tests that are expected to fail
Also add should-fail tests that exercise const and decl initializers
This commit is contained in:
1
ispc.cpp
1
ispc.cpp
@@ -332,6 +332,7 @@ Globals::Globals() {
|
|||||||
runCPP = true;
|
runCPP = true;
|
||||||
debugPrint = false;
|
debugPrint = false;
|
||||||
disableWarnings = false;
|
disableWarnings = false;
|
||||||
|
disableLineWrap = false;
|
||||||
emitPerfWarnings = true;
|
emitPerfWarnings = true;
|
||||||
emitInstrumentation = false;
|
emitInstrumentation = false;
|
||||||
generateDebuggingSymbols = false;
|
generateDebuggingSymbols = false;
|
||||||
|
|||||||
4
ispc.h
4
ispc.h
@@ -337,6 +337,10 @@ struct Globals {
|
|||||||
/** Indicates whether all warning messages should be surpressed. */
|
/** Indicates whether all warning messages should be surpressed. */
|
||||||
bool disableWarnings;
|
bool disableWarnings;
|
||||||
|
|
||||||
|
/** Indicates whether line wrapping of error messages to the terminal
|
||||||
|
width should be disabled. */
|
||||||
|
bool disableLineWrap;
|
||||||
|
|
||||||
/** Indicates whether additional warnings should be issued about
|
/** Indicates whether additional warnings should be issued about
|
||||||
possible performance pitfalls. */
|
possible performance pitfalls. */
|
||||||
bool emitPerfWarnings;
|
bool emitPerfWarnings;
|
||||||
|
|||||||
2
main.cpp
2
main.cpp
@@ -280,6 +280,8 @@ int main(int Argc, char *Argv[]) {
|
|||||||
g->disableWarnings = true;
|
g->disableWarnings = true;
|
||||||
g->emitPerfWarnings = false;
|
g->emitPerfWarnings = false;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[i], "--nowrap"))
|
||||||
|
g->disableLineWrap = true;
|
||||||
else if (!strcmp(argv[i], "--wno-perf") || !strcmp(argv[i], "-wno-perf"))
|
else if (!strcmp(argv[i], "--wno-perf") || !strcmp(argv[i], "-wno-perf"))
|
||||||
g->emitPerfWarnings = false;
|
g->emitPerfWarnings = false;
|
||||||
else if (!strcmp(argv[i], "-o")) {
|
else if (!strcmp(argv[i], "-o")) {
|
||||||
|
|||||||
28
run_tests.py
28
run_tests.py
@@ -17,6 +17,7 @@ import random
|
|||||||
import string
|
import string
|
||||||
import mutex
|
import mutex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import shlex
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
@@ -102,6 +103,33 @@ def run_tasks_from_queue(queue):
|
|||||||
if (filename == 'STOP'):
|
if (filename == 'STOP'):
|
||||||
sys.exit(error_count)
|
sys.exit(error_count)
|
||||||
|
|
||||||
|
# is this a test to make sure an error is issued?
|
||||||
|
want_error = (filename.find("tests_errors") != -1)
|
||||||
|
if want_error == True:
|
||||||
|
ispc_cmd = "ispc --nowrap --woff %s --arch=%s --target=%s" % \
|
||||||
|
( filename, options.arch, options.target)
|
||||||
|
sp = subprocess.Popen(shlex.split(ispc_cmd), stdin=None, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
output = sp.communicate()[1]
|
||||||
|
got_error = (sp.returncode != 0)
|
||||||
|
|
||||||
|
# figure out the error message we're expecting
|
||||||
|
file = open(filename, 'r')
|
||||||
|
firstline = file.readline()
|
||||||
|
firstline = string.replace(firstline, "//", "")
|
||||||
|
firstline = string.lstrip(firstline)
|
||||||
|
firstline = string.rstrip(firstline)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
if (output.find(firstline) == -1):
|
||||||
|
print "Didn't see expected error message \"%s\" from test %s.\nActual outout: %s" % \
|
||||||
|
(firstline, filename, output)
|
||||||
|
error_count += 1
|
||||||
|
elif got_error == False:
|
||||||
|
print "Unexpectedly no errors issued from test %s" % filename
|
||||||
|
error_count += 1
|
||||||
|
continue
|
||||||
|
|
||||||
# do we expect this test to fail?
|
# do we expect this test to fail?
|
||||||
should_fail = (filename.find("failing_") != -1)
|
should_fail = (filename.find("failing_") != -1)
|
||||||
|
|
||||||
|
|||||||
6
tests_errors/const-1.ispc
Normal file
6
tests_errors/const-1.ispc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Can't pre-increment
|
||||||
|
|
||||||
|
int func() {
|
||||||
|
const int x = 2;
|
||||||
|
++x;
|
||||||
|
}
|
||||||
6
tests_errors/const-2.ispc
Normal file
6
tests_errors/const-2.ispc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Can't assign to type
|
||||||
|
|
||||||
|
int func() {
|
||||||
|
const int x = 2;
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
9
tests_errors/const-3.ispc
Normal file
9
tests_errors/const-3.ispc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// Can't assign to type
|
||||||
|
|
||||||
|
struct Foo {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
|
||||||
|
int func(const Foo f) {
|
||||||
|
f.x = 0;
|
||||||
|
}
|
||||||
9
tests_errors/const-4.ispc
Normal file
9
tests_errors/const-4.ispc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// Can't assign to type
|
||||||
|
|
||||||
|
struct Foo {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
|
||||||
|
int func(const int f) {
|
||||||
|
f -= 2;
|
||||||
|
}
|
||||||
6
tests_errors/const-5.ispc
Normal file
6
tests_errors/const-5.ispc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// Can't assign to type
|
||||||
|
|
||||||
|
int func() {
|
||||||
|
const int a[10] = {1,2,3,4,5,6,7,8,9,10};
|
||||||
|
a[0] = 1;
|
||||||
|
}
|
||||||
5
tests_errors/decl-1.ispc
Normal file
5
tests_errors/decl-1.ispc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// requires 10 values; 11 provided
|
||||||
|
|
||||||
|
int func() {
|
||||||
|
int a[10] = {1,2,3,4,5,6,7,8,9,10,11};
|
||||||
|
}
|
||||||
5
tests_errors/decl-2.ispc
Normal file
5
tests_errors/decl-2.ispc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// requires 12 values; 11 provided
|
||||||
|
|
||||||
|
int func() {
|
||||||
|
int a[12] = {1,2,3,4,5,6,7,8,9,10,11};
|
||||||
|
}
|
||||||
5
tests_errors/decl-3.ispc
Normal file
5
tests_errors/decl-3.ispc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// Expression list initializers can't be used
|
||||||
|
|
||||||
|
int func() {
|
||||||
|
int a = { 1 };
|
||||||
|
}
|
||||||
5
tests_errors/decl-4.ispc
Normal file
5
tests_errors/decl-4.ispc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// Can't declare an unsized array as a local variable without providing an initializer expression to set its size
|
||||||
|
|
||||||
|
int func() {
|
||||||
|
int a[];
|
||||||
|
}
|
||||||
3
util.cpp
3
util.cpp
@@ -69,6 +69,9 @@
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
lTerminalWidth() {
|
lTerminalWidth() {
|
||||||
|
if (g->disableLineWrap)
|
||||||
|
return 1<<30;
|
||||||
|
|
||||||
#if defined(ISPC_IS_WINDOWS)
|
#if defined(ISPC_IS_WINDOWS)
|
||||||
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
if (h == INVALID_HANDLE_VALUE || h == NULL)
|
if (h == INVALID_HANDLE_VALUE || h == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user