l3_bank_test.c 784 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2014, Michael Ellerman, IBM Corp.
  3. * Licensed under GPLv2.
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include "event.h"
  8. #include "utils.h"
  9. #define MALLOC_SIZE (0x10000 * 10) /* Ought to be enough .. */
  10. /*
  11. * Tests that the L3 bank handling is correct. We fixed it in commit e9aaac1.
  12. */
  13. static int l3_bank_test(void)
  14. {
  15. struct event event;
  16. char *p;
  17. int i;
  18. p = malloc(MALLOC_SIZE);
  19. FAIL_IF(!p);
  20. event_init(&event, 0x84918F);
  21. FAIL_IF(event_open(&event));
  22. for (i = 0; i < MALLOC_SIZE; i += 0x10000)
  23. p[i] = i;
  24. event_read(&event);
  25. event_report(&event);
  26. FAIL_IF(event.result.running == 0);
  27. FAIL_IF(event.result.enabled == 0);
  28. event_close(&event);
  29. free(p);
  30. return 0;
  31. }
  32. int main(void)
  33. {
  34. return test_harness(l3_bank_test, "l3_bank_test");
  35. }