no_handler_test.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. SKIP_IF(!ebb_is_supported());
  17. event_init_named(&event, 0x1001e, "cycles");
  18. event_leader_ebb_init(&event);
  19. event.attr.exclude_kernel = 1;
  20. event.attr.exclude_hv = 1;
  21. event.attr.exclude_idle = 1;
  22. FAIL_IF(event_open(&event));
  23. FAIL_IF(ebb_event_enable(&event));
  24. val = mfspr(SPRN_EBBHR);
  25. FAIL_IF(val != 0);
  26. /* Make sure it overflows quickly */
  27. sample_period = 1000;
  28. mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
  29. /* Spin to make sure the event has time to overflow */
  30. for (i = 0; i < 1000; i++)
  31. mb();
  32. dump_ebb_state();
  33. /* We expect to see the PMU frozen & PMAO set */
  34. val = mfspr(SPRN_MMCR0);
  35. FAIL_IF(val != 0x0000000080000080);
  36. event_close(&event);
  37. dump_ebb_state();
  38. /* The real test is that we never took an EBB at 0x0 */
  39. return 0;
  40. }
  41. int main(void)
  42. {
  43. return test_harness(no_handler_test,"no_handler_test");
  44. }