Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c7d5ded
feat: init integration tests
Gioee Jun 10, 2025
1137f4e
fix: optimize build commands and improve CPU utilization in Makefile
Gioee Jun 11, 2025
c52be5c
New Android PEM specific code
marcobambini Jun 11, 2025
a77b9f4
fix android cert: add new line
Gioee Jun 11, 2025
6cce7fc
Merge branch 'main' into new-integration-test
Gioee Jun 11, 2025
8d3f202
refactor: remove health-track schema and update db_init function for …
Gioee Jun 11, 2025
d091c2c
refactor: improve error handling and add in memory peers test
Gioee Jun 11, 2025
a6321d3
refactor: multi-threaded sync testing with random text insert
Gioee Jun 11, 2025
946cec2
expect sync to be gt0 only when not initializing the db
Gioee Jun 11, 2025
91b5e0e
to fix test
Gioee Jun 11, 2025
59681d1
test only 5 peers
Gioee Jun 11, 2025
2c95976
test 2 peers
Gioee Jun 11, 2025
80d384e
test: expect changes gt0 only when not initializing the db
Gioee Jun 11, 2025
237b5a7
test: low peers count
Gioee Jun 11, 2025
33b5a42
fix integration test: add windows thread handling
Gioee Jun 11, 2025
b4b04fe
fix: rename INT to INTGR in expected_type enum to avoid redeclaration…
Gioee Jun 11, 2025
4d25025
test 1 peer
Gioee Jun 12, 2025
5c0efa2
add max retry and wait time
Gioee Jun 12, 2025
180285d
increase wait time and retries
Gioee Jun 12, 2025
e6a8c0a
Merge branch 'main' into new-integration-test
Gioee Jun 12, 2025
794bbb4
Resolve cacert.h merge conflicts
Gioee Jun 12, 2025
cd355cd
test print network sync results
Gioee Jun 12, 2025
fddc7a2
sync test skip insert
Gioee Jun 12, 2025
7597559
test print network init string
Gioee Jun 12, 2025
cd21eeb
test: remove debug prints
Gioee Jun 12, 2025
118955e
test: update PEERS count and modify cloudsync_network_sync parameters
Gioee Jun 12, 2025
c46377f
test: lower peers count
Gioee Jun 12, 2025
54a08d9
test: missing close database connection after initialization
Gioee Jun 12, 2025
0a47458
linux error test
Gioee Jun 12, 2025
e60773c
revert last test commit
Gioee Jun 12, 2025
c95307e
test debug functions and settings
Gioee Jun 12, 2025
dbd2c43
test 1 peer
Gioee Jun 12, 2025
0113cf5
test 2 peer
Gioee Jun 12, 2025
687dcd5
print cloudsync_network_sync
Gioee Jun 12, 2025
2a31f26
test: disable debug flags
Gioee Jun 12, 2025
b829082
Merge branch 'main' into new-integration-test
Gioee Jun 12, 2025
9010894
test more peers
Gioee Jun 12, 2025
59377dd
final test 50 peers
Gioee Jun 12, 2025
216ce2c
remove debug network sync print
Gioee Jun 12, 2025
ac17058
test 10 peers
Gioee Jun 12, 2025
04bca1f
expect network sync to be gt0
Gioee Jun 12, 2025
afdc74b
hardcode test executables
Gioee Jun 12, 2025
01aea2d
fix makefile link pthread
Gioee Jun 12, 2025
e1f5a32
revert last commits
Gioee Jun 12, 2025
a22a971
lower peers count
Gioee Jun 12, 2025
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
16 changes: 12 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
run:
shell: bash

env:
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
APIKEY: ${{ secrets.APIKEY }}
WEBLITE: ${{ secrets.WEBLITE }}

steps:

- uses: actions/checkout@v4.2.2
Expand All @@ -62,11 +67,11 @@ jobs:

- name: windows build curl
if: matrix.os == 'windows-latest'
run: make curl/windows/libcurl.a -j4
run: make curl/windows/libcurl.a
shell: msys2 {0}

- name: build sqlite-sync
run: make extension ${{ matrix.make && matrix.make || ''}} -j4
run: make extension ${{ matrix.make && matrix.make || ''}}

- name: windows install sqlite3
if: matrix.os == 'windows-latest'
Expand Down Expand Up @@ -96,10 +101,13 @@ jobs:
echo "::endgroup::"

echo "::group::prepare the test script"
make test PLATFORM=$PLATFORM ARCH=$ARCH -j4 || echo "It should fail. Running remaining commands in the emulator"
make test PLATFORM=$PLATFORM ARCH=$ARCH || echo "It should fail. Running remaining commands in the emulator"
cat > commands.sh << EOF
mv -f /data/local/tmp/sqlite3 /system/xbin
cd /data/local/tmp
export CONNECTION_STRING="$CONNECTION_STRING"
export APIKEY="$APIKEY"
export WEBLITE="$WEBLITE"
$(make test PLATFORM=$PLATFORM ARCH=$ARCH -n)
EOF
echo "::endgroup::"
Expand All @@ -118,7 +126,7 @@ jobs:

- name: test sqlite-sync
if: matrix.name == 'linux' || matrix.name == 'windows'
run: make test -j4
run: make test

- name: test sqlite-sync + coverage
if: matrix.name == 'macos'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
*.a
unittest
/curl/src
.vscode
29 changes: 16 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ CURL_VERSION ?= 8.12.1
# Set default platform if not specified
ifeq ($(OS),Windows_NT)
PLATFORM := windows
HOST:= windows
HOST := windows
CPUS := $(shell powershell -Command "[Environment]::ProcessorCount")
else
HOST = $(shell uname -s | tr '[:upper:]' '[:lower:]')
ifeq ($(HOST),darwin)
PLATFORM := macos
CPUS := $(shell sysctl -n hw.ncpu)
else
PLATFORM := $(HOST)
CPUS := $(shell nproc)
endif
endif

# Speed up builds by using all available CPU cores
MAKEFLAGS += -j$(CPUS)

# Compiler and flags
CC = gcc
CFLAGS = -Wall -Wextra -Wno-unused-parameter -I$(SRC_DIR) -I$(SQLITE_DIR) -I$(CURL_DIR)/include
Expand All @@ -42,18 +48,14 @@ CURL_SRC = $(CURL_DIR)/src/curl-$(CURL_VERSION)
COV_DIR = coverage
CUSTOM_CSS = $(TEST_DIR)/sqliteai.css

# Files and objects
ifeq ($(PLATFORM),windows)
TEST_TARGET := $(DIST_DIR)/test.exe
else
TEST_TARGET := $(DIST_DIR)/test
endif
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
TEST_FILES = $(SRC_FILES) $(wildcard $(TEST_DIR)/*.c) $(wildcard $(SQLITE_DIR)/*.c)
TEST_SRC = $(wildcard $(TEST_DIR)/*.c)
TEST_FILES = $(SRC_FILES) $(TEST_SRC) $(wildcard $(SQLITE_DIR)/*.c)
RELEASE_OBJ = $(patsubst %.c, $(BUILD_RELEASE)/%.o, $(notdir $(SRC_FILES)))
TEST_OBJ = $(patsubst %.c, $(BUILD_TEST)/%.o, $(notdir $(TEST_FILES)))
COV_FILES = $(filter-out $(SRC_DIR)/lz4.c $(SRC_DIR)/network.c, $(SRC_FILES))
CURL_LIB = $(CURL_DIR)/$(PLATFORM)/libcurl.a
TEST_TARGET = $(patsubst %.c,$(DIST_DIR)/%$(EXE), $(notdir $(TEST_SRC)))

# Platform-specific settings
ifeq ($(PLATFORM),windows)
Expand All @@ -64,6 +66,7 @@ ifeq ($(PLATFORM),windows)
DEF_FILE := $(BUILD_RELEASE)/cloudsync.def
CFLAGS += -DCURL_STATICLIB
CURL_CONFIG = --with-schannel CFLAGS="-DCURL_STATICLIB"
EXE = .exe
else ifeq ($(PLATFORM),macos)
TARGET := $(DIST_DIR)/cloudsync.dylib
LDFLAGS += -arch x86_64 -arch arm64 -framework Security -dynamiclib -undefined dynamic_lookup
Expand All @@ -90,7 +93,7 @@ else ifeq ($(PLATFORM),android)

OPENSSL := $(BIN)/../sysroot/usr/include/openssl
CC = $(BIN)/$(ARCH)-linux-android26-clang
CURL_CONFIG = --host $(ARCH)-$(HOST)-android26 --with-openssl=$(BIN)/../sysroot/usr LIBS="-lssl -lcrypto" AR=$(BIN)/llvm-ar AS=$(BIN)/llvm-as CC=$(BIN)/$(ARCH)-linux-android26-clang CXX=$(BIN)/$(ARCH)-linux-android26-clang++ LD=$(BIN)/ld RANLIB=$(BIN)/llvm-ranlib STRIP=$(BIN)/llvm-strip
CURL_CONFIG = --host $(ARCH)-$(HOST)-android26 --with-openssl=$(BIN)/../sysroot/usr LIBS="-lssl -lcrypto" AR=$(BIN)/llvm-ar AS=$(BIN)/llvm-as CC=$(CC) CXX=$(BIN)/$(ARCH)-linux-android26-clang++ LD=$(BIN)/ld RANLIB=$(BIN)/llvm-ranlib STRIP=$(BIN)/llvm-strip
TARGET := $(DIST_DIR)/cloudsync.so
LDFLAGS += -shared -lcrypto -lssl
else ifeq ($(PLATFORM),ios)
Expand Down Expand Up @@ -146,20 +149,20 @@ endif

# Test executable
$(TEST_TARGET): $(TEST_OBJ)
$(CC) $(TEST_OBJ) -o $@ $(T_LDFLAGS)
$(CC) $(filter-out $(patsubst $(DIST_DIR)/%$(EXE),$(BUILD_TEST)/%.o, $(filter-out $@,$(TEST_TARGET))), $(TEST_OBJ)) -o $@ $(T_LDFLAGS)

# Object files
$(BUILD_RELEASE)/%.o: %.c
$(CC) $(CFLAGS) -O3 -fPIC -c $< -o $@
$(BUILD_TEST)/sqlite3.o: $(SQLITE_DIR)/sqlite3.c
$(CC) $(CFLAGS) -DSQLITE_CORE=1 -c $< -o $@
$(CC) $(CFLAGS) -DSQLITE_CORE -c $< -o $@
$(BUILD_TEST)/%.o: %.c
$(CC) $(T_CFLAGS) -c $< -o $@

# Run code coverage (--css-file $(CUSTOM_CSS))
test: $(TARGET) $(TEST_TARGET)
$(SQLITE3) ":memory:" -cmd ".bail on" ".load ./$<" "SELECT cloudsync_version();"
./$(TEST_TARGET)
set -e; for t in $(TEST_TARGET); do ./$$t; done
ifneq ($(COVERAGE),false)
mkdir -p $(COV_DIR)
lcov --capture --directory . --output-file $(COV_DIR)/coverage.info $(subst src, --include src,${COV_FILES})
Expand Down Expand Up @@ -265,7 +268,7 @@ endif

# Clean up generated files
clean:
rm -rf $(BUILD_DIRS) $(DIST_DIR)/* $(COV_DIR) *.gcda *.gcno *.gcov $(CURL_DIR)/src
rm -rf $(BUILD_DIRS) $(DIST_DIR)/* $(COV_DIR) *.gcda *.gcno *.gcov $(CURL_DIR)/src *.sqlite

# Help message
help:
Expand Down
Loading