aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/alignedunaligned.ll6
-rw-r--r--tests/cases/breakinthemiddle3.ll26
-rw-r--r--tests/cases/callundef.ll18
-rw-r--r--tests/cases/phicubed.ll29
-rw-r--r--tests/cases/storestruct.ll5
-rw-r--r--tests/cases/unannotated__noasm.ll (renamed from tests/cases/unannotated.ll)0
-rw-r--r--tests/cases/unannotated__noasm.txt (renamed from tests/cases/unannotated.txt)0
-rw-r--r--tests/gl_ps_strides.c241
-rw-r--r--tests/gl_ps_strides.pngbin0 -> 98713 bytes
-rw-r--r--tests/openal_playback.cpp115
-rwxr-xr-xtests/runner.py239
-rw-r--r--tests/sdl_audio_mix.c2
-rw-r--r--tests/sounds/audio.wavbin0 -> 190764 bytes
13 files changed, 617 insertions, 64 deletions
diff --git a/tests/cases/alignedunaligned.ll b/tests/cases/alignedunaligned.ll
index 9faa87ef..f4e0535a 100644
--- a/tests/cases/alignedunaligned.ll
+++ b/tests/cases/alignedunaligned.ll
@@ -15,9 +15,7 @@ entry:
%saved_stack = alloca i8* ; [#uses=2 type=i8**]
%cleanup.dest.slot = alloca i32 ; [#uses=1 type=i32*]
store i32 0, i32* %retval
- call void @llvm.dbg.declare(metadata !{i8** %str}, metadata !12), !dbg !16 ; [debug line = 6:19] [debug variable = str]
store i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0), i8** %str, align 4, !dbg !17 ; [debug line = 6:39]
- call void @llvm.dbg.declare(metadata !{i32* %len}, metadata !18), !dbg !19 ; [debug line = 7:17] [debug variable = len]
%0 = load i8** %str, align 4, !dbg !20 ; [#uses=1 type=i8*] [debug line = 7:23]
%call = call i32 @strlen(i8* %0), !dbg !20 ; [#uses=1 type=i32] [debug line = 7:23]
store i32 %call, i32* %len, align 4, !dbg !20 ; [debug line = 7:23]
@@ -26,7 +24,6 @@ entry:
%2 = call i8* @llvm.stacksave(), !dbg !21 ; [#uses=1 type=i8*] [debug line = 8:29]
store i8* %2, i8** %saved_stack, !dbg !21 ; [debug line = 8:29]
%vla = alloca i8, i32 %add, align 1, !dbg !21 ; [#uses=93 type=i8*] [debug line = 8:29]
- call void @llvm.dbg.declare(metadata !{i8* %vla}, metadata !22), !dbg !26 ; [debug line = 8:18] [debug variable = curr]
%3 = load i32* %len, align 4, !dbg !27 ; [#uses=1 type=i32] [debug line = 13:13]
call void @llvm.memset.p0i8.i32(i8* %vla, i8 46, i32 %3, i32 4, i1 false), !dbg !27 ; [debug line = 13:13]
%4 = load i32* %len, align 4, !dbg !27 ; [#uses=1 type=i32] [debug line = 13:13]
@@ -210,9 +207,6 @@ entry:
ret i32 %63, !dbg !122 ; [debug line = 40:11]
}
-; [#uses=3]
-declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
-
; [#uses=1]
declare i32 @strlen(i8*)
diff --git a/tests/cases/breakinthemiddle3.ll b/tests/cases/breakinthemiddle3.ll
new file mode 100644
index 00000000..e9173965
--- /dev/null
+++ b/tests/cases/breakinthemiddle3.ll
@@ -0,0 +1,26 @@
+@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
+
+define linkonce_odr i32 @main() align 2 {
+ %333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %199 = trunc i8 1 to i1 ; [#uses=1]
+ switch i32 %333, label %label999 [
+ i32 1000, label %label995
+ ] ; switch should ignore all code after it in the block
+ ; No predecessors!
+ %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ cleanup
+ %a473 = extractvalue { i8*, i32 } %a472, 0
+ %a474 = extractvalue { i8*, i32 } %a472, 1
+ br label %label999
+
+label995:
+ %333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ br label %label999
+
+label999: ; preds = %555
+ ret i32 0
+}
+
+declare i32 @printf(i8*)
+declare i32 @__gxx_personality_v0(...)
+
diff --git a/tests/cases/callundef.ll b/tests/cases/callundef.ll
new file mode 100644
index 00000000..a540a08c
--- /dev/null
+++ b/tests/cases/callundef.ll
@@ -0,0 +1,18 @@
+; 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"
+
+@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ store i32 0, i32* %retval
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
+ call void undef(i32 55)
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
diff --git a/tests/cases/phicubed.ll b/tests/cases/phicubed.ll
index 4f0611ec..a0799997 100644
--- a/tests/cases/phicubed.ll
+++ b/tests/cases/phicubed.ll
@@ -12,25 +12,16 @@ entry:
%a = alloca %struct.worker_args, align 4 ; [#uses=3 type=%struct.worker_args*]
%b = alloca %struct.worker_args, align 4 ; [#uses=4 type=%struct.worker_args*]
%chunk = alloca [10 x %struct.worker_args], align 4 ; [#uses=30 type=[10 x %struct.worker_args]*]
- call void @llvm.dbg.declare(metadata !{%struct.worker_args* %a}, metadata !12), !dbg !23 ; [debug line = 9:25] [debug variable = a]
- call void @llvm.dbg.declare(metadata !{%struct.worker_args* %b}, metadata !24), !dbg !25 ; [debug line = 10:25] [debug variable = b]
%value = getelementptr inbounds %struct.worker_args* %a, i32 0, i32 0, !dbg !26 ; [#uses=1 type=i32*] [debug line = 11:13]
store i32 60, i32* %value, align 4, !dbg !26 ; [debug line = 11:13]
call void @emscripten_autodebug_i32(i32 16, i32 60)
%next = getelementptr inbounds %struct.worker_args* %a, i32 0, i32 1, !dbg !27 ; [#uses=1 type=%struct.worker_args**] [debug line = 12:13]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %b}, i64 0, metadata !24), !dbg !27 ; [debug line = 12:13] [debug variable = b]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %b}, i64 0, metadata !24), !dbg !27 ; [debug line = 12:13] [debug variable = b]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %b}, i64 0, metadata !24), !dbg !27 ; [debug line = 12:13] [debug variable = b]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %b}, i64 0, metadata !24), !dbg !27 ; [debug line = 12:13] [debug variable = b]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %b}, i64 0, metadata !24), !dbg !27 ; [debug line = 12:13] [debug variable = b]
store %struct.worker_args* %b, %struct.worker_args** %next, align 4, !dbg !27 ; [debug line = 12:13]
%value1 = getelementptr inbounds %struct.worker_args* %b, i32 0, i32 0, !dbg !28 ; [#uses=1 type=i32*] [debug line = 13:13]
store i32 900, i32* %value1, align 4, !dbg !28 ; [debug line = 13:13]
call void @emscripten_autodebug_i32(i32 26, i32 900)
%next2 = getelementptr inbounds %struct.worker_args* %b, i32 0, i32 1, !dbg !29 ; [#uses=1 type=%struct.worker_args**] [debug line = 14:13]
store %struct.worker_args* null, %struct.worker_args** %next2, align 4, !dbg !29 ; [debug line = 14:13]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %a}, i64 0, metadata !30), !dbg !31 ; [debug line = 15:32] [debug variable = c]
- call void @llvm.dbg.value(metadata !2, i64 0, metadata !32), !dbg !33 ; [debug line = 16:26] [debug variable = total]
br label %while.body, !dbg !34 ; [debug line = 17:13]
for.cond.preheader: ; preds = %while.body
@@ -40,70 +31,60 @@ for.cond.preheader: ; preds = %while.body
%arrayidx7 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 0, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7, %struct.worker_args** %next9, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value5.1 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 1, i32 0, !dbg !35 ; [#uses=1 type=i32*] [debug line = 25:15]
store i32 10, i32* %value5.1, align 4, !dbg !35 ; [debug line = 25:15]
call void @emscripten_autodebug_i32(i32 43, i32 10)
%arrayidx7.1 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 2, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9.1 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 1, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7.1, %struct.worker_args** %next9.1, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value5.2 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 2, i32 0, !dbg !35 ; [#uses=1 type=i32*] [debug line = 25:15]
store i32 20, i32* %value5.2, align 4, !dbg !35 ; [debug line = 25:15]
call void @emscripten_autodebug_i32(i32 50, i32 20)
%arrayidx7.2 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 3, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9.2 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 2, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7.2, %struct.worker_args** %next9.2, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value5.3 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 3, i32 0, !dbg !35 ; [#uses=1 type=i32*] [debug line = 25:15]
store i32 30, i32* %value5.3, align 4, !dbg !35 ; [debug line = 25:15]
call void @emscripten_autodebug_i32(i32 57, i32 30)
%arrayidx7.3 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 4, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9.3 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 3, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7.3, %struct.worker_args** %next9.3, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value5.4 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 4, i32 0, !dbg !35 ; [#uses=1 type=i32*] [debug line = 25:15]
store i32 40, i32* %value5.4, align 4, !dbg !35 ; [debug line = 25:15]
call void @emscripten_autodebug_i32(i32 64, i32 40)
%arrayidx7.4 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 5, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9.4 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 4, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7.4, %struct.worker_args** %next9.4, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value5.5 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 5, i32 0, !dbg !35 ; [#uses=1 type=i32*] [debug line = 25:15]
store i32 50, i32* %value5.5, align 4, !dbg !35 ; [debug line = 25:15]
call void @emscripten_autodebug_i32(i32 71, i32 50)
%arrayidx7.5 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 6, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9.5 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 5, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7.5, %struct.worker_args** %next9.5, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value5.6 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 6, i32 0, !dbg !35 ; [#uses=1 type=i32*] [debug line = 25:15]
store i32 60, i32* %value5.6, align 4, !dbg !35 ; [debug line = 25:15]
call void @emscripten_autodebug_i32(i32 78, i32 60)
%arrayidx7.6 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 7, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9.6 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 6, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7.6, %struct.worker_args** %next9.6, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value5.7 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 7, i32 0, !dbg !35 ; [#uses=1 type=i32*] [debug line = 25:15]
store i32 70, i32* %value5.7, align 4, !dbg !35 ; [debug line = 25:15]
call void @emscripten_autodebug_i32(i32 85, i32 70)
%arrayidx7.7 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 8, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9.7 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 7, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7.7, %struct.worker_args** %next9.7, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value5.8 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 8, i32 0, !dbg !35 ; [#uses=1 type=i32*] [debug line = 25:15]
store i32 80, i32* %value5.8, align 4, !dbg !35 ; [debug line = 25:15]
call void @emscripten_autodebug_i32(i32 92, i32 80)
%arrayidx7.8 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 9, !dbg !38 ; [#uses=1 type=%struct.worker_args*] [debug line = 26:15]
%next9.8 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 8, i32 1, !dbg !38 ; [#uses=1 type=%struct.worker_args**] [debug line = 26:15]
store %struct.worker_args* %arrayidx7.8, %struct.worker_args** %next9.8, align 4, !dbg !38 ; [debug line = 26:15]
- call void @llvm.dbg.value(metadata !39, i64 0, metadata !40), !dbg !41 ; [debug line = 24:36] [debug variable = i]
%value11 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 9, i32 0, !dbg !42 ; [#uses=1 type=i32*] [debug line = 28:13]
store i32 90, i32* %value11, align 4, !dbg !42 ; [debug line = 28:13]
call void @emscripten_autodebug_i32(i32 99, i32 90)
%arrayidx12 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 0, !dbg !43 ; [#uses=3 type=%struct.worker_args*] [debug line = 29:13]
%next14 = getelementptr inbounds [10 x %struct.worker_args]* %chunk, i32 0, i32 9, i32 1, !dbg !43 ; [#uses=1 type=%struct.worker_args**] [debug line = 29:13]
store %struct.worker_args* %arrayidx12, %struct.worker_args** %next14, align 4, !dbg !43 ; [debug line = 29:13]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %arrayidx12}, i64 0, metadata !30), !dbg !44 ; [debug line = 31:13] [debug variable = c]
br label %do.body, !dbg !45 ; [debug line = 32:13]
while.body: ; preds = %while.body.while.body_crit_edge, %entry
@@ -114,8 +95,6 @@ while.body: ; preds = %while.body.while.bo
%1 = load i32* %value3, align 4, !dbg !46 ; [#uses=2 type=i32] [debug line = 18:15]
call void @emscripten_autodebug_i32(i32 112, i32 %1)
%add = add nsw i32 %1, %total.02, !dbg !46 ; [#uses=2 type=i32] [debug line = 18:15]
- call void @llvm.dbg.value(metadata !{i32 %add}, i64 0, metadata !32), !dbg !46 ; [debug line = 18:15] [debug variable = total]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %0}, i64 0, metadata !30), !dbg !48 ; [debug line = 19:15] [debug variable = c]
%tobool = icmp eq %struct.worker_args* %0, null, !dbg !34 ; [#uses=1 type=i1] [debug line = 17:13]
br i1 %tobool, label %for.cond.preheader, label %while.body.while.body_crit_edge, !dbg !34 ; [debug line = 17:13]
@@ -131,10 +110,8 @@ do.body: ; preds = %do.body, %for.cond.
%2 = load i32* %value15, align 4, !dbg !49 ; [#uses=2 type=i32] [debug line = 33:15]
call void @emscripten_autodebug_i32(i32 129, i32 %2)
%add16 = add nsw i32 %2, %total.1, !dbg !49 ; [#uses=2 type=i32] [debug line = 33:15]
- call void @llvm.dbg.value(metadata !{i32 %add16}, i64 0, metadata !32), !dbg !49 ; [debug line = 33:15] [debug variable = total]
%next17 = getelementptr inbounds %struct.worker_args* %c.1, i32 0, i32 1, !dbg !51 ; [#uses=1 type=%struct.worker_args**] [debug line = 34:15]
%3 = load %struct.worker_args** %next17, align 4, !dbg !51 ; [#uses=2 type=%struct.worker_args*] [debug line = 34:15]
- call void @llvm.dbg.value(metadata !{%struct.worker_args* %3}, i64 0, metadata !30), !dbg !51 ; [debug line = 34:15] [debug variable = c]
%cmp19 = icmp eq %struct.worker_args* %3, %arrayidx12, !dbg !52 ; [#uses=1 type=i1] [debug line = 35:13]
br i1 %cmp19, label %do.end, label %do.body, !dbg !52 ; [debug line = 35:13]
@@ -143,15 +120,9 @@ do.end: ; preds = %do.body
ret i32 0, !dbg !54 ; [debug line = 40:13]
}
-; [#uses=2]
-declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
-
; [#uses=7]
declare i32 @printf(i8* nocapture, ...) nounwind
-; [#uses=21]
-declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
-
; [#uses=0]
define void @emscripten_autodebug_i64(i32 %line, i64 %value) {
entry:
diff --git a/tests/cases/storestruct.ll b/tests/cases/storestruct.ll
index 5bd9224e..a5b7483b 100644
--- a/tests/cases/storestruct.ll
+++ b/tests/cases/storestruct.ll
@@ -15,8 +15,6 @@ entry:
%x = alloca %struct.X, align 4 ; [#uses=2]
%y = alloca %struct.X, align 4 ; [#uses=2]
store i32 0, i32* %retval
- call void @llvm.dbg.declare(metadata !{%struct.X* %x}, metadata !6), !dbg !13
- call void @llvm.dbg.declare(metadata !{%struct.X* %y}, metadata !14), !dbg !15
%a = getelementptr inbounds %struct.X* %x, i32 0, i32 0, !dbg !16 ; [#uses=1]
store i32 5, i32* %a, align 4, !dbg !16
%b = getelementptr inbounds %struct.X* %x, i32 0, i32 1, !dbg !17 ; [#uses=1]
@@ -54,9 +52,6 @@ entry:
ret i32 0, !dbg !19
}
-; [#uses=2]
-declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
-
; [#uses=1]
declare i32 @printf(i8*, ...)
diff --git a/tests/cases/unannotated.ll b/tests/cases/unannotated__noasm.ll
index d87b2e54..d87b2e54 100644
--- a/tests/cases/unannotated.ll
+++ b/tests/cases/unannotated__noasm.ll
diff --git a/tests/cases/unannotated.txt b/tests/cases/unannotated__noasm.txt
index 9daeafb9..9daeafb9 100644
--- a/tests/cases/unannotated.txt
+++ b/tests/cases/unannotated__noasm.txt
diff --git a/tests/gl_ps_strides.c b/tests/gl_ps_strides.c
new file mode 100644
index 00000000..d88f5d0b
--- /dev/null
+++ b/tests/gl_ps_strides.c
@@ -0,0 +1,241 @@
+/*******************************************************************
+ * *
+ * Using SDL With OpenGL *
+ * *
+ * Tutorial by Kyle Foley (sdw) *
+ * *
+ * http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL *
+ * *
+ *******************************************************************/
+
+/*
+THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION
+AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN.
+
+THE ORIGINAL AUTHOR IS KYLE FOLEY.
+
+THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY
+OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF
+MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE,
+ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE
+RESULTING FROM THE USE, MODIFICATION, OR
+REDISTRIBUTION OF THIS SOFTWARE.
+*/
+
+#if !EMSCRIPTEN
+#define USE_GLEW 1
+#endif
+
+#if USE_GLEW
+#include "GL/glew.h"
+#endif
+
+#include "SDL/SDL.h"
+#include "SDL/SDL_image.h"
+#if !USE_GLEW
+#include "SDL/SDL_opengl.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+void shaders() {
+#if USE_GLEW
+ glewInit();
+#endif
+
+ GLint ok;
+
+ const char *vertexShader = "void main(void) \n"
+ "{ \n"
+ " gl_Position = ftransform(); \n"
+ " gl_TexCoord[0] = gl_MultiTexCoord0; \n"
+ " gl_FrontColor = gl_Color; \n"
+ "} \n";
+ const char *fragmentShader = "uniform sampler2D tex0; \n"
+ "void main(void) \n"
+ "{ \n"
+ " gl_FragColor = gl_Color * texture2D(tex0, gl_TexCoord[0].xy); \n"
+ "} \n";
+
+ GLuint vs = glCreateShader(GL_VERTEX_SHADER);
+ glShaderSource(vs, 1, &vertexShader, NULL);
+ glCompileShader(vs);
+ glGetShaderiv(vs, GL_COMPILE_STATUS, &ok);
+ assert(ok);
+
+ GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
+ glShaderSource(fs, 1, &fragmentShader, NULL);
+ glCompileShader(fs);
+ glGetShaderiv(fs, GL_COMPILE_STATUS, &ok);
+ assert(ok);
+
+ GLuint program = glCreateProgram();
+
+ glAttachShader(program, vs);
+ glAttachShader(program, fs);
+ glLinkProgram(program);
+ glGetProgramiv(program, GL_LINK_STATUS, &ok);
+ assert(ok);
+ assert(glIsProgram(program));
+ assert(!glIsProgram(0));
+ assert(!glIsProgram(program+1)); // a number that can't be a real shader
+
+ glUseProgram(program);
+
+ {
+ // Also, check getting the error log
+ const char *fakeVertexShader = "atbute ve4 blarg; ### AAA\n";
+ GLuint vs = glCreateShader(GL_VERTEX_SHADER);
+ glShaderSource(vs, 1, &fakeVertexShader, NULL);
+ glCompileShader(vs);
+ glGetShaderiv(vs, GL_COMPILE_STATUS, &ok);
+ assert(!ok);
+ GLint infoLen = 0;
+ glGetShaderiv(vs, GL_INFO_LOG_LENGTH, &infoLen);
+ assert(infoLen > 1);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+
+ // Slightly different SDL initialization
+ if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) {
+ printf("Unable to initialize SDL: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // *new*
+
+ screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); // *changed*
+ if ( !screen ) {
+ printf("Unable to set video mode: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ // Set the OpenGL state after creating the context with SDL_SetVideoMode
+
+ glClearColor( 0, 0, 0, 0 );
+
+#if !EMSCRIPTEN
+ glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL
+#endif
+
+ glViewport( 0, 0, 640, 480 );
+
+ glMatrixMode( GL_PROJECTION );
+ GLfloat matrixData[] = { 2.0/640, 0, 0, 0,
+ 0, -2.0/480, 0, 0,
+ 0, 0, -1, 0,
+ -1, 1, 0, 1 };
+ glLoadMatrixf(matrixData); // test loadmatrix
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ // Load the OpenGL texture
+
+ GLuint texture; // Texture object handle
+ SDL_Surface *surface; // Gives us the information to make the texture
+
+ if ( (surface = IMG_Load("screenshot.png")) ) {
+
+ // Check that the image's width is a power of 2
+ if ( (surface->w & (surface->w - 1)) != 0 ) {
+ printf("warning: image.bmp's width is not a power of 2\n");
+ }
+
+ // Also check if the height is a power of 2
+ if ( (surface->h & (surface->h - 1)) != 0 ) {
+ printf("warning: image.bmp's height is not a power of 2\n");
+ }
+
+ // Have OpenGL generate a texture object handle for us
+ glGenTextures( 1, &texture );
+
+ // Bind the texture object
+ glBindTexture( GL_TEXTURE_2D, texture );
+
+ // Set the texture's stretching properties
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+
+ //SDL_LockSurface(surface);
+
+ // Add some greyness
+ memset(surface->pixels, 0x66, surface->w*surface->h);
+
+ // Edit the texture object's image data using the information SDL_Surface gives us
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels );
+
+ //SDL_UnlockSurface(surface);
+ }
+ else {
+ printf("SDL could not load image.bmp: %s\n", SDL_GetError());
+ SDL_Quit();
+ return 1;
+ }
+
+ // Free the SDL_Surface only if it was successfully created
+ if ( surface ) {
+ SDL_FreeSurface( surface );
+ }
+
+ // Clear the screen before drawing
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ shaders();
+
+ // Bind the texture to which subsequent calls refer to
+ glBindTexture( GL_TEXTURE_2D, texture );
+
+ // Use clientside vertex pointers to render two items
+ GLfloat vertexData[] = { 0, 0, 10, 10, // texture2, position2
+ 1, 0, 300, 10,
+ 1, 1, 300, 128,
+ 0, 1, 10, 128,
+ 0, 0.5, 410, 10,
+ 1, 0.5, 600, 10,
+ 1, 1, 630, 200,
+ 0.5, 1, 310, 250,
+ 0, 0, 100, 300,
+ 1, 0, 300, 300,
+ 1, 1, 300, 400,
+ 0, 1, 100, 400 };
+
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(2, GL_FLOAT, 4*4, &vertexData[0]);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(2, GL_FLOAT, 4*4, &vertexData[2]);
+
+ glDrawArrays(GL_QUADS, 0, 4);
+
+ glTexCoordPointer(2, GL_FLOAT, 4*4*2, &vertexData[0]); // and now with a different stride
+ glVertexPointer(2, GL_FLOAT, 4*4*2, &vertexData[2]);
+ glDrawArrays(GL_QUADS, 4, 4);
+
+ glTexCoordPointer(2, GL_FLOAT, 4*4, &vertexData[0]); // and back
+ glVertexPointer(2, GL_FLOAT, 4*4, &vertexData[2]);
+ glDrawArrays(GL_QUADS, 8, 4);
+
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ SDL_GL_SwapBuffers();
+
+#if !EMSCRIPTEN
+ // Wait for 3 seconds to give us a chance to see the image
+ SDL_Delay(3000);
+#endif
+
+ // Now we can delete the OpenGL texture and close down SDL
+ glDeleteTextures( 1, &texture );
+
+ SDL_Quit();
+
+ return 0;
+}
diff --git a/tests/gl_ps_strides.png b/tests/gl_ps_strides.png
new file mode 100644
index 00000000..5b49af36
--- /dev/null
+++ b/tests/gl_ps_strides.png
Binary files differ
diff --git a/tests/openal_playback.cpp b/tests/openal_playback.cpp
new file mode 100644
index 00000000..13d619e6
--- /dev/null
+++ b/tests/openal_playback.cpp
@@ -0,0 +1,115 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <AL/al.h>
+#include <AL/alc.h>
+#include <assert.h>
+#include <emscripten.h>
+
+void playSource(void* arg)
+{
+ ALuint source = reinterpret_cast<ALuint>(arg);
+ ALint state;
+ alGetSourcei(source, AL_SOURCE_STATE, &state);
+ assert(state == AL_PLAYING);
+ alSourcePause(source);
+ alGetSourcei(source, AL_SOURCE_STATE, &state);
+ assert(state == AL_PAUSED);
+ alSourcePlay(source);
+ alGetSourcei(source, AL_SOURCE_STATE, &state);
+ assert(state == AL_PLAYING);
+ alSourceStop(source);
+ alGetSourcei(source, AL_SOURCE_STATE, &state);
+ assert(state == AL_STOPPED);
+
+ int result = 1;
+ REPORT_RESULT();
+}
+
+int main() {
+ ALCdevice* device = alcOpenDevice(NULL);
+ ALCcontext* context = alcCreateContext(device, NULL);
+ alcMakeContextCurrent(context);
+
+ ALfloat listenerPos[] = {0.0, 0.0, 0.0};
+ ALfloat listenerVel[] = {0.0, 0.0, 0.0};
+ ALfloat listenerOri[] = {0.0, 0.0, -1.0, 0.0, 1.0, 0.0};
+
+ alListenerfv(AL_POSITION, listenerPos);
+ alListenerfv(AL_VELOCITY, listenerVel);
+ alListenerfv(AL_ORIENTATION, listenerOri);
+
+ ALuint buffers[1];
+
+ alGenBuffers(1, buffers);
+
+ FILE* source = fopen("audio.wav", "rb");
+ fseek(source, 0, SEEK_END);
+ int size = ftell(source);
+ fseek(source, 0, SEEK_SET);
+
+ unsigned char* buffer = (unsigned char*) malloc(size);
+ fread(buffer, size, 1, source);
+
+ unsigned offset = 12; // ignore the RIFF header
+ offset += 8; // ignore the fmt header
+ offset += 2; // ignore the format type
+
+ unsigned channels = buffer[offset + 1] << 8;
+ channels |= buffer[offset];
+ offset += 2;
+ printf("Channels: %u\n", channels);
+
+ unsigned frequency = buffer[offset + 3] << 24;
+ frequency |= buffer[offset + 2] << 16;
+ frequency |= buffer[offset + 1] << 8;
+ frequency |= buffer[offset];
+ offset += 4;
+ printf("Frequency: %u\n", frequency);
+
+ offset += 6; // ignore block size and bps
+
+ unsigned bits = buffer[offset + 1] << 8;
+ bits |= buffer[offset];
+ offset += 2;
+ printf("Bits: %u\n", bits);
+
+ ALenum format = 0;
+ if(bits == 8)
+ {
+ if(channels == 1)
+ format = AL_FORMAT_MONO8;
+ else if(channels == 2)
+ format = AL_FORMAT_STEREO8;
+ }
+ else if(bits == 16)
+ {
+ if(channels == 1)
+ format = AL_FORMAT_MONO16;
+ else if(channels == 2)
+ format = AL_FORMAT_STEREO16;
+ }
+
+ offset += 8; // ignore the data chunk
+
+ printf("Start offset: %d\n", offset);
+
+ alBufferData(buffers[0], format, &buffer[offset], size - offset, frequency);
+
+ ALuint sources[1];
+ alGenSources(1, sources);
+
+ alSourcei(sources[0], AL_BUFFER, buffers[0]);
+
+ ALint state;
+ alGetSourcei(sources[0], AL_SOURCE_STATE, &state);
+ assert(state == AL_INITIAL);
+
+ alSourcePlay(sources[0]);
+
+ alGetSourcei(sources[0], AL_SOURCE_STATE, &state);
+ assert(state == AL_PLAYING);
+
+ emscripten_async_call(playSource, reinterpret_cast<void*>(sources[0]), 700);
+
+ return 0;
+}
diff --git a/tests/runner.py b/tests/runner.py
index 99c536e3..529dcc48 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -829,11 +829,14 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
int add_low = add;
int add_high = add >> 32;
printf("*%lld,%lld,%u,%u*\n", mul, add, add_low, add_high);
+ int64 x = sec + (usec << 25);
+ x >>= argc*3;
+ printf("*%llu*\n", x);
return 0;
}
'''
- self.do_run(src, '*1329409676000000,1329412005509675,3663280683,309527*\n')
+ self.do_run(src, '*1329409676000000,1329412005509675,3663280683,309527*\n*9770671914067409*\n')
def test_i64_cmp(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
@@ -1003,12 +1006,6 @@ m_divisor is 1091269979
'''
self.do_run(src, open(path_from_root('tests', 'i64_precise.txt')).read())
- # Verify that without precision, we do not include the precision code
- Settings.PRECISE_I64_MATH = 0
- self.do_run(src, 'unsigned')
- code = open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read()
- assert 'goog.math.Long' not in code, 'i64 precise math should not have been included if not asked for'
-
# Verify that even if we ask for precision, if it is not needed it is not included
Settings.PRECISE_I64_MATH = 1
src = '''
@@ -1890,13 +1887,34 @@ Succeeded!
printf("%s\\n", strdup_val);
free(strdup_val);
+ {
+ char *one = "one 1 ONE !";
+ char *two = "two 2 TWO ?";
+ char three[1024];
+ memset(three, '.', 1024);
+ three[50] = 0;
+ strncpy(three + argc, one + (argc/2), argc+1);
+ strncpy(three + argc*3, two + (argc/3), argc+2);
+ printf("waka %s\\n", three);
+ }
+
+ {
+ char *one = "string number one top notch";
+ char *two = "fa la sa ho fi FI FO FUM WHEN WHERE WHY HOW WHO";
+ char three[1000];
+ strcpy(three, &one[argc*2]);
+ strcat(three, &two[argc*3]);
+ printf("cat |%s|\\n", three);
+ }
+
return 0;
}
'''
for named in (0, 1):
print named
Settings.NAMED_GLOBALS = named
- self.do_run(src, '4:10,177,543,def\n4\nwowie\ntoo\n76\n5\n(null)\n/* a comment */\n// another\ntest\n', ['wowie', 'too', '74'])
+ self.do_run(src, '''4:10,177,543,def\n4\nwowie\ntoo\n76\n5\n(null)\n/* a comment */\n// another\ntest\nwaka ....e 1 O...wo 2 T................................
+cat |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO|''', ['wowie', 'too', '74'])
if self.emcc_args == []:
gen = open(self.in_dir('src.cpp.o.js')).read()
assert ('var __str1;' in gen) == named
@@ -4117,10 +4135,12 @@ The current type of b is: 9
#define CONSTRLEN 32
+ char * (*func)(char *, const char *) = NULL;
+
void conoutfv(const char *fmt)
{
static char buf[CONSTRLEN];
- strcpy(buf, fmt);
+ func(buf, fmt); // call by function pointer to make sure we test strcpy here
puts(buf);
}
@@ -4142,6 +4162,7 @@ The current type of b is: 9
};
int main() {
+ func = &strcpy;
conoutfv("*staticccz*");
printf("*%.2f,%.2f,%.2f*\\n", S::getIdentity().x, S::getIdentity().y, S::getIdentity().z);
return 0;
@@ -5232,6 +5253,62 @@ at function.:blag
'''
self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
+ def test_vsnprintf(self):
+ if self.emcc_args is None: return self.skip('needs i64 math')
+
+ src = r'''
+ #include <stdio.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+
+ void printy(const char *f, ...)
+ {
+ char buffer[256];
+ va_list args;
+ va_start(args, f);
+ vsnprintf(buffer, 256, f, args);
+ puts(buffer);
+ va_end(args);
+ }
+
+ int main(int argc, char **argv) {
+ int64_t x = argc - 1;
+ int64_t y = argc - 1 + 0x400000;
+ if (x % 3 == 2) y *= 2;
+
+ printy("0x%llx_0x%llx", x, y);
+ printy("0x%llx_0x%llx", x, x);
+ printy("0x%llx_0x%llx", y, x);
+ printy("0x%llx_0x%llx", y, y);
+
+ {
+ uint64_t A = 0x800000;
+ uint64_t B = 0x800000000000ULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+ {
+ uint64_t A = 0x800;
+ uint64_t B = 0x12340000000000ULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+ {
+ uint64_t A = 0x000009182746756;
+ uint64_t B = 0x192837465631ACBDULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+
+ return 0;
+ }
+ '''
+ self.do_run(src, '''0x0_0x400000
+0x0_0x0
+0x400000_0x0
+0x400000_0x400000
+0x800000_0x800000000000
+0x800_0x12340000000000
+0x9182746756_0x192837465631acbd