0001
0002
0003
0004
0005
0006 #include <signal.h>
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 #include <stdbool.h>
0010 #include <sys/types.h>
0011 #include <sys/wait.h>
0012 #include <unistd.h>
0013
0014 #include "ebb.h"
0015
0016
0017
0018
0019
0020
0021
0022 static int setup_child_event(struct event *event, pid_t child_pid)
0023 {
0024 event_init_named(event, 0x400FA, "PM_RUN_INST_CMPL");
0025
0026 event->attr.exclude_kernel = 1;
0027 event->attr.exclude_hv = 1;
0028 event->attr.exclude_idle = 1;
0029
0030 FAIL_IF(event_open_with_pid(event, child_pid));
0031 FAIL_IF(event_enable(event));
0032
0033 return 0;
0034 }
0035
0036 int task_event_vs_ebb(void)
0037 {
0038 union pipe read_pipe, write_pipe;
0039 struct event event;
0040 pid_t pid;
0041 int rc;
0042
0043 SKIP_IF(!ebb_is_supported());
0044
0045 FAIL_IF(pipe(read_pipe.fds) == -1);
0046 FAIL_IF(pipe(write_pipe.fds) == -1);
0047
0048 pid = fork();
0049 if (pid == 0) {
0050
0051 exit(ebb_child(write_pipe, read_pipe));
0052 }
0053
0054
0055 rc = setup_child_event(&event, pid);
0056 if (rc) {
0057 kill_child_and_wait(pid);
0058 return rc;
0059 }
0060
0061
0062 if (sync_with_child(read_pipe, write_pipe))
0063
0064 goto wait;
0065
0066
0067 FAIL_IF(sync_with_child(read_pipe, write_pipe));
0068
0069 wait:
0070
0071 FAIL_IF(wait_for_child(pid));
0072 FAIL_IF(event_disable(&event));
0073 FAIL_IF(event_read(&event));
0074
0075 event_report(&event);
0076
0077
0078
0079 return 0;
0080 }
0081
0082 int main(void)
0083 {
0084 return test_harness(task_event_vs_ebb, "task_event_vs_ebb");
0085 }