aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-12 15:37:53 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-12 15:38:59 -0500
commit295246ff194b941d48a303be6766b23251110ff5 (patch)
tree19a113238337604444100ee6546109cad23c0f71
parent2e4a7019fda668090990e057d6af97d6e6c9ba75 (diff)
Add test to trace-cmd command line to test tracecmd_read_at
The trace-cmd command line does not use tracecmd_read_at, but it still needs to be tested. This allows easy access to test the tracecmd_read_at routine. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-read.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/trace-read.c b/trace-read.c
index 3baa9d8..bf01c55 100644
--- a/trace-read.c
+++ b/trace-read.c
@@ -44,6 +44,52 @@ const char *input_file = "trace.dat";
44 44
45static int filter_cpu = -1; 45static int filter_cpu = -1;
46 46
47/* Debug variables for testing tracecmd_read_at */
48#define TEST_READ_AT 0
49#if TEST_READ_AT
50static off64_t test_read_at_offset;
51static int test_read_at_copy = 100;
52static int test_read_at_index;
53static void test_read_at(struct tracecmd_input *handle)
54{
55 struct pevent *pevent;
56 struct record *record;
57 struct trace_seq s;
58 int cpu;
59
60 if (!test_read_at_offset) {
61 printf("\nNO RECORD COPIED\n");
62 return;
63 }
64
65 pevent = tracecmd_get_pevent(handle);
66
67 record = tracecmd_read_at(handle, test_read_at_offset, &cpu);
68 printf("\nHERE'S THE COPY RECORD\n");
69 trace_seq_init(&s);
70 pevent_print_event(pevent, &s, cpu, record->data, record->size, record->ts);
71 trace_seq_do_printf(&s);
72 printf("\n");
73
74 free(record);
75}
76
77static void test_read_at_save(struct record *record)
78{
79 if (test_read_at_index++ == test_read_at_copy) {
80 test_read_at_offset = record->offset;
81 printf("\nUSING THIS RECORD\n");
82 }
83}
84#else
85static void test_read_at(struct tracecmd_input *handle)
86{
87}
88static void test_read_at_save(struct record *record)
89{
90}
91#endif /* TEST_READ_AT */
92
47static void show_data(struct tracecmd_input *handle, int cpu) 93static void show_data(struct tracecmd_input *handle, int cpu)
48{ 94{
49 struct pevent *pevent; 95 struct pevent *pevent;
@@ -54,6 +100,8 @@ static void show_data(struct tracecmd_input *handle, int cpu)
54 100
55 record = tracecmd_read_data(handle, cpu); 101 record = tracecmd_read_data(handle, cpu);
56 102
103 test_read_at_save(record);
104
57 trace_seq_init(&s); 105 trace_seq_init(&s);
58 pevent_print_event(pevent, &s, cpu, record->data, record->size, record->ts); 106 pevent_print_event(pevent, &s, cpu, record->data, record->size, record->ts);
59 trace_seq_do_printf(&s); 107 trace_seq_do_printf(&s);
@@ -119,6 +167,8 @@ static void read_data_info(struct tracecmd_input *handle)
119 show_data(handle, next); 167 show_data(handle, next);
120 168
121 } while (next >= 0); 169 } while (next >= 0);
170
171 test_read_at(handle);
122} 172}
123 173
124struct tracecmd_input *read_trace_header(void) 174struct tracecmd_input *read_trace_header(void)