Esempio n. 1
0
    def test_tracing_bootstrap(self):
        workq_event_path = FT_EVENT_DIR + "workqueue/enable"
        permitted_files = {workq_event_path: "0", FT_TRACE: "x"}
        io_interface = make_test_io_interface(permitted_files)
        systrace_cmd = SYSTRACE_HOST_CMD_DEFAULT + ["workq"]
        options, categories = run_systrace.parse_options(systrace_cmd)
        agent = ftrace_agent.FtraceAgent(io_interface)
        self.assertEqual(['workq'], agent._avail_categories())

        # confirm tracing is enabled, buffer is cleared
        agent.StartAgentTracing(options, categories, 10)
        self.assertEqual(permitted_files[FT_TRACE_ON], "1")
        self.assertEqual(permitted_files[FT_TRACE], "")

        # fill in file with dummy contents
        dummy_trace = "trace_contents"
        permitted_files[FT_TRACE] = dummy_trace

        # confirm tracing is disabled
        agent.StopAgentTracing(10)
        agent.GetResults(30)
        self.assertEqual(permitted_files[FT_TRACE_ON], "0")

        # confirm trace is expected, and read from fs
        self.assertEqual(agent.GetResults(30).raw_data, dummy_trace)

        # confirm buffer size is reset to 1
        self.assertEqual(permitted_files[FT_BUFFER_SIZE], "1")
Esempio n. 2
0
  def test_tracing_bootstrap(self):
    workq_event_path = FT_EVENT_DIR + "workqueue/enable"
    permitted_files = {
      workq_event_path: "0",
      FT_TRACE: "x"
    }
    io_interface = make_test_io_interface(permitted_files)
    systrace_cmd = SYSTRACE_HOST_CMD_DEFAULT + ["workq"]
    options, categories = run_systrace.parse_options(systrace_cmd)
    agent = ftrace_agent.FtraceAgent(io_interface)
    self.assertEqual(['workq'], agent._avail_categories())

    # confirm tracing is enabled, buffer is cleared
    agent.StartAgentTracing(options, categories, 10)
    self.assertEqual(permitted_files[FT_TRACE_ON], "1")
    self.assertEqual(permitted_files[FT_TRACE], "")

    # fill in file with dummy contents
    dummy_trace = "trace_contents"
    permitted_files[FT_TRACE] = dummy_trace

    # confirm tracing is disabled
    agent.StopAgentTracing(10)
    agent.GetResults(30)
    self.assertEqual(permitted_files[FT_TRACE_ON], "0")

    # confirm trace is expected, and read from fs
    self.assertEqual(agent.GetResults(30).raw_data, dummy_trace)

    # confirm buffer size is reset to 1
    self.assertEqual(permitted_files[FT_BUFFER_SIZE], "1")
Esempio n. 3
0
 def test_buffer_size(self):
     systrace_cmd = SYSTRACE_HOST_CMD_DEFAULT + ['-b', '16000']
     options, categories = run_systrace.parse_options(systrace_cmd)
     agent = ftrace_agent.FtraceAgent()
     agent._options = options
     agent._categories = categories
     self.assertEqual(agent._get_trace_buffer_size(), 16000)
Esempio n. 4
0
 def test_buffer_size(self):
   systrace_cmd = SYSTRACE_HOST_CMD_DEFAULT + ['-b', '16000']
   options, categories = run_systrace.parse_options(systrace_cmd)
   agent = ftrace_agent.FtraceAgent()
   agent._options = options
   agent._categories = categories
   self.assertEqual(agent._get_trace_buffer_size(), 16000)
  def test_tracing_event_enable_disable(self):
    # turn on irq tracing
    ipi_event_path = FT_EVENT_DIR + "ipi/enable"
    irq_event_path = FT_EVENT_DIR + "irq/enable"
    permitted_files = {
      ipi_event_path: "0",
      irq_event_path: "0"
    }
    io_interface = make_test_io_interface(permitted_files)
    systrace_cmd = SYSTRACE_HOST_CMD_DEFAULT + ["irq"]
    options, categories = run_systrace.parse_options(systrace_cmd)
    options.ftrace_categories = categories
    agent = ftrace_agent.FtraceAgent(io_interface)
    self.assertEqual(['irq'], agent._avail_categories())

    # confirm all the event nodes are turned on during tracing
    agent.StartAgentTracing(options)
    self.assertEqual(permitted_files[irq_event_path], "1")
    self.assertEqual(permitted_files[ipi_event_path], "1")

    # and then turned off when completed.
    agent.StopAgentTracing()
    agent.GetResults()
    self.assertEqual(permitted_files[irq_event_path], "0")
    self.assertEqual(permitted_files[ipi_event_path], "0")
Esempio n. 6
0
 def test_preprocess_trace_data(self):
   with contextlib.nested(open(ATRACE_DATA_STRIPPED, 'r'),
                          open(ATRACE_DATA_RAW, 'r')) as (f1, f2):
     atrace_data = f1.read()
     atrace_data_raw = f2.read()
     options, categories = run_systrace.parse_options(SYSTRACE_CMD)
     agent = atrace_agent.AtraceAgent()
     agent._config = options
     agent._config.atrace_categories = categories
     trace_data = agent._preprocess_trace_data(atrace_data_raw)
     self.assertEqual(atrace_data, trace_data)
Esempio n. 7
0
 def test_preprocess_trace_data(self):
     with contextlib.nested(open(ATRACE_DATA_STRIPPED, 'r'),
                            open(ATRACE_DATA_RAW, 'r')) as (f1, f2):
         atrace_data = f1.read()
         atrace_data_raw = f2.read()
         options, categories = run_systrace.parse_options(STOP_FIX_UPS)
         agent = atrace_agent.AtraceAgent()
         agent._config = options
         agent._config.atrace_categories = categories
         trace_data = agent._preprocess_trace_data(atrace_data_raw)
         self.assertEqual(atrace_data, trace_data)
Esempio n. 8
0
    def test_tracing_event_enable_disable(self):
        # turn on irq tracing
        ipi_event_path = FT_EVENT_DIR + "ipi/enable"
        irq_event_path = FT_EVENT_DIR + "irq/enable"
        permitted_files = {ipi_event_path: "0", irq_event_path: "0"}
        io_interface = make_test_io_interface(permitted_files)
        systrace_cmd = SYSTRACE_HOST_CMD_DEFAULT + ["irq"]
        options, categories = run_systrace.parse_options(systrace_cmd)
        agent = ftrace_agent.FtraceAgent(io_interface)
        self.assertEqual(['irq'], agent._avail_categories())

        # confirm all the event nodes are turned on during tracing
        agent.StartAgentTracing(options, categories, 10)
        self.assertEqual(permitted_files[irq_event_path], "1")
        self.assertEqual(permitted_files[ipi_event_path], "1")

        # and then turned off when completed.
        agent.StopAgentTracing(10)
        agent.GetResults(30)
        self.assertEqual(permitted_files[irq_event_path], "0")
        self.assertEqual(permitted_files[ipi_event_path], "0")
Esempio n. 9
0
 def test_construct_atrace_args(self):
   options, categories = run_systrace.parse_options(SYSTRACE_CMD)
   options.atrace_categories = categories
   tracer_args = atrace_agent._construct_atrace_args(options, categories)
   self.assertEqual(' '.join(TRACE_ARGS), ' '.join(tracer_args))
Esempio n. 10
0
 def test_boot(self):
   options, _ = run_systrace.parse_options(SYSTRACE_BOOT_CMD)
   tracer_args = atrace_agent._construct_boot_trace_command(options)
   self.assertEqual(' '.join(TRACE_BOOT_CMD), ' '.join(tracer_args))
Esempio n. 11
0
 def test_construct_atrace_args(self):
     options, categories = run_systrace.parse_options(SYSTRACE_CMD)
     options.atrace_categories = categories
     tracer_args = atrace_agent._construct_atrace_args(options, categories)
     self.assertEqual(' '.join(TRACE_ARGS), ' '.join(tracer_args))
Esempio n. 12
0
 def test_boot(self):
     options, _ = run_systrace.parse_options(SYSTRACE_BOOT_CMD)
     tracer_args = atrace_agent._construct_boot_trace_command(options)
     self.assertEqual(' '.join(TRACE_BOOT_CMD), ' '.join(tracer_args))
Esempio n. 13
0
 def test_construct_walt_args(self):
   options, _ = run_systrace.parse_options(['./run_systrace.py',
                                                     '--walt'])
   self.assertTrue(walt_agent.get_config(options).is_walt_enabled)
   options, _ = run_systrace.parse_options(['./run_systrace.py'])
   self.assertFalse(walt_agent.get_config(options).is_walt_enabled)