Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/rootfs
17 changes: 9 additions & 8 deletions examples/src/linux/picohttpd/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
all: server arm_server
all: x64_server arm_server

clean:
@rm -rf *.o
@rm -rf server
@rm -rf x64_server
@rm -rf arm_server
@rm -rf armeb_server

server: main.o httpd.o
gcc -o server $^
x64_server: main.o httpd.o
gcc -o x64_server $^
@rm -rf *.o

main.o: main.c httpd.h
gcc -c -o main.o main.c
x64_main.o: main.c httpd.h
gcc -c -o x64_main.o main.c

httpd.o: httpd.c httpd.h
gcc -c -o httpd.o httpd.c
x64_httpd.o: httpd.c httpd.h
gcc -c -o x64_httpd.o httpd.c

arm_server: arm_main.o arm_httpd.o
arm-linux-gnueabi-gcc-10 -o arm_server $^
Expand Down
16 changes: 14 additions & 2 deletions examples/src/linux/picohttpd/main.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#include "httpd.h"

int main(int c, char** v, int argc, const char **argv)
#define PORT_DEFAULT "12913"

int main(int argc, const char **argv)
{
serve_forever("12913");
const char *PORT;

if (argc < 2) {
PORT = PORT_DEFAULT;
} else {
PORT = argv[1];
}

fprintf(stderr, "port is %s.\n", PORT);

serve_forever(PORT);
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions tests/test_elf_multithread.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
except:
pass

ql = Qiling(["../examples/rootfs/armeb_linux/bin/armeb_udp_test","20009"], "../examples/rootfs/armeb_linux", multithread=True)
ql = Qiling(["../examples/rootfs/armeb_linux/bin/armeb_udp_test","20010"], "../examples/rootfs/armeb_linux", multithread=True)
ql.os.set_syscall("write", check_write, QL_INTERCEPT.ENTER)
ql.run()

Expand All @@ -362,7 +362,7 @@ def check_write(ql, write_fd, write_buf, write_count, *args, **kw):

def test_http_elf_linux_x8664(self):
def picohttpd():
ql = Qiling(["../examples/rootfs/x8664_linux/bin/picohttpd"], "../examples/rootfs/x8664_linux", multithread=True, verbose=QL_VERBOSE.DEBUG)
ql = Qiling(["../examples/rootfs/x8664_linux/bin/picohttpd","12911"], "../examples/rootfs/x8664_linux", multithread=True, verbose=QL_VERBOSE.DEBUG)
ql.run()


Expand All @@ -371,12 +371,12 @@ def picohttpd():

time.sleep(1)

f = os.popen("curl http://127.0.0.1:12913")
f = os.popen("curl http://127.0.0.1:12911")
self.assertEqual("httpd_test_successful", f.read())

def test_http_elf_linux_arm(self):
def picohttpd():
ql = Qiling(["../examples/rootfs/arm_linux/bin/picohttpd"], "../examples/rootfs/arm_linux", multithread=True, verbose=QL_VERBOSE.DEBUG)
ql = Qiling(["../examples/rootfs/arm_linux/bin/picohttpd","12912"], "../examples/rootfs/arm_linux", multithread=True, verbose=QL_VERBOSE.DEBUG)
ql.run()


Expand All @@ -385,7 +385,7 @@ def picohttpd():

time.sleep(1)

f = os.popen("curl http://127.0.0.1:12913")
f = os.popen("curl http://127.0.0.1:12912")
self.assertEqual("httpd_test_successful", f.read())

def test_http_elf_linux_armeb(self):
Expand Down