#include #include #include #include #include MtShadowRegistry registry; void cleanup_and_exit(int status_code) { mt_cleanup_shadow_registry(®istry); } void signal_handler(int number) { printf("FAIL: The program crashed because of a memory access error!\n"); exit(-8); } int main(int argc, char **argv) { signal(SIGSEGV, &signal_handler); registry = mt_create_shadow_registry(NULL); MtShadow *original_1 = mt_create_shadow(®istry); MtShadow *lookedup_1 = mt_lookup_shadow(®istry, original_1->identifier); MtShadow *original_2 = mt_create_shadow(®istry); MtShadow *lookedup_2 = mt_lookup_shadow(®istry, original_2->identifier); if(original_1 != lookedup_1) { puts("FAIL: In test case 1, the original shadow doesn't match the looked-up one."); printf("O %p : L %p\n", original_1, lookedup_1); cleanup_and_exit(-1); } if(original_2 != lookedup_2) { puts("FAIL: In test case 2, the original shadow doesn't match the looked-up one."); printf("O %p : L %p\n", original_2, lookedup_2); cleanup_and_exit(-2); } if(original_1 == original_2) { puts("FAIL: In test case 3, the first original shadow matches the second!"); cleanup_and_exit(-3); } if(lookedup_1 == lookedup_2) { puts("FAIL: In test case 3, the first looked-up shadow matches the second!"); cleanup_and_exit(-4); } puts("Success."); cleanup_and_exit(0); return 0; }