File: //usr/local/lib/python3.7/test/__pycache__/test_dtrace.cpython-37.pyc
B
��g� � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlm Z m
Z
dd� Zdd� ZG dd� d�Z
G d d
� d
e
�ZG dd� de
�ZG d
d� dej�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Zdd� Zedkr�e� dS )� N)�findfile�run_unittestc C s t j�t| dd��S )NZ
dtracedata)Zsubdir)�os�path�abspathr )�filename� r �,/usr/local/lib/python3.7/test/test_dtrace.pyr s r c C st t �dd| �} y:dd� | �� D �}|jdd� d� dd� |D �}d �|�S ttfk
rn td
�| ���Y nX dS )aM Normalize DTrace output for comparison.
DTrace keeps a per-CPU buffer, and when showing the fired probes, buffers
are concatenated. So if the operating system moves our thread around, the
straight result can be "non-causal". So we add timestamps to the probe
firing, sort by that field, then strip it from the outputz\[[0-9]+ refs\]� c S s$ g | ]}|r|� d �s|�d��qS )�#� )�
startswith�split)�.0�rowr r r �
<listcomp> s z*normalize_trace_output.<locals>.<listcomp>c S s t | d �S )Nr )�int)r r r r �<lambda> � z(normalize_trace_output.<locals>.<lambda>)�keyc S s g | ]}|d �qS )� r )r r r r r r ! s �
z&tracer produced unparseable output:
{}N) �re�sub�
splitlines�sort�join�
IndexError�
ValueError�AssertionError�format)�output�resultr r r �normalize_trace_output s
r# c @ sH e Zd ZdZdZg Zddd�Zd
dd�Zddd�Zddd �Z d
d� Z
dS )�TraceBackendNc C s\ t | jt|| j �t|d �|d��}tt|| j d ���}|�� �� }W d Q R X ||fS )Nz.py)�script_file�python_file�optimize_pythonz .expected)r# �trace_pythonr � EXTENSION�open�read�rstrip)�self�namer'