Skip to content

Commit a1f7e8b

Browse files
committed
Adding Stress Test (Not Complete)
1 parent 9ddb390 commit a1f7e8b

6 files changed

Lines changed: 1151 additions & 0 deletions

File tree

examples/C/stress_test/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# stress test
4+
/st_root_a
5+
/st_root_b
6+
test_pass.txt
7+
test_error.txt
8+
log.txt

examples/C/stress_test/GNUmakefile

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# WebUI C Example
2+
3+
# == 1. VARIABLES =============================================================
4+
5+
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
6+
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
7+
TARGET := $(firstword $(MAKECMDGOALS))
8+
LIB_DIR := $(PROJECT_DIR)/dist
9+
ifeq ($(TARGET), debug)
10+
LIB_DIR := $(LIB_DIR)/debug
11+
endif
12+
INCLUDE_DIR := $(PROJECT_DIR)/include
13+
WEBUI_LIB_NAME = webui-2
14+
ifeq ($(WEBUI_USE_TLS), 1)
15+
WEBUI_LIB_NAME = webui-2-secure
16+
endif
17+
18+
# ARGS
19+
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
20+
CC = gcc
21+
# Build the WebUI library if running via `make BUILD_LIB=true`
22+
BUILD_LIB ?=
23+
24+
# BUILD FLAGS
25+
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
26+
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
27+
28+
# Platform conditions
29+
ifeq ($(OS),Windows_NT)
30+
# Windows
31+
PLATFORM := windows
32+
SHELL := CMD
33+
STATIC_BUILD_FLAGS += icon.o -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -lstdc++ -luuid -static
34+
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
35+
DYN_BUILD_FLAGS += icon.o "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32 -lstdc++ -luuid
36+
STATIC_OUT := main.exe
37+
DYN_OUT := main-dyn.exe
38+
LWS2_OPT := -lws2_32 -lole32
39+
STRIP_OPT := --strip-all
40+
CONSOLE_APP := -Wl,-subsystem=console
41+
GUI_APP := -Wl,-subsystem=windows
42+
else
43+
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lpthread -lm -ldl
44+
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME) -lpthread -lm -ldl
45+
STATIC_OUT := main
46+
DYN_OUT := main-dyn
47+
ifeq ($(shell uname),Darwin)
48+
# MacOS
49+
PLATFORM := macos
50+
CC = clang
51+
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
52+
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
53+
else
54+
# Linux
55+
PLATFORM := linux
56+
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
57+
STRIP_OPT := --strip-all
58+
ifeq ($(CC),clang)
59+
LLVM_OPT := llvm-
60+
endif
61+
endif
62+
endif
63+
64+
# == 2.TARGETS ================================================================
65+
66+
all: release
67+
68+
debug: --validate-args
69+
ifeq ($(BUILD_LIB),true)
70+
@cd "$(PROJECT_DIR)" && $(MAKE) debug
71+
endif
72+
ifeq ($(PLATFORM),windows)
73+
@windres icon.rc -o icon.o
74+
endif
75+
# Static with Debug info
76+
ifneq ($(WEBUI_USE_TLS), 1)
77+
@echo "Build C Example ($(CC) debug static)..."
78+
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
79+
endif
80+
# Dynamic with Debug info
81+
@echo "Build C Example ($(CC) debug dynamic)..."
82+
$(COPY_LIB_CMD)
83+
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
84+
# Clean
85+
ifeq ($(PLATFORM),windows)
86+
@- del *.o >nul 2>&1
87+
else
88+
@- rm -f *.o
89+
@- rm -rf *.dSYM # macOS
90+
endif
91+
@echo "Done."
92+
93+
release: --validate-args
94+
ifeq ($(BUILD_LIB),true)
95+
@cd "$(PROJECT_DIR)" && $(MAKE)
96+
endif
97+
ifeq ($(PLATFORM),windows)
98+
@windres icon.rc -o icon.o
99+
endif
100+
# Static Release
101+
ifneq ($(WEBUI_USE_TLS), 1)
102+
@echo "Build C Example ($(CC) release static)..."
103+
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
104+
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
105+
endif
106+
# Dynamic Release
107+
@echo "Build C Example ($(CC) release dynamic)..."
108+
$(COPY_LIB_CMD)
109+
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
110+
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
111+
# Clean
112+
ifeq ($(PLATFORM),windows)
113+
@- del *.o >nul 2>&1
114+
else
115+
@- rm -f *.o
116+
@- rm -rf *.dSYM # macOS
117+
endif
118+
@echo "Done."
119+
120+
clean: --clean-$(PLATFORM)
121+
122+
# INTERNAL TARGETS
123+
124+
--validate-args:
125+
ifneq ($(filter $(CC),gcc clang aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc musl-gcc),$(CC))
126+
$(error Invalid compiler specified: `$(CC)`)
127+
endif
128+
129+
--clean-linux: --clean-unix
130+
131+
--clean-macos: --clean-unix
132+
133+
--clean-unix:
134+
- rm -f *.o
135+
- rm -f *.a
136+
- rm -f *.so
137+
- rm -f *.dylib
138+
- rm -rf *.dSYM
139+
140+
--clean-windows:
141+
- del *.o >nul 2>&1
142+
- del *.dll >nul 2>&1
143+
- del *.a >nul 2>&1
144+
- del *.exe >nul 2>&1

examples/C/stress_test/Makefile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# WebUI C Example
2+
# Windows - Microsoft Visual C
3+
4+
SHELL = CMD
5+
LIB_DIR = ../../../dist
6+
INCLUDE_DIR = ../../../include
7+
WEBUI_LIB_NAME = webui-2
8+
!IF "$(WEBUI_USE_TLS)" == "1"
9+
WEBUI_LIB_NAME = webui-2-secure
10+
!ENDIF
11+
12+
# Build the WebUI library if running `nmake BUILD_LIB=true`
13+
BUILD_LIB =
14+
15+
all: release
16+
17+
debug:
18+
!IF "$(BUILD_LIB)" == "true"
19+
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
20+
!ENDIF
21+
@echo Build icon resource...
22+
@rc /nologo /fo icon.res icon.rc
23+
# Static with Debug info
24+
!IF "$(WEBUI_USE_TLS)" != "1"
25+
@echo Build C Example (Static Debug)...
26+
@cl /Zi main.c icon.res /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
27+
!ENDIF
28+
# Dynamic with Debug info
29+
@echo Build C Example (Dynamic Debug)...
30+
@copy "$(LIB_DIR)\debug\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
31+
@cl /Zi main.c icon.res /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
32+
# Clean
33+
@- del *.exp >nul 2>&1
34+
@- del *.ilk >nul 2>&1
35+
@- del *.lib >nul 2>&1
36+
@- del *.obj >nul 2>&1
37+
@- del *.res >nul 2>&1
38+
@echo Done.
39+
40+
release:
41+
!IF "$(BUILD_LIB)" == "true"
42+
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
43+
!ENDIF
44+
@echo Build icon resource...
45+
@rc /nologo /fo icon.res icon.rc
46+
# Static Release
47+
!IF "$(WEBUI_USE_TLS)" != "1"
48+
@echo Build C Example (Static Release)...
49+
@cl main.c icon.res /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
50+
!ENDIF
51+
# Dynamic Release
52+
@echo Build C Example (Dynamic Release)...
53+
@copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
54+
@cl main.c icon.res /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
55+
# Clean
56+
@- del *.exp >nul 2>&1
57+
@- del *.ilk >nul 2>&1
58+
@- del *.lib >nul 2>&1
59+
@- del *.obj >nul 2>&1
60+
@- del *.pdb >nul 2>&1
61+
@- del *.res >nul 2>&1
62+
@echo Done.
63+
64+
clean:
65+
- del *.obj >nul 2>&1
66+
- del *.ilk >nul 2>&1
67+
- del *.pdb >nul 2>&1
68+
- del *.exp >nul 2>&1
69+
- del *.exe >nul 2>&1
70+
- del *.lib >nul 2>&1
71+
- del *.res >nul 2>&1

examples/C/stress_test/favicon.ico

66.1 KB
Binary file not shown.

examples/C/stress_test/icon.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
32512 ICON "favicon.ico"

0 commit comments

Comments
 (0)