#include "command.h"
#include "environment.h"
+#include "event_selection_set.h"
#include "get_test_data.h"
#include "test_util.h"
while (tid == 0);
ASSERT_TRUE(StatCmd()->Run({"-t", std::to_string(tid), "--in-app"}));
}
+
+TEST(stat_cmd, sample_speed_should_be_zero) {
+ EventSelectionSet set(true);
+ ASSERT_TRUE(set.AddEventType("cpu-cycles"));
+ set.AddMonitoredProcesses({getpid()});
+ ASSERT_TRUE(set.OpenEventFiles({-1}));
+ std::vector<EventAttrWithId> attrs = set.GetEventAttrWithId();
+ ASSERT_GT(attrs.size(), 0u);
+ for (auto& attr : attrs) {
+ ASSERT_EQ(attr.attr->sample_period, 0u);
+ ASSERT_EQ(attr.attr->sample_freq, 0u);
+ ASSERT_EQ(attr.attr->freq, 0u);
+ }
+}
selection->event_attr.exclude_host = event_type->exclude_host;
selection->event_attr.exclude_guest = event_type->exclude_guest;
selection->event_attr.precise_ip = event_type->precise_ip;
- if (event_type->event_type.type == PERF_TYPE_TRACEPOINT) {
- selection->event_attr.freq = 0;
- selection->event_attr.sample_period = DEFAULT_SAMPLE_PERIOD_FOR_TRACEPOINT_EVENT;
- } else {
- selection->event_attr.freq = 1;
- selection->event_attr.sample_freq =
- AdjustSampleFrequency(DEFAULT_SAMPLE_FREQ_FOR_NONTRACEPOINT_EVENT);
+ if (!for_stat_cmd_) {
+ if (event_type->event_type.type == PERF_TYPE_TRACEPOINT) {
+ selection->event_attr.freq = 0;
+ selection->event_attr.sample_period = DEFAULT_SAMPLE_PERIOD_FOR_TRACEPOINT_EVENT;
+ } else {
+ selection->event_attr.freq = 1;
+ selection->event_attr.sample_freq =
+ AdjustSampleFrequency(DEFAULT_SAMPLE_FREQ_FOR_NONTRACEPOINT_EVENT);
+ }
}
if (!IsEventAttrSupported(selection->event_attr)) {
LOG(ERROR) << "Event type '" << event_type->name