Exemplo n.º 1
0
def send_and_compare_result(app_client, url, body_data, expect_file=None, method='post', full_url=False):
    """Send and compare result."""
    res = get_request_result(app_client, url, body_data, method=method, full_url=full_url)
    delete_random_items(res)
    if expect_file:
        real_path = os.path.join(DEBUGGER_EXPECTED_RESULTS, 'restful_results', expect_file)
        compare_result_with_file(res, real_path)
    def test_get_timeline_summary(self, device_target, filename):
        """Test the function of get timeline summary data for UI display."""
        file_path = os.path.join(self.profiler,
                                 filename.format(self.device_id))

        result = self._analyser.get_timeline_summary(device_target)
        compare_result_with_file(result, file_path)
 def test_search_nodes_by_type(self, node_type, condition, result_file):
     """Test search nodes by type."""
     result = self.graph_handler.search_nodes({
         'node_category': node_type,
         'condition': condition,
         'graph_name': 'kernel_graph_0'
     })
     file_path = os.path.join(self.graph_results_dir, result_file)
     compare_result_with_file(result, file_path)
Exemplo n.º 4
0
 def test_search_nodes_by_type(self, node_type, condition, result_file):
     """Test search nodes by type."""
     search_nodes = self.graph_handler.get_searched_node_list(
         {
             'node_category': node_type,
             'condition': condition
         }, 'kernel_graph_0')
     file_path = os.path.join(self.graph_results_dir, result_file)
     result = {'node_names': [node.name for node in search_nodes]}
     compare_result_with_file(result, file_path)
    def test_get_display_timeline(self):
        """Test the function of get timeline detail data for UI display."""
        gpu_file_path = os.path.join(
            self.profiler, self.gpu_display_filename.format(self.device_id))
        ascend_file_path = os.path.join(
            self.profiler, self.ascend_display_filename.format(self.device_id))

        result = self._analyser.get_display_timeline("gpu", 0)
        compare_result_with_file(result, gpu_file_path)

        result = self._analyser.get_display_timeline("ascend", 0)
        compare_result_with_file(result, ascend_file_path)
Exemplo n.º 6
0
def compare_debugger_result_with_file(res, expect_file, save=False):
    """
    Compare debugger result with file.

    Args:
        res (dict): The debugger result in dict type.
        expect_file: The expected file name.
    """
    real_path = os.path.join(DEBUGGER_EXPECTED_RESULTS, expect_file)
    if save:
        with open(real_path, 'w') as file_handler:
            json.dump(res, file_handler)
    else:
        compare_result_with_file(res, real_path)
Exemplo n.º 7
0
 def test_load_device_info_ascend(self):
     """Test load_device_info of ascend chip for offline-debugger."""
     res = self.data_loader_ascend.load_device_info()
     expected_result = os.path.join(self.expected_results_dir, 'load_device_info_ascend.json')
     compare_result_with_file(res, expected_result)
Exemplo n.º 8
0
 def test_get(self, filter_condition, result_file):
     """Test get."""
     reply = self.handler.get(filter_condition)
     file_path = os.path.join(self.results_dir, result_file)
     compare_result_with_file(reply, file_path)
Exemplo n.º 9
0
 def test_get_without_filter(self, filter_condition, result_file):
     """Test get with filer_condition is False."""
     file_path = os.path.join(self.results_dir, result_file)
     reply = self.handler.get(filter_condition)
     watch_points = reply.get('watch_points')
     compare_result_with_file(watch_points, file_path)
Exemplo n.º 10
0
 def test_search_nodes(self, pattern, result_file):
     """Test search nodes."""
     result = self.graph_handler.search_nodes({'name': pattern})
     file_path = os.path.join(self.graph_results_dir, result_file)
     compare_result_with_file(result, file_path)
Exemplo n.º 11
0
 def test_get_tensor_history(self, node_name, result_file):
     """Test get tensor history."""
     result = self.graph_handler.get_tensor_history(node_name)
     file_path = os.path.join(self.graph_results_dir, result_file)
     compare_result_with_file(result, file_path)
Exemplo n.º 12
0
 def test_get(self, filter_condition, result_file):
     """Test get."""
     result = self.graph_handler.get(filter_condition)
     file_path = os.path.join(self.graph_results_dir, result_file)
     compare_debugger_result_with_file(result, file_path, True)
     compare_result_with_file(result, file_path)