Use docker as dev environment

This commit is contained in:
Jianfeng Jiang
2023-07-05 14:08:58 +08:00
committed by Tate, Hongliang Tian
parent bf961756b9
commit 9137ef434f
52 changed files with 202 additions and 207 deletions

View File

@ -2,11 +2,14 @@ MAKEFLAGS += --no-builtin-rules # Prevent the implicit rules from compiling ".c"
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CUR_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
INITRAMFS ?= $(CUR_DIR)/../build/initramfs
REGRESSION_BUILD_DIR ?= $(INITRAMFS)/regression
TEST_APPS := signal_c pthread network hello_world hello_pie hello_c fork_c fork execve
.PHONY: all
all: build
build:
@cp -a $(CUR_DIR)/* $(INITRAMFS)
@cd $(INITRAMFS) && find . \( -name "*.s" -o -name "*.c" -o -name "Makefile" -o -name "README.md" \) -delete
all:
@mkdir -p $(REGRESSION_BUILD_DIR)
@for test_app in $(TEST_APPS); \
do make --no-print-directory -C $${test_app}; \
done
@make --no-print-directory BUILD_DIR=$(REGRESSION_BUILD_DIR) -C scripts

View File

@ -1,4 +0,0 @@
.PHONY: all
all:
ln -sf /busybox/busybox sh

View File

@ -1 +0,0 @@
/busybox/busybox

View File

@ -1,7 +0,0 @@
### How to compile this busybox
We don't include the source code of busybox here since the source code is really large. The busybox can be compiled with following commands.
After download the source code of busybox 1.35.0 and unzip, then cd to the directory of busybox
1. `make defconfig`. We set all config as default.
2. Set static link option in .config: `CONFIG_STATIC=y`. We need a static-linked busybox binary since we does not support dynamic linking now.
3. Set standalone shell option in .config: `CONFIG_FEATURE_SH_STANDALONE=y`. The standalone ash will try to call busybox applets instead of search binaries in host system. e.g., when running ls, standalone ash will invoke `busybox ls`.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6db28e1ed8bdac06ac595b2126cefc10ecf16156bf4c1005950f561aedc0531a
size 2701792

View File

@ -1,12 +1,3 @@
.PHONY: build clean run
include ../test_common.mk
build: hello.c execve.c
@gcc -static hello.c -o hello
@gcc -static execve.c -o execve
clean:
@rm hello
@rm execve
run: build
@./execve
EXTRA_C_FLAGS :=-static

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c7cc90df87ade7ff2cb494e13678aceaf93542883558fda947bd2fc01e2d73a6
size 871952

View File

@ -8,7 +8,7 @@ int main() {
printf("Execve a new file /execve/hello:\n");
// flush the stdout content to ensure the content print to console
fflush(stdout);
execve("/execve/hello", argv, envp);
execve("/regression/execve/hello", argv, envp);
printf("Should not print\n");
fflush(stdout);
return 0;

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d0152798ba393fb04603ead02083e74de560d9cf51584f5cdca762d0706ebd2d
size 871960

View File

@ -1,10 +1,3 @@
.PHONY: build clean run
include ../test_common.mk
build: fork.s
@gcc -static -nostdlib fork.s -o fork
clean:
@rm fork
run: build
@./fork
EXTRA_C_FLAGS :=-static -nostdlib

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9bc1642390b9dc38ecc058240e529401c38aa8bb9a86bad3615e4bdad505fa8c
size 9592

View File

@ -1,10 +1,3 @@
.PHONY: build clean run
include ../test_common.mk
build: fork.c
@gcc -static fork.c -o fork
clean:
@rm fork
run: build
@./fork
EXTRA_C_FLAGS :=-static

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ca7a77a72da160f11670a04a16b623944295b9059399da45f57668f121b00d11
size 877152

View File

@ -1,10 +1,3 @@
.PHONY: build clean run
include ../test_common.mk
build: hello.c
@gcc -static -mno-sse hello.c -o hello
clean:
@rm hello
run: build
@./hello
EXTRA_C_FLAGS :=-static -mno-sse

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dda5a7d6081cc2252056375d0550731ef2fd24789aa5f17da189a36bf78c588d
size 871896

View File

@ -1,10 +1,3 @@
.PHONY: build clean run
include ../test_common.mk
build: hello.c
@gcc hello.c -o hello
clean:
@rm hello
run: build
@./hello
EXTRA_C_FLAGS :=

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:64b67cf4ad247d668833888447ec7f12d37f5f816abd549d5c2c08fecfa4dd09
size 16696

View File

@ -1,10 +1,3 @@
.PHONY: build clean run
include ../test_common.mk
build: hello_world.s
@gcc -static -nostdlib hello_world.s -o hello_world
clean:
@rm hello_world
run: build
@./hello_world
EXTRA_C_FLAGS :=-static -nostdlib

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f56fb5cf05f234578b13c8d73f2d29568f6f513602f1ea0b71a0dbf0cf8f60f8
size 9104

View File

@ -1,13 +1,3 @@
.PHONY: build clean
include ../test_common.mk
build: tcp/client.c tcp/server.c udp/client.c udp/server.c
@gcc tcp/client.c -o tcp/client
@gcc tcp/server.c -o tcp/server
@gcc udp/server.c -o udp/server
@gcc udp/client.c -o udp/client
clean:
@rm tcp/client
@rm tcp/server
@rm udp/client
@rm udp/server
EXTRA_C_FLAGS :=

View File

@ -1,11 +0,0 @@
#!/bin/sh
NETTEST_DIR=/network
cd ${NETTEST_DIR}
echo "Start net test......"
./tcp/server &
./tcp/client
./udp/server &
./udp/client
echo "All net test passed"

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6ba2aa2da39e5e6d7be121f13e9321a43a4a47b03f50d3d8303d3d51753e2f5c
size 17096

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:209ffb16164cc1e4f7dc978ce3d660e5c9bee5cd4f70e20088d59c8ff64b8d7d
size 17368

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2701b848bdcbde4c1a2af2923f6c57d261befd7b20180fe0c10ac820f7082303
size 17280

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8e890e0782c4320369841b50abfb56f0059b02881ea5b3384224ae65ce9c1d65
size 17328

View File

@ -1,10 +1,3 @@
.PHONY: build clean run
include ../test_common.mk
build: pthread_test.c
@gcc -static pthread_test.c -lpthread -o pthread_test
clean:
@rm pthread_test
run: build
@./pthread_test
EXTRA_C_FLAGS :=-static -lpthread

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d40bfc16dbf95aba3afa1934fa4efc0147f0a0a12533362a8d95e105d4d2af21
size 1693840

View File

@ -0,0 +1,4 @@
.PHONY: all
all: ./*.sh
@cp ./*.sh $(BUILD_DIR)

View File

@ -0,0 +1,11 @@
#!/bin/sh
NETTEST_DIR=/regression/network
cd ${NETTEST_DIR}
echo "Start net test......"
./tcp_server &
./tcp_client
./udp_server &
./udp_client
echo "All net test passed"

View File

@ -2,15 +2,14 @@
set -e
SCRIPT_DIR=/scripts
SCRIPT_DIR=/regression
cd ${SCRIPT_DIR}/..
echo "Running tests......"
tests="hello_world/hello_world fork/fork execve/execve fork_c/fork signal_c/signal_test pthread/pthread_test hello_pie/hello"
for testcase in ${tests}
do
echo "Running test ${testcase}......"
${testcase}
${SCRIPT_DIR}/${testcase}
done
echo "All tests passed"

View File

@ -3,7 +3,7 @@
set -e
set -x
SCRIPT_DIR=/scripts
SCRIPT_DIR=/regression
cd ${SCRIPT_DIR}
touch hello.txt

View File

@ -1,7 +1,3 @@
.PHONY: build clean run
build: signal_test.c
@gcc -static signal_test.c -o signal_test
clean:
@rm signal_test
run: build
@./signal_test
include ../test_common.mk
EXTRA_C_FLAGS :=-static

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:25894b343f222eea5074a83e16a7140868a992a66e7bc8e363fabf2c23e19451
size 882520

View File

@ -0,0 +1,27 @@
MAIN_MAKEFILE := $(firstword $(MAKEFILE_LIST))
INCLUDE_MAKEFILE := $(lastword $(MAKEFILE_LIST))
CUR_DIR := $(shell dirname $(realpath $(MAIN_MAKEFILE)))
CUR_DIR_NAME := $(shell basename $(realpath $(CUR_DIR)))
REGRESSION_BUILD_DIR := $(CUR_DIR)/../../build/initramfs/regression
OBJ_OUTPUT_DIR := $(REGRESSION_BUILD_DIR)/$(CUR_DIR_NAME)
C_SRCS := $(wildcard *.c)
C_OBJS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(C_SRCS:%.c=%))
ASM_SRCS := $(wildcard *.s)
ASM_OBJS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(ASM_SRCS:%.s=%))
CC := gcc
C_FLAGS :=
.PHONY: all
all: $(OBJ_OUTPUT_DIR) $(C_OBJS) $(ASM_OBJS)
$(OBJ_OUTPUT_DIR):
@mkdir -p $(OBJ_OUTPUT_DIR)
$(CUR_DIR)/../../build/initramfs/regression/$(CUR_DIR_NAME)/%: %.c
@$(CC) $(C_FLAGS) $(EXTRA_C_FLAGS) $< -o $@
@echo "CC <= $@"
$(CUR_DIR)/../../build/initramfs/regression/$(CUR_DIR_NAME)/%: %.s
@$(CC) $(C_FLAGS) $(EXTRA_C_FLAGS) $< -o $@
@echo "CC <= $@"