Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions test/tap/test_helpers/test_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ int test_init_query_cache() {
return 0;
}

// The Query_Cache constructor registers Prometheus metrics via
// GloVars.prometheus_registry. Provide a real registry so the
// constructor doesn't crash on nullptr dereference.
if (GloVars.prometheus_registry == nullptr) {
GloVars.prometheus_registry = std::make_shared<prometheus::Registry>();
}

GloMyQC = new MySQL_Query_Cache();
GloPgQC = new PgSQL_Query_Cache();

Expand Down
7 changes: 6 additions & 1 deletion test/tap/tests/unit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ $(ODIR)/test_init.o: $(TEST_HELPERS_DIR)/test_init.cpp | $(ODIR)
# Unit test targets
# ===========================================================================

UNIT_TESTS := smoke_test-t
UNIT_TESTS := smoke_test-t query_cache_unit-t

.PHONY: all
all: $(UNIT_TESTS)
Expand All @@ -250,6 +250,11 @@ smoke_test-t: smoke_test-t.cpp $(TEST_HELPERS_OBJ) $(LIBPROXYSQLAR)
$(LIBPROXYSQLAR_FULL) $(STATIC_LIBS) $(MYLIBS) \
$(ALLOW_MULTI_DEF) -o $@

query_cache_unit-t: query_cache_unit-t.cpp $(TEST_HELPERS_OBJ) $(LIBPROXYSQLAR)
$(CXX) $< $(TEST_HELPERS_OBJ) $(IDIRS) $(LDIRS) $(OPT) \
$(LIBPROXYSQLAR_FULL) $(STATIC_LIBS) $(MYLIBS) \
$(ALLOW_MULTI_DEF) -o $@


# ===========================================================================
# Clean
Expand Down
Loading