diff options
Diffstat (limited to 'tests')
94 files changed, 9716 insertions, 551 deletions
diff --git a/tests/browser_harness.html b/tests/browser_harness.html new file mode 100644 index 00000000..86f3749f --- /dev/null +++ b/tests/browser_harness.html @@ -0,0 +1,29 @@ +<html> +<head> + <title>Emscripten Browser Test Harness</title> +</head> +<body> +<h2><b>Running tests...</b></h2> +<div id="output"></div> +<script> + var counter = 0; + function check() { + var request = new XMLHttpRequest(); + request.open('GET', '/check', false); + try { + request.send(null); + if (request.responseText != 'False') { + window.open(request.responseText); + document.getElementById('output').innerHTML += 'opened test window ' + (counter++) + '..<br>'; + } + setTimeout(check, 333); + } catch(e) { + document.write('Tests complete. View log in console.'); + return; + } + } + check(); +</script> +</body> +</html> + diff --git a/tests/cases/aliasbitcastdollar.ll b/tests/cases/aliasbitcastdollar.ll new file mode 100644 index 00000000..1ecf6047 --- /dev/null +++ b/tests/cases/aliasbitcastdollar.ll @@ -0,0 +1,27 @@ +; ModuleID = '/tmp/emscripten/tmp/src.cpp.o' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" +target triple = "i386-pc-linux-gnu" + +@.str = private constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1] + +@"other$name" = alias bitcast (void ()* @original to void (i32)*) ; [#uses=1] + +; [#uses=2] +define void @original() { +entry: + %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] + br label %return + +return: ; preds = %entry + ret void +} + +; [#uses=1] +declare i32 @puts(i8*) + +; [#uses=0] +define i32 @main() { +entry: + call void @"other$name"(i32 5) + ret i32 0 +} diff --git a/tests/cases/complexphi.ll b/tests/cases/complexphi.ll index 6f64af06..fcb7185f 100644 --- a/tests/cases/complexphi.ll +++ b/tests/cases/complexphi.ll @@ -3,6 +3,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3 target triple = "i386-pc-linux-gnu" @.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] +@_dispatchTable = internal global i64 0 ; [#uses=0] define i32 @main() { @@ -19,6 +20,9 @@ cond.null: cond.end: ; preds = %cond.false, %cond.true %cond = phi { i32, i32 } [ { i32 5, i32 6 }, %entry ], [ zeroinitializer, %cond.null ] ; [#uses=1] store { i32, i32 } %cond, { i32, i32 }* %comp + + store { i32, i32 } { i32 ptrtoint (i64* @_dispatchTable to i32), i32 0 }, { i32, i32 }* getelementptr inbounds ([1 x i64]* @_dispatchTable, i32 0, i32 0, i32 1), align 4 + ret i32 0 ; [debug line = 6:13] } diff --git a/tests/cases/emptystruct.ll b/tests/cases/emptystruct.ll new file mode 100644 index 00000000..d4165fdd --- /dev/null +++ b/tests/cases/emptystruct.ll @@ -0,0 +1,21 @@ +; ModuleID = 'emptystruct.c' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128" +target triple = "i386-pc-linux-gnu" + +%struct.s = type { {}, i32 } + +@.str = private constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1] + +define i32 @main() nounwind { +entry: + %z = alloca %struct.s, align 4 + %0 = bitcast %struct.s* %z to i8* + call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 4, i32 4, i1 false) + %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] + ret i32 0 +} + +declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind + +declare i32 @puts(i8*) + diff --git a/tests/cases/frem.ll b/tests/cases/frem.ll new file mode 100644 index 00000000..442cd04c --- /dev/null +++ b/tests/cases/frem.ll @@ -0,0 +1,13 @@ +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" +target triple = "i386-pc-linux-gnu" + +@.str2 = private constant [6 x i8] c"*%f*\0A\00", align 1 ; [#uses=1] + +declare i32 @printf(i8* noalias, ...) nounwind + +define i32 @main() { +entry: + %c = frem double 2.5, 1.0 + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str2, i32 0, i32 0), double %c) + ret i32 0 +} diff --git a/tests/cases/frem.txt b/tests/cases/frem.txt new file mode 100644 index 00000000..3a7ecb6a --- /dev/null +++ b/tests/cases/frem.txt @@ -0,0 +1 @@ +*0.500000* diff --git a/tests/cases/quotedlabel.ll b/tests/cases/quotedlabel.ll new file mode 100644 index 00000000..d32e380a --- /dev/null +++ b/tests/cases/quotedlabel.ll @@ -0,0 +1,19 @@ +; ModuleID = '/tmp/emscripten/tmp/src.cpp.o' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" +target triple = "i386-pc-linux-gnu" + +@.str = private constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1] + +; [#uses=1] +declare i32 @puts(i8*) + +; [#uses=0] +define i32 @main() { +entry: + br label %"finish$$$" + +"finish$$$": ; preds = %entry + %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] + ret i32 0 +} + diff --git a/tests/cases/uadd_overflow.ll b/tests/cases/uadd_overflow.ll new file mode 100644 index 00000000..a808b9de --- /dev/null +++ b/tests/cases/uadd_overflow.ll @@ -0,0 +1,25 @@ +; ModuleID = 'tests/hello_world.bc' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128" +target triple = "i386-pc-linux-gnu" + +@.str2 = private constant [9 x i8] c"*%d,%d*\0A\00", align 1 ; [#uses=1] + +; [#uses=0] +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + %mul7 = bitcast i32 -259741926 to i32 + %shl10 = shl i32 4014, 16 + %uadd1 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %mul7, i32 %shl10) + %a0 = extractvalue { i32, i1 } %uadd1, 0 + %a1 = extractvalue { i32, i1 } %uadd1, 1 + %a2 = zext i1 %a1 to i32 + call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %a0, i32 %a2) ; [#uses=0] + ret i32 1 +} + +; [#uses=1] +declare i32 @printf(i8*, ...) + +declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone + diff --git a/tests/cases/uadd_overflow.txt b/tests/cases/uadd_overflow.txt new file mode 100644 index 00000000..dcda9240 --- /dev/null +++ b/tests/cases/uadd_overflow.txt @@ -0,0 +1 @@ +*3319578,1* diff --git a/tests/cube2hash/Makefile b/tests/cube2hash/Makefile new file mode 100644 index 00000000..5d0a7a63 --- /dev/null +++ b/tests/cube2hash/Makefile @@ -0,0 +1,14 @@ +all: cube2hash.bc + +cube2hash.bc: cube2crypto.o tiger.o hashstring.o + $(CXX) $^ -o $@ + +hashstring.o: hashstring.cpp + $(CXX) -c $^ -o $@ + +cube2crypto.o: cube2crypto.c cube2crypto.h + $(CC) -c $< -o $@ + +tiger.o: tiger.c tiger.h + $(CC) -c $< -o $@ + diff --git a/tests/cube2hash/cube2crypto.c b/tests/cube2hash/cube2crypto.c new file mode 100644 index 00000000..52613318 --- /dev/null +++ b/tests/cube2hash/cube2crypto.c @@ -0,0 +1,23 @@ +#include <stdlib.h> +#include "util.h" +#include "tiger.h" +#include "cube2crypto.h" + +char *cube2crypto_hashstring(char *string) +{ + char *result = (char *)malloc(49); + union hashval hv; + + tiger_hash((uchar *)string, strlen(string), &hv); + + int i; + for(i = 0; i < sizeof(hv.bytes); i++) + { + uchar c = hv.bytes[i]; + *(result+(i*2)) = "0123456789ABCDEF"[c&0xF]; + *(result+(i*2)+1) = "0123456789ABCDEF"[c>>4]; + } + *(result+(i*2)+2) = '\0'; + + return result; +} diff --git a/tests/cube2hash/cube2crypto.h b/tests/cube2hash/cube2crypto.h new file mode 100644 index 00000000..90bd06a8 --- /dev/null +++ b/tests/cube2hash/cube2crypto.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif + +char *cube2crypto_hashstring(char *string); + +#ifdef __cplusplus +} /* closing brace for extern "C" */ +#endif
\ No newline at end of file diff --git a/tests/cube2hash/hashstring.cpp b/tests/cube2hash/hashstring.cpp new file mode 100644 index 00000000..b08d5d5e --- /dev/null +++ b/tests/cube2hash/hashstring.cpp @@ -0,0 +1,28 @@ +#include "cube2crypto.h" +#include <stdlib.h> +#include <stdio.h> + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +void help() +{ + printf("Usage: hashstring <seed>\n"); +} + +int main(int argc, char **argv) +{ + if(argc != 2 || !argv[1]) + { + help(); + return EXIT_FAILURE; + } + + char *answer = cube2crypto_hashstring(argv[1]); + + printf("hash value: %s\n", answer); + + free(answer); + + return EXIT_SUCCESS; +} diff --git a/tests/cube2hash/readme.txt b/tests/cube2hash/readme.txt new file mode 100644 index 00000000..6eb129c2 --- /dev/null +++ b/tests/cube2hash/readme.txt @@ -0,0 +1,27 @@ +This directory contains zlib code (c) the Cube 2/Sauerbraten project. +http://sauerbraten.org/ + +LICENSE +======= + +Sauerbraten game engine source code, any release. + +Copyright (C) 2001-2009 Wouter van Oortmerssen, Lee Salzman, Mike Dysart, Robert Pointon, and Quinton Reeves + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + + diff --git a/tests/cube2hash/tiger.c b/tests/cube2hash/tiger.c new file mode 100644 index 00000000..f8707248 --- /dev/null +++ b/tests/cube2hash/tiger.c @@ -0,0 +1,175 @@ +///////////////////////// cryptography ///////////////////////////////// + +/* Based off the reference implementation of Tiger, a cryptographically + * secure 192 bit hash function by Ross Anderson and Eli Biham. More info at: + * http://www.cs.technion.ac.il/~biham/Reports/Tiger/ + */ + +#define TIGER_PASSES 3 + +#include "tiger.h" +#include "util.h" + +chunk sboxes[4*256]; + +#define sb1 (sboxes) +#define sb2 (sboxes+256) +#define sb3 (sboxes+256*2) +#define sb4 (sboxes+256*3) + +#define round(a, b, c, x) \ + c ^= x; \ + a -= sb1[((c)>>(0*8))&0xFF] ^ sb2[((c)>>(2*8))&0xFF] ^ \ + sb3[((c)>>(4*8))&0xFF] ^ sb4[((c)>>(6*8))&0xFF] ; \ + b += sb4[((c)>>(1*8))&0xFF] ^ sb3[((c)>>(3*8))&0xFF] ^ \ + sb2[((c)>>(5*8))&0xFF] ^ sb1[((c)>>(7*8))&0xFF] ; \ + b *= mul; + +void tiger_compress(const chunk *str, chunk state[3]) +{ + chunk a, b, c; + chunk aa, bb, cc; + chunk x0, x1, x2, x3, x4, x5, x6, x7; + + a = state[0]; + b = state[1]; + c = state[2]; + + x0=str[0]; x1=str[1]; x2=str[2]; x3=str[3]; + x4=str[4]; x5=str[5]; x6=str[6]; x7=str[7]; + + aa = a; + bb = b; + cc = c; + + int pass; + + for(pass = 0; pass < TIGER_PASSES; pass++) + { + if(pass) + { + x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5ULL; x1 ^= x0; x2 += x1; x3 -= x2 ^ ((~x1)<<19); + x4 ^= x3; x5 += x4; x6 -= x5 ^ ((~x4)>>23); x7 ^= x6; + x0 += x7; x1 -= x0 ^ ((~x7)<<19); x2 ^= x1; x3 += x2; + x4 -= x3 ^ ((~x2)>&g |