perf tests: Fix hist accumulation test
authorJiri Olsa <jolsa@kernel.org>
Mon, 4 Jul 2016 12:16:21 +0000 (14:16 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 4 Jul 2016 22:39:01 +0000 (19:39 -0300)
User's values from .perfconfig could overload the default callchain
setup and cause this test to fail.  Making sure the test is using
default callchain_param values.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1467634583-29147-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/hists_cumulate.c
tools/perf/util/callchain.h
tools/perf/util/util.c

index a9e3db3afac423a89f589ee995433278172b019e..9fd54b79a7886266889f17f5865d69b46171cbf3 100644 (file)
@@ -216,6 +216,8 @@ static int do_test(struct hists *hists, struct result *expected, size_t nr_expec
 
                /* check callchain entries */
                root = &he->callchain->node.rb_root;
+
+               TEST_ASSERT_VAL("callchains expected", !RB_EMPTY_ROOT(root));
                cnode = rb_entry(rb_first(root), struct callchain_node, rb_node);
 
                c = 0;
@@ -666,6 +668,8 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
        perf_evsel__set_sample_bit(evsel, CALLCHAIN);
 
        setup_sorting(NULL);
+
+       callchain_param = callchain_param_default;
        callchain_register_param(&callchain_param);
 
        err = add_hist_entries(hists, machine);
index a70f6b54eb927b2836f7bdd2feab2e63fb4c130e..13e75549c4407dcf750c52e123ce3d48cc57ed2c 100644 (file)
@@ -106,6 +106,7 @@ struct callchain_param {
 };
 
 extern struct callchain_param callchain_param;
+extern struct callchain_param callchain_param_default;
 
 struct callchain_list {
        u64                     ip;
index e08b9a092a239b17096ab2c23932898b1c249fe9..5f44a21955cde0a53bb94859ddf32df55da79e3d 100644 (file)
 #include "callchain.h"
 #include "strlist.h"
 
-struct callchain_param callchain_param = {
-       .mode   = CHAIN_GRAPH_ABS,
-       .min_percent = 0.5,
-       .order  = ORDER_CALLEE,
-       .key    = CCKEY_FUNCTION,
-       .value  = CCVAL_PERCENT,
+#define CALLCHAIN_PARAM_DEFAULT                        \
+       .mode           = CHAIN_GRAPH_ABS,      \
+       .min_percent    = 0.5,                  \
+       .order          = ORDER_CALLEE,         \
+       .key            = CCKEY_FUNCTION,       \
+       .value          = CCVAL_PERCENT,        \
+
+struct callchain_param callchain_param = {
+       CALLCHAIN_PARAM_DEFAULT
+};
+
+struct callchain_param callchain_param_default = {
+       CALLCHAIN_PARAM_DEFAULT
 };
 
 /*