realizedClassGenerationCount.m 916 B

1234567891011121314151617181920212223242526272829
  1. // TEST_CONFIG
  2. #include "test.h"
  3. #include "testroot.i"
  4. #include <dlfcn.h>
  5. extern uintptr_t objc_debug_realized_class_generation_count;
  6. int main()
  7. {
  8. testassert(objc_debug_realized_class_generation_count > 0);
  9. uintptr_t prev = objc_debug_realized_class_generation_count;
  10. void *handle = dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_LAZY);
  11. testassert(handle);
  12. Class c = objc_getClass("NSFileManager");
  13. testassert(c);
  14. testassert(objc_debug_realized_class_generation_count > prev);
  15. prev = objc_debug_realized_class_generation_count;
  16. c = objc_allocateClassPair([TestRoot class], "Dynamic", 0);
  17. testassert(objc_debug_realized_class_generation_count > prev);
  18. prev = objc_debug_realized_class_generation_count;
  19. objc_registerClassPair(c);
  20. testassert(objc_debug_realized_class_generation_count == prev);
  21. succeed(__FILE__);
  22. }