Merge branch 'cp/unit-test-reftable-stack' into ps/reftable-exclude
* cp/unit-test-reftable-stack: t-reftable-stack: add test for stack iterators t-reftable-stack: add test for non-default compaction factor t-reftable-stack: use reftable_ref_record_equal() to compare ref records t-reftable-stack: use Git's tempfile API instead of mkstemp() t: harmonize t-reftable-stack.c with coding guidelines t: move reftable/stack_test.c to the unit testing frameworkmaint
commit
d70600526e
12
Makefile
12
Makefile
|
@ -912,7 +912,6 @@ TEST_SHELL_PATH = $(SHELL_PATH)
|
||||||
LIB_FILE = libgit.a
|
LIB_FILE = libgit.a
|
||||||
XDIFF_LIB = xdiff/lib.a
|
XDIFF_LIB = xdiff/lib.a
|
||||||
REFTABLE_LIB = reftable/libreftable.a
|
REFTABLE_LIB = reftable/libreftable.a
|
||||||
REFTABLE_TEST_LIB = reftable/libreftable_test.a
|
|
||||||
|
|
||||||
GENERATED_H += command-list.h
|
GENERATED_H += command-list.h
|
||||||
GENERATED_H += config-list.h
|
GENERATED_H += config-list.h
|
||||||
|
@ -1349,6 +1348,7 @@ UNIT_TEST_PROGRAMS += t-reftable-merged
|
||||||
UNIT_TEST_PROGRAMS += t-reftable-pq
|
UNIT_TEST_PROGRAMS += t-reftable-pq
|
||||||
UNIT_TEST_PROGRAMS += t-reftable-readwrite
|
UNIT_TEST_PROGRAMS += t-reftable-readwrite
|
||||||
UNIT_TEST_PROGRAMS += t-reftable-record
|
UNIT_TEST_PROGRAMS += t-reftable-record
|
||||||
|
UNIT_TEST_PROGRAMS += t-reftable-stack
|
||||||
UNIT_TEST_PROGRAMS += t-reftable-tree
|
UNIT_TEST_PROGRAMS += t-reftable-tree
|
||||||
UNIT_TEST_PROGRAMS += t-strbuf
|
UNIT_TEST_PROGRAMS += t-strbuf
|
||||||
UNIT_TEST_PROGRAMS += t-strcmp-offset
|
UNIT_TEST_PROGRAMS += t-strcmp-offset
|
||||||
|
@ -2691,9 +2691,6 @@ REFTABLE_OBJS += reftable/stack.o
|
||||||
REFTABLE_OBJS += reftable/tree.o
|
REFTABLE_OBJS += reftable/tree.o
|
||||||
REFTABLE_OBJS += reftable/writer.o
|
REFTABLE_OBJS += reftable/writer.o
|
||||||
|
|
||||||
REFTABLE_TEST_OBJS += reftable/stack_test.o
|
|
||||||
REFTABLE_TEST_OBJS += reftable/test_framework.o
|
|
||||||
|
|
||||||
TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
|
TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
|
||||||
|
|
||||||
.PHONY: test-objs
|
.PHONY: test-objs
|
||||||
|
@ -2868,9 +2865,6 @@ $(XDIFF_LIB): $(XDIFF_OBJS)
|
||||||
$(REFTABLE_LIB): $(REFTABLE_OBJS)
|
$(REFTABLE_LIB): $(REFTABLE_OBJS)
|
||||||
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
|
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
|
||||||
|
|
||||||
$(REFTABLE_TEST_LIB): $(REFTABLE_TEST_OBJS)
|
|
||||||
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
|
|
||||||
|
|
||||||
export DEFAULT_EDITOR DEFAULT_PAGER
|
export DEFAULT_EDITOR DEFAULT_PAGER
|
||||||
|
|
||||||
Documentation/GIT-EXCLUDED-PROGRAMS: FORCE
|
Documentation/GIT-EXCLUDED-PROGRAMS: FORCE
|
||||||
|
@ -3250,7 +3244,7 @@ perf: all
|
||||||
|
|
||||||
t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
|
t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) $(UNIT_TEST_DIR)/test-lib.o
|
||||||
|
|
||||||
t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS) $(REFTABLE_TEST_LIB)
|
t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
|
||||||
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
|
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
|
||||||
|
|
||||||
check-sha1:: t/helper/test-tool$X
|
check-sha1:: t/helper/test-tool$X
|
||||||
|
@ -3711,7 +3705,7 @@ clean: profile-clean coverage-clean cocciclean
|
||||||
$(RM) git.res
|
$(RM) git.res
|
||||||
$(RM) $(OBJECTS)
|
$(RM) $(OBJECTS)
|
||||||
$(RM) headless-git.o
|
$(RM) headless-git.o
|
||||||
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
|
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB)
|
||||||
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS)
|
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS)
|
||||||
$(RM) $(TEST_PROGRAMS)
|
$(RM) $(TEST_PROGRAMS)
|
||||||
$(RM) $(FUZZ_PROGRAMS)
|
$(RM) $(FUZZ_PROGRAMS)
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2020 Google LLC
|
|
||||||
|
|
||||||
Use of this source code is governed by a BSD-style
|
|
||||||
license that can be found in the LICENSE file or at
|
|
||||||
https://developers.google.com/open-source/licenses/bsd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef REFTABLE_TESTS_H
|
|
||||||
#define REFTABLE_TESTS_H
|
|
||||||
|
|
||||||
int stack_test_main(int argc, const char **argv);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2020 Google LLC
|
|
||||||
|
|
||||||
Use of this source code is governed by a BSD-style
|
|
||||||
license that can be found in the LICENSE file or at
|
|
||||||
https://developers.google.com/open-source/licenses/bsd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "system.h"
|
|
||||||
#include "test_framework.h"
|
|
||||||
|
|
||||||
|
|
||||||
void set_test_hash(uint8_t *p, int i)
|
|
||||||
{
|
|
||||||
memset(p, (uint8_t)i, hash_size(GIT_SHA1_FORMAT_ID));
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t strbuf_add_void(void *b, const void *data, size_t sz)
|
|
||||||
{
|
|
||||||
strbuf_add(b, data, sz);
|
|
||||||
return sz;
|
|
||||||
}
|
|
||||||
|
|
||||||
int noop_flush(void *arg UNUSED)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2020 Google LLC
|
|
||||||
|
|
||||||
Use of this source code is governed by a BSD-style
|
|
||||||
license that can be found in the LICENSE file or at
|
|
||||||
https://developers.google.com/open-source/licenses/bsd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TEST_FRAMEWORK_H
|
|
||||||
#define TEST_FRAMEWORK_H
|
|
||||||
|
|
||||||
#include "system.h"
|
|
||||||
#include "reftable-error.h"
|
|
||||||
|
|
||||||
#define EXPECT_ERR(c) \
|
|
||||||
do { \
|
|
||||||
if (c != 0) { \
|
|
||||||
fflush(stderr); \
|
|
||||||
fflush(stdout); \
|
|
||||||
fprintf(stderr, "%s: %d: error == %d (%s), want 0\n", \
|
|
||||||
__FILE__, __LINE__, c, reftable_error_str(c)); \
|
|
||||||
abort(); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define EXPECT_STREQ(a, b) \
|
|
||||||
do { \
|
|
||||||
if (strcmp(a, b)) { \
|
|
||||||
fflush(stderr); \
|
|
||||||
fflush(stdout); \
|
|
||||||
fprintf(stderr, "%s:%d: %s (%s) != %s (%s)\n", __FILE__, \
|
|
||||||
__LINE__, #a, a, #b, b); \
|
|
||||||
abort(); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define EXPECT(c) \
|
|
||||||
do { \
|
|
||||||
if (!(c)) { \
|
|
||||||
fflush(stderr); \
|
|
||||||
fflush(stdout); \
|
|
||||||
fprintf(stderr, "%s: %d: failed assertion %s\n", __FILE__, \
|
|
||||||
__LINE__, #c); \
|
|
||||||
abort(); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define RUN_TEST(f) \
|
|
||||||
fprintf(stderr, "running %s\n", #f); \
|
|
||||||
fflush(stderr); \
|
|
||||||
f();
|
|
||||||
|
|
||||||
void set_test_hash(uint8_t *p, int i);
|
|
||||||
|
|
||||||
/* Like strbuf_add, but suitable for passing to reftable_new_writer
|
|
||||||
*/
|
|
||||||
ssize_t strbuf_add_void(void *b, const void *data, size_t sz);
|
|
||||||
|
|
||||||
int noop_flush(void *);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -6,16 +6,8 @@
|
||||||
#include "reftable/reftable-merged.h"
|
#include "reftable/reftable-merged.h"
|
||||||
#include "reftable/reftable-reader.h"
|
#include "reftable/reftable-reader.h"
|
||||||
#include "reftable/reftable-stack.h"
|
#include "reftable/reftable-stack.h"
|
||||||
#include "reftable/reftable-tests.h"
|
|
||||||
#include "test-tool.h"
|
#include "test-tool.h"
|
||||||
|
|
||||||
int cmd__reftable(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
/* test from simple to complex. */
|
|
||||||
stack_test_main(argc, argv);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void print_help(void)
|
static void print_help(void)
|
||||||
{
|
{
|
||||||
printf("usage: dump [-st] arg\n\n"
|
printf("usage: dump [-st] arg\n\n"
|
||||||
|
|
|
@ -26,6 +26,7 @@ static struct test_cmd cmds[] = {
|
||||||
{ "drop-caches", cmd__drop_caches },
|
{ "drop-caches", cmd__drop_caches },
|
||||||
{ "dump-cache-tree", cmd__dump_cache_tree },
|
{ "dump-cache-tree", cmd__dump_cache_tree },
|
||||||
{ "dump-fsmonitor", cmd__dump_fsmonitor },
|
{ "dump-fsmonitor", cmd__dump_fsmonitor },
|
||||||
|
{ "dump-reftable", cmd__dump_reftable },
|
||||||
{ "dump-split-index", cmd__dump_split_index },
|
{ "dump-split-index", cmd__dump_split_index },
|
||||||
{ "dump-untracked-cache", cmd__dump_untracked_cache },
|
{ "dump-untracked-cache", cmd__dump_untracked_cache },
|
||||||
{ "env-helper", cmd__env_helper },
|
{ "env-helper", cmd__env_helper },
|
||||||
|
@ -61,9 +62,7 @@ static struct test_cmd cmds[] = {
|
||||||
{ "read-graph", cmd__read_graph },
|
{ "read-graph", cmd__read_graph },
|
||||||
{ "read-midx", cmd__read_midx },
|
{ "read-midx", cmd__read_midx },
|
||||||
{ "ref-store", cmd__ref_store },
|
{ "ref-store", cmd__ref_store },
|
||||||
{ "reftable", cmd__reftable },
|
|
||||||
{ "rot13-filter", cmd__rot13_filter },
|
{ "rot13-filter", cmd__rot13_filter },
|
||||||
{ "dump-reftable", cmd__dump_reftable },
|
|
||||||
{ "regex", cmd__regex },
|
{ "regex", cmd__regex },
|
||||||
{ "repository", cmd__repository },
|
{ "repository", cmd__repository },
|
||||||
{ "revision-walking", cmd__revision_walking },
|
{ "revision-walking", cmd__revision_walking },
|
||||||
|
|
|
@ -55,7 +55,6 @@ int cmd__read_graph(int argc, const char **argv);
|
||||||
int cmd__read_midx(int argc, const char **argv);
|
int cmd__read_midx(int argc, const char **argv);
|
||||||
int cmd__ref_store(int argc, const char **argv);
|
int cmd__ref_store(int argc, const char **argv);
|
||||||
int cmd__rot13_filter(int argc, const char **argv);
|
int cmd__rot13_filter(int argc, const char **argv);
|
||||||
int cmd__reftable(int argc, const char **argv);
|
|
||||||
int cmd__regex(int argc, const char **argv);
|
int cmd__regex(int argc, const char **argv);
|
||||||
int cmd__repository(int argc, const char **argv);
|
int cmd__repository(int argc, const char **argv);
|
||||||
int cmd__revision_walking(int argc, const char **argv);
|
int cmd__revision_walking(int argc, const char **argv);
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Copyright (c) 2020 Google LLC
|
|
||||||
#
|
|
||||||
|
|
||||||
test_description='reftable unittests'
|
|
||||||
|
|
||||||
TEST_PASSES_SANITIZE_LEAK=true
|
|
||||||
. ./test-lib.sh
|
|
||||||
|
|
||||||
test_expect_success 'unittests' '
|
|
||||||
TMPDIR=$(pwd) && export TMPDIR &&
|
|
||||||
test-tool reftable
|
|
||||||
'
|
|
||||||
|
|
||||||
test_done
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue