no_handler_test.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2014, Michael Ellerman, IBM Corp.
  3. * Licensed under GPLv2.
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <setjmp.h>
  8. #include <signal.h>
  9. #include "ebb.h"
  10. /* Test that things work sanely if we have no handler */
  11. static int no_handler_test(void)
  12. {
  13. struct event event;
  14. u64 val;
  15. int i;
  16. event_init_named(&event, 0x1001e, "cycles");
  17. event_leader_ebb_init(&event);
  18. event.attr.exclude_kernel = 1;
  19. event.attr.exclude_hv = 1;
  20. event.attr.exclude_idle = 1;
  21. FAIL_IF(event_open(&event));
  22. FAIL_IF(ebb_event_enable(&event));
  23. val = mfspr(SPRN_EBBHR);
  24. FAIL_IF(val != 0);
  25. /* Make sure it overflows quickly */
  26. sample_period = 1000;
  27. mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
  28. /* Spin to make sure the event has time to overflow */
  29. for (i = 0; i < 1000; i++)
  30. mb();
  31. dump_ebb_state();
  32. /* We expect to see the PMU frozen & PMAO set */
  33. val = mfspr(SPRN_MMCR0);
  34. FAIL_IF(val != 0x0000000080000080);
  35. event_close(&event);
  36. dump_ebb_state();
  37. /* The real test is that we never took an EBB at 0x0 */
  38. return 0;
  39. }
  40. int main(void)
  41. {
  42. return test_harness(no_handler_test,"no_handler_test");
  43. }