Skip to content

Commit

Permalink
fix clang-format
Browse files Browse the repository at this point in the history
Signed-off-by: artikell <[email protected]>
  • Loading branch information
artikell committed Nov 11, 2024
1 parent 829c25e commit d0d3aa7
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 224 deletions.
35 changes: 10 additions & 25 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
ref: ${{ env.GITHUB_HEAD_REF }}
- name: make
run: make all-with-unit-tests SERVER_CFLAGS='-Werror -DSERVER_TEST'
run: make all-with-unit-tests SERVER_CFLAGS='-Werror'
- name: testprep
run: sudo apt-get install tcl8.6 tclx
- name: test
Expand All @@ -75,9 +75,6 @@ jobs:
- name: cluster tests
if: true && !contains(github.event.inputs.skiptests, 'cluster')
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
- name: legacy unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-server test all --accurate
- name: new unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-unit-tests --accurate
Expand Down Expand Up @@ -109,7 +106,7 @@ jobs:
run: |
apt-get update && apt-get install -y make gcc-13
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100
make all-with-unit-tests CC=gcc OPT=-O3 SERVER_CFLAGS='-Werror -DSERVER_TEST -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3'
make all-with-unit-tests CC=gcc OPT=-O3 SERVER_CFLAGS='-Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3'
- name: testprep
run: apt-get install -y tcl8.6 tclx procps
- name: test
Expand All @@ -124,9 +121,6 @@ jobs:
- name: cluster tests
if: true && !contains(github.event.inputs.skiptests, 'cluster')
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
- name: legacy unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-server test all --accurate
- name: new unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-unit-tests --accurate
Expand Down Expand Up @@ -234,7 +228,7 @@ jobs:
- name: make
run: |
sudo apt-get update && sudo apt-get install libc6-dev-i386
make 32bit SERVER_CFLAGS='-Werror -DSERVER_TEST'
make 32bit SERVER_CFLAGS='-Werror'
- name: testprep
run: sudo apt-get install tcl8.6 tclx
- name: test
Expand All @@ -251,9 +245,6 @@ jobs:
- name: cluster tests
if: true && !contains(github.event.inputs.skiptests, 'cluster')
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
- name: legacy unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-server test all --accurate
- name: new unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-unit-tests --accurate
Expand Down Expand Up @@ -483,7 +474,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
ref: ${{ env.GITHUB_HEAD_REF }}
- name: make
run: make valgrind SERVER_CFLAGS='-Werror -DSERVER_TEST'
run: make valgrind SERVER_CFLAGS='-Werror'
- name: testprep
run: |
sudo apt-get update
Expand Down Expand Up @@ -515,7 +506,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
ref: ${{ env.GITHUB_HEAD_REF }}
- name: make
run: make valgrind SERVER_CFLAGS='-Werror -DSERVER_TEST'
run: make valgrind SERVER_CFLAGS='-Werror'
- name: testprep
run: |
sudo apt-get update
Expand Down Expand Up @@ -552,7 +543,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
ref: ${{ env.GITHUB_HEAD_REF }}
- name: make
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE -DSERVER_TEST" SERVER_CFLAGS='-Werror'
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE" SERVER_CFLAGS='-Werror'
- name: testprep
run: |
sudo apt-get update
Expand Down Expand Up @@ -584,7 +575,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
ref: ${{ env.GITHUB_HEAD_REF }}
- name: make
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE -DSERVER_TEST" SERVER_CFLAGS='-Werror'
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE" SERVER_CFLAGS='-Werror'
- name: testprep
run: |
sudo apt-get update
Expand Down Expand Up @@ -627,7 +618,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
ref: ${{ env.GITHUB_HEAD_REF }}
- name: make
run: make all-with-unit-tests OPT=-O3 SANITIZER=address SERVER_CFLAGS='-DSERVER_TEST -Werror'
run: make all-with-unit-tests OPT=-O3 SANITIZER=address SERVER_CFLAGS='-Werror'
- name: testprep
run: |
sudo apt-get update
Expand All @@ -644,9 +635,6 @@ jobs:
- name: cluster tests
if: true && !contains(github.event.inputs.skiptests, 'cluster')
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
- name: legacy unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-server test all
- name: new unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-unit-tests
Expand Down Expand Up @@ -680,7 +668,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
ref: ${{ env.GITHUB_HEAD_REF }}
- name: make
run: make all-with-unit-tests OPT=-O3 SANITIZER=undefined SERVER_CFLAGS='-DSERVER_TEST -Werror' LUA_DEBUG=yes # we (ab)use this flow to also check Lua C API violations
run: make all-with-unit-tests OPT=-O3 SANITIZER=undefined SERVER_CFLAGS='-Werror' LUA_DEBUG=yes # we (ab)use this flow to also check Lua C API violations
- name: testprep
run: |
sudo apt-get update
Expand All @@ -697,9 +685,6 @@ jobs:
- name: cluster tests
if: true && !contains(github.event.inputs.skiptests, 'cluster')
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
- name: legacy unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-server test all --accurate
- name: new unit tests
if: true && !contains(github.event.inputs.skiptests, 'unittest')
run: ./src/valkey-unit-tests --accurate
Expand Down Expand Up @@ -1031,7 +1016,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
ref: ${{ env.GITHUB_HEAD_REF }}
- name: make
run: make SERVER_CFLAGS='-Werror -DSERVER_TEST'
run: make SERVER_CFLAGS='-Werror'

test-freebsd:
runs-on: macos-12
Expand Down
3 changes: 0 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ ifdef REDIS_LDFLAGS
endif

FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(SERVER_CFLAGS)
ifeq ($(SERVER_TEST),yes)
FINAL_CFLAGS +=-DSERVER_TEST=1
endif
FINAL_LDFLAGS=$(LDFLAGS) $(OPT) $(SERVER_LDFLAGS) $(DEBUG)
FINAL_LIBS=-lm
DEBUG=-g -ggdb
Expand Down
2 changes: 0 additions & 2 deletions src/quicklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ void quicklistRelease(quicklist *quicklist) {
/* Compress the listpack in 'node' and update encoding details.
* Returns 1 if listpack compressed successfully.
* Returns 0 if compression failed or if listpack too small to compress. */

static int __quicklistCompressNode(quicklistNode *node) {
node->attempted_compress = 1;
if (node->dont_compress) return 0;
Expand Down Expand Up @@ -248,7 +247,6 @@ static int __quicklistCompressNode(quicklistNode *node) {

/* Uncompress the listpack in 'node' and update encoding details.
* Returns 1 on successful decode, 0 on failure to decode. */

static int __quicklistDecompressNode(quicklistNode *node) {
node->attempted_compress = 0;
node->recompress = 0;
Expand Down
72 changes: 0 additions & 72 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -6781,84 +6781,12 @@ int iAmPrimary(void) {
(server.cluster_enabled && clusterNodeIsPrimary(getMyClusterNode())));
}

#ifdef SERVER_TEST
#include "testhelp.h"
#include "intset.h" /* Compact integer set structure */

int __failed_tests = 0;
int __test_num = 0;

/* The flags are the following:
* --accurate: Runs tests with more iterations.
* --large-memory: Enables tests that consume more than 100mb. */
typedef int serverTestProc(int argc, char **argv, int flags);
struct serverTest {
char *name;
serverTestProc *proc;
int failed;
} serverTests[] = {
};
serverTestProc *getTestProcByName(const char *name) {
int numtests = sizeof(serverTests) / sizeof(struct serverTest);
for (int j = 0; j < numtests; j++) {
if (!strcasecmp(name, serverTests[j].name)) {
return serverTests[j].proc;
}
}
return NULL;
}
#endif

/* Main is marked as weak so that unit tests can use their own main function. */
__attribute__((weak)) int main(int argc, char **argv) {
struct timeval tv;
int j;
char config_from_stdin = 0;

#ifdef SERVER_TEST
monotonicInit(); /* Required for dict tests, that are relying on monotime during dict rehashing. */
if (argc >= 3 && !strcasecmp(argv[1], "test")) {
int flags = 0;
for (j = 3; j < argc; j++) {
char *arg = argv[j];
if (!strcasecmp(arg, "--accurate"))
flags |= TEST_ACCURATE;
else if (!strcasecmp(arg, "--large-memory"))
flags |= TEST_LARGE_MEMORY;
else if (!strcasecmp(arg, "--valgrind"))
flags |= TEST_VALGRIND;
}

if (!strcasecmp(argv[2], "all")) {
int numtests = sizeof(serverTests) / sizeof(struct serverTest);
for (j = 0; j < numtests; j++) {
serverTests[j].failed = (serverTests[j].proc(argc, argv, flags) != 0);
}

/* Report tests result */
int failed_num = 0;
for (j = 0; j < numtests; j++) {
if (serverTests[j].failed) {
failed_num++;
printf("[failed] Test - %s\n", serverTests[j].name);
} else {
printf("[ok] Test - %s\n", serverTests[j].name);
}
}

printf("%d tests, %d passed, %d failed\n", numtests, numtests - failed_num, failed_num);

return failed_num == 0 ? 0 : 1;
} else {
serverTestProc *proc = getTestProcByName(argv[2]);
if (!proc) return -1; /* test not found */
return proc(argc, argv, flags);
}

return 0;
}
#endif

/* We need to initialize our libraries, and the server configuration. */
#ifdef INIT_SETPROCTITLE_REPLACEMENT
spt_init(argc, argv);
Expand Down
Loading

0 comments on commit d0d3aa7

Please sign in to comment.