aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/aliasbitcast2_noasm.ll (renamed from tests/cases/aliasbitcast2.ll)0
-rw-r--r--tests/cases/aliasbitcast3_noasm.ll (renamed from tests/cases/aliasbitcast3.ll)0
-rw-r--r--tests/cases/aliasbitcastdollar_noasm.ll (renamed from tests/cases/aliasbitcastdollar.ll)0
-rw-r--r--tests/cases/gepoverflow.txt2
-rw-r--r--tests/cases/longjmp_tiny_noasm.ll (renamed from tests/cases/longjmp_tiny.ll)0
-rw-r--r--tests/cases/longjmp_tiny_noasm.txt (renamed from tests/cases/longjmp_tiny.txt)0
-rw-r--r--tests/cases/selectstruct.ll3
-rw-r--r--tests/cases/structparam.ll36
-rw-r--r--tests/cases/structparam.txt1
-rw-r--r--tests/cases/typestr.ll19
-rw-r--r--tests/cases/uadd_overflow.ll25
-rw-r--r--tests/cases/uadd_overflow.txt1
-rw-r--r--tests/cases/uadd_overflow_ta2.ll44
-rw-r--r--tests/cases/uadd_overflow_ta2.txt3
-rw-r--r--tests/emscripten_fs_api_browser.cpp38
-rw-r--r--tests/enet_client.c2
-rw-r--r--tests/enet_server.c2
-rw-r--r--tests/files.cpp18
-rw-r--r--tests/http.cpp286
-rw-r--r--tests/http.h151
-rw-r--r--tests/lua/lua.ll15
-rwxr-xr-xtests/runner.py420
-rw-r--r--tests/sqlite/sqlite-autooptimize.fails.txt3436
-rw-r--r--tests/websockets.c21
-rw-r--r--tests/websockets_bi.c4
-rw-r--r--tests/websockets_bi_side.c4
26 files changed, 918 insertions, 3613 deletions
diff --git a/tests/cases/aliasbitcast2.ll b/tests/cases/aliasbitcast2_noasm.ll
index 8537e272..8537e272 100644
--- a/tests/cases/aliasbitcast2.ll
+++ b/tests/cases/aliasbitcast2_noasm.ll
diff --git a/tests/cases/aliasbitcast3.ll b/tests/cases/aliasbitcast3_noasm.ll
index 4ff969e3..4ff969e3 100644
--- a/tests/cases/aliasbitcast3.ll
+++ b/tests/cases/aliasbitcast3_noasm.ll
diff --git a/tests/cases/aliasbitcastdollar.ll b/tests/cases/aliasbitcastdollar_noasm.ll
index 1ecf6047..1ecf6047 100644
--- a/tests/cases/aliasbitcastdollar.ll
+++ b/tests/cases/aliasbitcastdollar_noasm.ll
diff --git a/tests/cases/gepoverflow.txt b/tests/cases/gepoverflow.txt
index e01c78dd..31d67161 100644
--- a/tests/cases/gepoverflow.txt
+++ b/tests/cases/gepoverflow.txt
@@ -1,2 +1,2 @@
-*5246470,5247040*
+*5242366,5242936*
*-514,56*
diff --git a/tests/cases/longjmp_tiny.ll b/tests/cases/longjmp_tiny_noasm.ll
index 0045847c..0045847c 100644
--- a/tests/cases/longjmp_tiny.ll
+++ b/tests/cases/longjmp_tiny_noasm.ll
diff --git a/tests/cases/longjmp_tiny.txt b/tests/cases/longjmp_tiny_noasm.txt
index 8a0aa386..8a0aa386 100644
--- a/tests/cases/longjmp_tiny.txt
+++ b/tests/cases/longjmp_tiny_noasm.txt
diff --git a/tests/cases/selectstruct.ll b/tests/cases/selectstruct.ll
index 90c15ac7..5c9fecf7 100644
--- a/tests/cases/selectstruct.ll
+++ b/tests/cases/selectstruct.ll
@@ -10,7 +10,8 @@ entry:
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
%. = select i1 %retval, { i32, i32 } { i32 55, i32 99 }, { i32, i32 } { i32 2, i32 6 } ; [#uses=1 type={ i32, i32 }]
store i32 0, i32* %retval
- %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %.) ; [#uses=0 type=i32]
+ %.1 = extractvalue { i32, i32 } %., 0
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %.1) ; [#uses=0 type=i32]
ret i32 1
}
diff --git a/tests/cases/structparam.ll b/tests/cases/structparam.ll
new file mode 100644
index 00000000..c59ad600
--- /dev/null
+++ b/tests/cases/structparam.ll
@@ -0,0 +1,36 @@
+; ModuleID = '/dev/shm/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 unnamed_addr constant [15 x i8] c"hello, %d %d!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
+@_dispatchTable = internal global i64 0
+
+define i32 @doit(i32 %x, { i32, i32 } %y) {
+ %y0 = extractvalue { i32, i32 } %y, 0
+ %y1 = extractvalue { i32, i32 } %y, 1
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %y0, i32 %y1) ; [#uses=0 type=i32] [debug line = 5:13]
+ ret i32 0
+}
+
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ %myi64 = alloca i64, align 4
+ %comp = alloca { i32, i32 }, align 4 ; [#uses=1]
+ store i32 0, i32* %retval
+ br label %cond.end
+
+cond.null:
+ br label %cond.end
+
+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
+ %call = call i32 (i32, { i32, i32 })* @doit(i32 1, { i32, i32 } %cond) ;
+ 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]
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
+
diff --git a/tests/cases/structparam.txt b/tests/cases/structparam.txt
new file mode 100644
index 00000000..b2a63262
--- /dev/null
+++ b/tests/cases/structparam.txt
@@ -0,0 +1 @@
+hello, 5 6!
diff --git a/tests/cases/typestr.ll b/tests/cases/typestr.ll
new file mode 100644
index 00000000..49074637
--- /dev/null
+++ b/tests/cases/typestr.ll
@@ -0,0 +1,19 @@
+; 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]*]
+@.str1227 = private unnamed_addr constant [9 x i8] c" = type \00", align 1
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ store i32 0, i32* %retval
+ %call0 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str1227, i32 0, i32 0)) ; [#uses=0 type=i32]
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
diff --git a/tests/cases/uadd_overflow.ll b/tests/cases/uadd_overflow.ll
deleted file mode 100644
index a808b9de..00000000
--- a/tests/cases/uadd_overflow.ll
+++ /dev/null
@@ -1,25 +0,0 @@
-; 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
deleted file mode 100644
index dcda9240..00000000
--- a/tests/cases/uadd_overflow.txt
+++ /dev/null
@@ -1 +0,0 @@
-*3319578,1*
diff --git a/tests/cases/uadd_overflow_ta2.ll b/tests/cases/uadd_overflow_ta2.ll
new file mode 100644
index 00000000..81a76bcd
--- /dev/null
+++ b/tests/cases/uadd_overflow_ta2.ll
@@ -0,0 +1,44 @@
+; 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]
+
+ %buadd1prepre = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %mul7, i32 %shl10)
+ %buadd1pre = insertvalue { i32, i1 } %buadd1prepre, i1 0, 1
+ %buadd1 = insertvalue { i32, i1 } %buadd1pre, i32 5177, 0
+ %ba0 = extractvalue { i32, i1 } %buadd1, 0
+ %ba1 = extractvalue { i32, i1 } %buadd1, 1
+ %ba2 = zext i1 %ba1 to i32
+ call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %ba0, i32 %ba2) ; [#uses=0]
+
+ %64buadd1pre = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 5000, i64 3000)
+ %64buadd1 = insertvalue { i64, i1 } %64buadd1pre, i64 9875, 0
+ %64buadd2 = insertvalue { i64, i1 } %64buadd1, i1 1, 1
+ %64ba0pre = extractvalue { i64, i1 } %64buadd2, 0
+ %64ba0 = trunc i64 %64ba0pre to i32
+ %64ba1 = extractvalue { i64, i1 } %64buadd2, 1
+ %64ba2 = zext i1 %64ba1 to i32
+ call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %64ba0, i32 %64ba2) ; [#uses=0]
+
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
+
+declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
+declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i32) nounwind readnone
+
diff --git a/tests/cases/uadd_overflow_ta2.txt b/tests/cases/uadd_overflow_ta2.txt
new file mode 100644
index 00000000..bcd04599
--- /dev/null
+++ b/tests/cases/uadd_overflow_ta2.txt
@@ -0,0 +1,3 @@
+*3319578,1*
+*5177,0*
+*9875,1*
diff --git a/tests/emscripten_fs_api_browser.cpp b/tests/emscripten_fs_api_browser.cpp
index 9936a09c..0355287a 100644
--- a/tests/emscripten_fs_api_browser.cpp
+++ b/tests/emscripten_fs_api_browser.cpp
@@ -13,6 +13,7 @@ int data_ok = 0;
int data_bad = 0;
void onLoadedData(void *arg, void *buffer, int size) {
+ printf("onLoadedData %d\n", (int)arg);
get_count++;
assert(size == 329895);
assert((int)arg == 135);
@@ -25,29 +26,41 @@ void onLoadedData(void *arg, void *buffer, int size) {
}
void onErrorData(void *arg) {
+ printf("onErrorData %d\n", (int)arg);
get_count++;
assert((int)arg == 246);
data_bad = 1;
}
+int counter = 0;
void wait_wgets() {
+ if (counter++ == 60) {
+ printf("%d\n", get_count);
+ counter = 0;
+ }
+
if (get_count == 3) {
- emscripten_async_wget_data(
- "http://localhost:8888/screenshot.png",
- (void*)135,
- onLoadedData,
- onErrorData);
- emscripten_async_wget_data(
- "http://localhost:8888/fail_me",
- (void*)246,
- onLoadedData,
- onErrorData);
+ static bool fired = false;
+ if (!fired) {
+ fired = true;
+ emscripten_async_wget_data(
+ "http://localhost:8888/screenshot.png",
+ (void*)135,
+ onLoadedData,
+ onErrorData);
+ emscripten_async_wget_data(
+ "http://localhost:8888/fail_me",
+ (void*)246,
+ onLoadedData,
+ onErrorData);
+ }
} else if (get_count == 5) {
assert(IMG_Load("/tmp/screen_shot.png"));
assert(data_ok == 1 && data_bad == 1);
emscripten_cancel_main_loop();
REPORT_RESULT();
}
+ assert(get_count <= 5);
}
void onLoaded(const char* file) {
@@ -55,8 +68,6 @@ void onLoaded(const char* file) {
result = 0;
}
- printf("loaded: %s\n", file);
-
if (FILE * f = fopen(file, "r")) {
printf("exists: %s\n", file);
int c = fgetc (f);
@@ -71,6 +82,7 @@ void onLoaded(const char* file) {
}
get_count++;
+ printf("onLoaded %s\n", file);
}
void onError(const char* file) {
@@ -78,8 +90,8 @@ void onError(const char* file) {
result = 0;
}
- printf("error: %s\n", file);
get_count++;
+ printf("onError %s\n", file);
}
int main() {
diff --git a/tests/enet_client.c b/tests/enet_client.c
index 78c8f314..601b8769 100644
--- a/tests/enet_client.c
+++ b/tests/enet_client.c
@@ -10,7 +10,7 @@ void main_loop() {
#if EMSCRIPTEN
counter++;
#endif
- if (counter == 10) {
+ if (counter == 100) {
printf("stop!\n");
emscripten_cancel_main_loop();
return;
diff --git a/tests/enet_server.c b/tests/enet_server.c
index 87c64038..a8167e16 100644
--- a/tests/enet_server.c
+++ b/tests/enet_server.c
@@ -29,7 +29,7 @@ void main_loop() {
#if EMSCRIPTEN
counter++;
#endif
- if (counter == 10) {
+ if (counter == 100) {
printf("stop!\n");
emscripten_cancel_main_loop();
return;
diff --git a/tests/files.cpp b/tests/files.cpp
index e1a38421..04baa151 100644
--- a/tests/files.cpp
+++ b/tests/files.cpp
@@ -1,6 +1,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
int main()
{
@@ -103,6 +104,23 @@ int main()
fclose(inf);
printf("fscanfed: %d - %s\n", number, text);
+ // temp files
+ const char *tname = "file_XXXXXX.txt";
+ char tname1[100];
+ char tname2[100];
+ strcpy(tname1, tname);
+ strcpy(tname2, tname);
+ assert(!strcmp(tname1, tname2)); // equal
+ int f1 = mkstemp(tname1);
+ int f2 = mkstemp(tname2);
+ assert(f1 != f2);
+ //printf("%d,%d,%s,%s\n", f1, f2, tname1, tname2);
+ assert(strcmp(tname1, tname2)); // not equal
+ assert(fopen(tname1, "r"));
+ assert(fopen(tname2, "r"));
+ assert(!fopen(tname2+1, "r")); // sanity check that we can't open just anything
+ printf("ok.\n");
+
return 0;
}
diff --git a/tests/http.cpp b/tests/http.cpp
new file mode 100644
index 00000000..07931e3c
--- /dev/null
+++ b/tests/http.cpp
@@ -0,0 +1,286 @@
+//
+// http.cpp
+// Player Javascript
+//
+// Created by Anthony Liot on 23/11/12.
+//
+
+#include "http.h"
+#include <emscripten/emscripten.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int http::uid = 0;
+
+/*
+- Useful for download an url on other domain
+<?php
+header("Access-Control-Allow-Origin: *");
+// verifie si on a les bons parametres
+if( isset($_GET['url']) ) {
+
+ $fileName = $_GET['url'];
+ if($f = fopen($fileName,'rb') ){
+ $fSize = 0;
+ while(!feof($f)){
+ ++$fSize;
+ $data = fread($f,1);
+ }
+ fclose($f);
+ if( $fSize < 1 ) {
+ header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
+ echo 'For empty file ' . $fileName;
+ die();
+ } else {
+ header("POST ".$fileName." HTTP/1.1\r\n");
+ header('Content-Description: File Transfer');
+ header('Content-Transfer-Encoding: binary');
+ header('Content-Disposition: attachment; filename="' . basename($fileName) . "\";");
+ header('Content-Type: application/octet-stream');
+ header('Content-Length: '.$fSize);
+
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate');
+ header('Pragma: public');
+ ob_clean();
+ flush();
+ readfile($fileName);
+ exit;
+ }
+ } else {
+ header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
+ echo 'For filename ' . $fileName;
+ }
+} else {
+ header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
+}
+?>
+*/
+// http://..../download.php?url=
+std::string http::cross_domain = "";
+
+
+//----------------------------------------------------------------------------------------
+// HTTP CLASS
+//----------------------------------------------------------------------------------------
+
+void http::onLoaded(void* parent, const char * file) {
+ http* req = reinterpret_cast<http*>(parent);
+ req->onLoaded(file);
+}
+
+void http::onError(void* parent, int statuserror) {
+ http* req = reinterpret_cast<http*>(parent);
+ req->onError(statuserror);
+}
+
+void http::onProgress(void* parent, int progress) {
+ http* req = reinterpret_cast<http*>(parent);
+ req->onProgress(progress);
+}
+
+/**
+* Constructeur
+*/
+http::http(const char* hostname, int requestType, const char* targetFilename) : _hostname(hostname), _page(""), _targetFileName(targetFilename), _param(""), _content(""), _error(""), _request((RequestType)requestType), _status(ST_PENDING), _assync(ASSYNC_THREAD) {
+ _progressValue = -1;
+ _uid = uid++;
+}
+
+
+/**
+* Destructeur
+*/
+http::~http() {
+}
+
+/**
+* Effectue la requete
+*/
+void http::runRequest(const char* page, int assync) {
+ _page = page;
+ _status = ST_PENDING;
+ _assync = (AssyncMode)assync;
+ _progressValue = 0;
+
+ std::string url = cross_domain;
+ url += _hostname + _page;
+
+ if (_hostname.size() > 0 && _page.size() > 0) {
+
+ printf("URL : %s\n",url.c_str());
+ printf("REQUEST : %s\n",(_request==REQUEST_GET) ? "GET":"POST");
+ printf("PARAMS : %s\n",_param.c_str());
+
+ if (_targetFileName.size() == 0 ) {
+ _targetFileName = format("prepare%d",_uid);
+ }
+
+ emscripten_async_wget2(url.c_str(), _targetFileName.c_str(), (_request==REQUEST_GET) ? "GET":"POST", _param.c_str(), this, http::onLoaded, http::onError, http::onProgress);
+
+ } else {
+ _error = format("malformed url : %s\n",url.c_str());
+ _content = "";
+ _status = ST_FAILED;
+ _progressValue = -1;
+ }
+}
+
+/**
+* Accede a la reponse
+*/
+const char* http::getContent() {
+ return _content.c_str();
+}
+
+/**
+* Accede a l'erreur
+*/
+const char* http::getError() {
+ return _error.c_str();
+}
+
+/**
+* Accede au status
+*/
+int http::getStatus() {
+ return _status;
+}
+
+/**
+* Accede a la progression between 0 & 100
+*/
+float http::getProgress() {
+ return (float)_progressValue;
+}
+
+/**
+* Accede a la progression between 0 & 100
+*/
+int http::getId() {
+ return _uid;
+}
+
+/**
+* Post
+*/
+void http::addValue(const char* key, const char* value) {
+ if (_param.size() > 0) {
+ _param += "&";
+ _param += key;
+ _param += "=";
+ _param += value;
+ } else {
+ _param += key;
+ _param += "=";
+ _param += value;
+ }
+}
+
+void http::onProgress(int progress) {
+ _progressValue = progress;
+}
+
+void http::onLoaded(const char* file) {
+
+ if (strstr(file,"prepare")) {
+ FILE* f = fopen(file,"rb");
+ if (f) {
+ fseek (f, 0, SEEK_END);
+ int size=ftell (f);
+ fseek (f, 0, SEEK_SET);
+
+ char* data = new char[size];
+ fread(data,size,1,f);
+ _content = data;
+ delete data;
+ fclose(f);
+ } else {
+ _content = file;
+ }
+
+ } else {
+ _content = file;
+ }
+
+ _progressValue = 100;
+ _status = ST_OK;
+}
+
+void http::onError(int error) {
+
+ printf("Error status : %d\n",error);
+
+ _error = "";
+ _content = "";
+ _status = ST_FAILED;
+ _progressValue = -1;
+}
+
+/// TEST
+int num_request = 0;
+float time_elapsed = 0.0f;
+
+void wait_https() {
+ if (num_request == 0) {
+ printf("End of all download ... %fs\n",(emscripten_get_now() - time_elapsed) / 1000.f);
+ emscripten_cancel_main_loop();
+ int result = 0;
+ REPORT_RESULT();
+ }
+}
+
+void wait_http(void* request) {
+ http* req = reinterpret_cast<http*>(request);
+ if (req != 0) {
+ if (req->getStatus() == http::ST_PENDING) {
+ if ((int)req->getProgress()>0) {
+ printf("Progress Request n°%d : %d\n",req->getId(),(int)req->getProgress());
+ }
+ emscripten_async_call(wait_http,request,500);
+
+ } else {
+ if (req->getStatus() == http::ST_OK) {
+ printf("Success Request n°%d : %s\n",req->getId(),req->getContent());
+
+ } else {
+ printf("Error Request n°%d : %s\n",req->getId(), req->getError());
+ }
+
+ num_request --;
+ }
+ } else {
+ num_request --;
+ }
+}
+
+
+int main() {
+ time_elapsed = emscripten_get_now();
+
+ http* http1 = new http("https://github.com",http::REQUEST_GET,"emscripten_master.zip");
+ http1->runRequest("/kripken/emscripten/archive/master.zip",http::ASSYNC_THREAD);
+
+ http* http2 = new http("https://github.com",http::REQUEST_GET,"wolfviking_master.zip");
+ http2->runRequest("/wolfviking0/image.js/archive/master.zip",http::ASSYNC_THREAD);
+
+ http* http3 = new http("https://raw.github.com",http::REQUEST_GET);
+ http3->runRequest("/kripken/emscripten/master/LICENSE",http::ASSYNC_THREAD);
+
+ num_request ++;
+ emscripten_async_call(wait_http,http1,500);
+ num_request ++;
+ emscripten_async_call(wait_http,http2,500);
+ num_request ++;
+ emscripten_async_call(wait_http,http3,500);
+
+ /*
+ Http* http4 = new Http("http://www.---.com",Http::REQUEST_POST);
+ http4->addValue("app","123");
+ http4->runRequest("/test.php",Http::ASSYNC_THREAD);
+ num_request ++;
+ emscripten_async_call(wait_http,http4,500);
+ */
+
+ emscripten_set_main_loop(wait_https, 0, 0);
+}
diff --git a/tests/http.h b/tests/http.h
new file mode 100644
index 00000000..7eff7013
--- /dev/null
+++ b/tests/http.h
@@ -0,0 +1,151 @@
+//
+// Http.h
+// Player Javascript
+//
+// Created by Anthony Liot on 23/11/12.
+//
+
+#ifndef __HTTP_H__
+#define __HTTP_H__
+
+#include <string>
+
+
+/*
+ */
+class http {
+
+ public:
+
+ enum Status {
+ ST_PENDING = 0,
+ ST_FAILED,
+ ST_OK
+ };
+
+ enum RequestType {
+ REQUEST_GET = 0,
+ REQUEST_POST ,
+ };
+
+ enum AssyncMode {
+ ASSYNC_THREAD
+ };
+
+ // enregistrement sur unigine
+ static void RegisterAsExtension(bool regis);
+
+ // Callback
+ static void onLoaded(void* parent, const char * file);
+ static void onError(void* parent, int statuserror);
+ static void onProgress(void* parent, int progress);
+
+ // Constructeur
+ http(const char* hostname, int requestType, const char* targetFileName = "");
+
+ //Destructeur
+ virtual ~http();
+
+ /**
+ * Effectue la requete
+ */
+ void runRequest(const char* page, int assync);
+
+ /**
+ * Accede a la reponse
+ */
+ const char* getContent();
+
+ /**
+ * Accede a l'erreur
+ */
+ const char* getError();
+
+ /**
+ * Accede au status
+ */
+ int getStatus();
+
+ /**
+ * Accede a la progression
+ */
+ float getProgress();
+
+ /**
+ * Get Id of http Class
+ */
+ int getId();
+
+ /**
+ *
+ */
+ void addValue(const char* key, const char* value);
+
+ /**
+ * Callback
+ */
+ void onProgress(int progress);
+ void onLoaded(const char* file);
+ void onError(int error);
+
+ // Static parameter
+ static int uid;
+ static std::string cross_domain ;
+
+ private:
+
+ // Id of request
+ int _uid;
+
+ // nom de l'hote
+ std::string _hostname;
+
+ // nom de la page
+ std::string _page;
+
+ // target filename
+ std::string _targetFileName;
+
+ // param
+ std::string _param;
+
+ // resultat
+ std::string _content;
+
+ // probleme
+ std::string _error;
+
+ // request type
+ RequestType _request;
+
+ // status
+ int _status;
+
+ // progress value
+ int _progressValue;
+
+ // mode assyncrone courant
+ AssyncMode _assync;
+
+};
+
+//this is safe and convenient but not exactly efficient
+inline std::string format(const char* fmt, ...){
+ int size = 512;
+ char* buffer = 0;
+ buffer = new char[size];
+ va_list vl;
+ va_start(vl,fmt);
+ int nsize = vsnprintf(buffer,size,fmt,vl);
+ if(size<=nsize){//fail delete buffer and try again
+ delete buffer; buffer = 0;
+ buffer = new char[nsize+1];//+1 for /0
+ nsize = vsnprintf(buffer,size,fmt,vl);
+ }
+ std::string ret(buffer);
+ va_end(vl);
+ delete buffer;
+ return ret;
+}
+
+#endif /* __HTTP_H__ */
diff --git a/tests/lua/lua.ll b/tests/lua/lua.ll
index 81c7bc27..cffaa3a2 100644
--- a/tests/lua/lua.ll
+++ b/tests/lua/lua.ll
@@ -13914,7 +13914,7 @@ define hidden void @_Z10luaD_throwP9lua_Statei(%struct.lua_State* %L, i32 %errco
%10 = getelementptr inbounds %struct.lua_State* %9, i32 0, i32 25, !dbg !9995 ; [#uses=1]
%11 = load %struct.lua_longjmp** %10, align 4, !dbg !9995 ; [#uses=1]
%12 = getelementptr inbounds %struct.lua_longjmp* %11, i32 0, i32 2, !dbg !9995 ; [#uses=1]
- volatile store i32 %8, i32* %12, align 4, !dbg !9995
+ store i32 %8, i32* %12, align 4, !dbg !9995
%13 = call i8* @__cxa_allocate_exception(i32 4) nounwind, !dbg !9997 ; [#uses=2]
%14 = bitcast i8* %13 to %struct.lua_longjmp**, !dbg !9997 ; [#uses=1]
%15 = load %struct.lua_State** %1, align 4, !dbg !9997 ; [#uses=1]
@@ -14032,7 +14032,7 @@ define hidden i32 @_Z20luaD_rawrunprotectedP9lua_StatePFvS0_PvES1_(%struct.lua_S
call void @llvm.dbg.declare(metadata !743, metadata !10030), !dbg !10031
call void @llvm.dbg.declare(metadata !743, metadata !10032), !dbg !10034
%5 = getelementptr inbounds %struct.lua_longjmp* %lj, i32 0, i32 2, !dbg !10035 ; [#uses=1]
- volatile store i32 0, i32* %5, align 4, !dbg !10035
+ store i32 0, i32* %5, align 4, !dbg !10035
%6 = load %struct.lua_State** %1, align 4, !dbg !10036 ; [#uses=1]
%7 = getelementptr inbounds %struct.lua_State* %6, i32 0, i32 25, !dbg !10036 ; [#uses=1]
%8 = load %struct.lua_longjmp** %7, align 4, !dbg !10036 ; [#uses=1]
@@ -14044,8 +14044,9 @@ define hidden i32 @_Z20luaD_rawrunprotectedP9lua_StatePFvS0_PvES1_(%struct.lua_S
%12 = load void (%struct.lua_State*, i8*)** %2, align 4, !dbg !10038 ; [#uses=1]
%13 = load %struct.lua_State** %1, align 4, !dbg !10038 ; [#uses=1]
%14 = load i8** %3, align 4, !dbg !10038 ; [#uses=1]
- invoke void %12(%struct.lua_State* %13, i8* %14)
- to label %15 unwind label %24, !dbg !10038
+ call void %12(%struct.lua_State* %13, i8* %14)
+ ; to label %15 unwind label %24, !dbg !10038
+ %15 = load i8** %3
; <label>:15 ; preds = %0
br label %28, !dbg !10038
@@ -14054,13 +14055,13 @@ define hidden i32 @_Z20luaD_rawrunprotectedP9lua_StatePFvS0_PvES1_(%struct.lua_S
%17 = load i8** %4, !dbg !10038 ; [#uses=1]
%18 = call i8* @__cxa_begin_catch(i8* %17) nounwind, !dbg !10038 ; [#uses=0]
%19 = getelementptr inbounds %struct.lua_longjmp* %lj, i32 0, i32 2, !dbg !10038 ; [#uses=1]
- %20 = volatile load i32* %19, align 4, !dbg !10038 ; [#uses=1]
+ %20 = load i32* %19, align 4, !dbg !10038 ; [#uses=1]
%21 = icmp eq i32 %20, 0, !dbg !10038 ; [#uses=1]
br i1 %21, label %22, label %27, !dbg !10038
; <label>:22 ; preds = %16
%23 = getelementptr inbounds %struct.lua_longjmp* %lj, i32 0, i32 2, !dbg !10038 ; [#uses=1]
- volatile store i32 -1, i32* %23, align 4, !dbg !10038
+ store i32 -1, i32* %23, align 4, !dbg !10038
br label %27, !dbg !10038
; <label>:24 ; preds = %0
@@ -14080,7 +14081,7 @@ define hidden i32 @_Z20luaD_rawrunprotectedP9lua_StatePFvS0_PvES1_(%struct.lua_S
%32 = getelementptr inbounds %struct.lua_State* %31, i32 0, i32 25, !dbg !10039 ; [#uses=1]
store %struct.lua_longjmp* %30, %struct.lua_longjmp** %32, align 4, !dbg !10039
%33 = getelementptr inbounds %struct.lua_longjmp* %lj, i32 0, i32 2, !dbg !10040 ; [#uses=1]
- %34 = volatile load i32* %33, align 4, !dbg !10040 ; [#uses=1]
+ %34 = load i32* %33, align 4, !dbg !10040 ; [#uses=1]
ret i32 %34, !dbg !10040
}
diff --git a/tests/runner.py b/tests/runner.py
index b1852ff2..d3471f62 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -263,7 +263,7 @@ process(sys.argv[1])
if output_processor is not None:
output_processor(open(filename + '.o.js').read())
- def run_generated_code(self, engine, filename, args=[], check_timeout=True):
+ def run_generated_code(self, engine, filename, args=[], check_timeout=True, output_nicerizer=None):
stdout = os.path.join(self.get_dir(), 'stdout') # use files, as PIPE can get too full and hang us
stderr = os.path.join(self.get_dir(), 'stderr')
try:
@@ -274,7 +274,12 @@ process(sys.argv[1])
run_js(filename, engine, args, check_timeout, stdout=open(stdout, 'w'), stderr=open(stderr, 'w'))
if cwd is not None: