// File: williewillus[P]panda_scratchpad/src/utils/Tester.cpp
// Function: Tester::test_check(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_ofstream<char, std::char_traits<char>>&)
vector<milliseconds> Tester::test_check(const string device_path, ofstream &log) {
	assert(current_test_suite_ != NULL);
	vector<milliseconds> res(3, duration<int, std::milli>(-1));
	SingleTestInfo test_info;
	unsigned int test_num = 1;
	test_info.test_num = test_num++;

	// This funstion will be called after the replay i.e. 
	// the replay_device is in an unmounted state.
	//
	// So first check if the filesystem is mountable
	
	time_point<steady_clock> mount_start_time = steady_clock::now();
	if (mount_device(device_path, MNT_POINT_REPLAY) != SUCCESS) {
		test_info.fs_test.SetError(FileSystemTestResult::kKernelMount);
		return res;
	}

	if (mount_device(record_device_path, MNT_POINT_RECORD) != SUCCESS) {
		test_info.fs_test.SetError(FileSystemTestResult::kKernelMount);
		return res;
	}

	cout << "Mounted both record and replay device for checks" << endl;
	system("mount | grep pmem");
	system("ls /mnt/pmem0");
	system("ls /mnt/pmem1");
	cout << "Checking using system diff command" << endl;
	system("diff -qr /mnt/pmem0 /mnt/pmem1");


	time_point<steady_clock> mount_end_time = steady_clock::now();
	res.at(2) = duration_cast<milliseconds>(mount_end_time - mount_start_time);	

	// Once mounted, begin testing
	time_point<steady_clock> test_case_start_time = steady_clock::now();
	bool retVal = check_disk_and_snapshot_contents();
	if (!retVal) {
		test_info.data_test.SetError(tests::DataTestResult::kAutoCheckFailed);
	} 
	time_point<steady_clock> test_case_end_time = steady_clock::now();
	res.at(1) = duration_cast<milliseconds>(test_case_end_time - test_case_start_time);

	test_info.PrintResults(log);
	current_test_suite_->TallyTimingResult(test_info);
	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdx, -0x1c8(%rbp)
movq %rdi, -0x1c0(%rbp)
movq %rdi, %rax
movq %rax, -0x1b8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1b0(%rbp)
cmpq $0x0, 0x98(%rax)
je 0x1a31a
jmp 0x1a339
leaq 0xaff0(%rip), %rdi      # 0x25311
leaq 0xaeee(%rip), %rsi      # 0x25216
movl $0xa4, %edx
leaq 0xaff9(%rip), %rcx      # 0x2532d
callq 0x6390
movb $0x0, -0x21(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
leaq -0x34(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x1c510
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x1c530
leaq -0x39(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x1c570
movq -0x1c0(%rbp), %rdi
movq -0x1d8(%rbp), %rdx
movq -0x1d0(%rbp), %rcx
movl $0x3, %esi
callq 0x1c590
jmp 0x1a3a0
leaq -0x39(%rbp), %rdi
callq 0xad90
leaq -0xc8(%rbp), %rdi
callq 0xd220
jmp 0x1a3b7
movl $0x1, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, %ecx
incl %ecx
movl %ecx, -0xcc(%rbp)
movl %eax, -0xc8(%rbp)
callq 0x6620
movq -0x1c8(%rbp), %rsi
movq %rax, -0xd8(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x6240
jmp 0x1a3f8
leaq -0x119(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x68b0
movq -0x1e8(%rbp), %rdx
leaq 0xafda(%rip), %rsi      # 0x253f3
leaq -0x118(%rbp), %rdi
callq 0x6670
jmp 0x1a427
movq -0x1b0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x1a010
movl %eax, -0x1ec(%rbp)
jmp 0x1a449
leaq -0x118(%rbp), %rdi
callq 0x69d8
leaq -0x119(%rbp), %rdi
callq 0x6590
leaq -0xf8(%rbp), %rdi
callq 0x69d8
movl -0x1ec(%rbp), %eax
cmpl $0x0, %eax
je 0x1a521
leaq -0x98(%rbp), %rdi
movl $0x80, %esi
callq 0xcfc0
jmp 0x1a48f
movb $0x1, -0x21(%rbp)
movl $0x1, -0x120(%rbp)
jmp 0x1a84d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0xad90
jmp 0x1a897
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1a88b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1a861
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1a504
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x69d8
leaq -0x119(%rbp), %rdi
callq 0x6590
leaq -0xf8(%rbp), %rdi
callq 0x69d8
jmp 0x1a861
movq -0x1b0(%rbp), %rsi
addq $0x50, %rsi
leaq -0x140(%rbp), %rdi
callq 0x6240
jmp 0x1a53a
leaq -0x161(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x68b0
movq -0x1f8(%rbp), %rdx
leaq 0xae48(%rip), %rsi      # 0x253a3
leaq -0x160(%rbp), %rdi
callq 0x6670
jmp 0x1a569
movq -0x1b0(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x160(%rbp), %rdx
callq 0x1a010
movl %eax, -0x1fc(%rbp)
jmp 0x1a58b
leaq -0x160(%rbp), %rdi
callq 0x69d8
leaq -0x161(%rbp), %rdi
callq 0x6590
leaq -0x140(%rbp), %rdi
callq 0x69d8
movl -0x1fc(%rbp), %eax
cmpl $0x0, %eax
je 0x1a623
leaq -0x98(%rbp), %rdi
movl $0x80, %esi
callq 0xcfc0
jmp 0x1a5cd
movb $0x1, -0x21(%rbp)
movl $0x1, -0x120(%rbp)
jmp 0x1a84d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1a606
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x69d8
leaq -0x161(%rbp), %rdi
callq 0x6590
leaq -0x140(%rbp), %rdi
callq 0x69d8
jmp 0x1a861
movq 0x1a996(%rip), %rdi     # 0x34fc0
leaq 0xad3e(%rip), %rsi      # 0x2536f
callq 0x6520
movq %rax, -0x208(%rbp)
jmp 0x1a63f
movq -0x208(%rbp), %rdi
movq 0x1a94b(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1a654
leaq 0x9d82(%rip), %rdi      # 0x243dd
callq 0x6470
jmp 0x1a662
leaq 0xad37(%rip), %rdi      # 0x253a0
callq 0x6470
jmp 0x1a670
leaq 0xad37(%rip), %rdi      # 0x253ae
callq 0x6470
jmp 0x1a67e
movq 0x1a93b(%rip), %rdi     # 0x34fc0
leaq 0xad30(%rip), %rsi      # 0x253bc
callq 0x6520
movq %rax, -0x210(%rbp)
jmp 0x1a69a
movq -0x210(%rbp), %rdi
movq 0x1a8f0(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1a6af
leaq 0xad29(%rip), %rdi      # 0x253df
callq 0x6470
jmp 0x1a6bd
callq 0x6620
movq %rax, -0x170(%rbp)
leaq -0x170(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x1c640
movq %rax, -0x218(%rbp)
jmp 0x1a6e5
movq -0x218(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x1c610
movq %rax, -0x220(%rbp)
jmp 0x1a708
movq -0x1c0(%rbp), %rdi
movq -0x220(%rbp), %rax
movq %rax, -0x178(%rbp)
movl $0x2, %esi
callq 0x1c690
movq %rax, -0x228(%rbp)
jmp 0x1a730
movq -0x228(%rbp), %rax
movq -0x178(%rbp), %rcx
movq %rcx, (%rax)
callq 0x6620
movq -0x1b0(%rbp), %rdi
movq %rax, -0x188(%rbp)
callq 0x1a8a0
movb %al, -0x229(%rbp)
jmp 0x1a761
movb -0x229(%rbp), %al
andb $0x1, %al
movb %al, -0x189(%rbp)
testb $0x1, -0x189(%rbp)
jne 0x1a78d
leaq -0xc0(%rbp), %rdi
movl $0x40, %esi
callq 0xcdd0
jmp 0x1a78b
jmp 0x1a78d
callq 0x6620
movq %rax, -0x198(%rbp)
leaq -0x198(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x1c640
movq %rax, -0x238(%rbp)
jmp 0x1a7b5
movq -0x238(%rbp), %rax
movq %rax, -0x1a8(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x1c610
movq %rax, -0x240(%rbp)
jmp 0x1a7d8
movq -0x1c0(%rbp), %rdi
movq -0x240(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movl $0x1, %esi
callq 0x1c690
movq %rax, -0x248(%rbp)
jmp 0x1a800
movq -0x248(%rbp), %rax
movq -0x1a0(%rbp), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0xd360
jmp 0x1a823
movq -0x1b0(%rbp), %rax
movq 0x98(%rax), %rdi
leaq -0xc8(%rbp), %rsi
callq 0xd710
jmp 0x1a83f
movb $0x1, -0x21(%rbp)
movl $0x1, -0x120(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x1c6d0
testb $0x1, -0x21(%rbp)
jne 0x1a87b
jmp 0x1a86f
leaq -0xc8(%rbp), %rdi
callq 0x1c6d0
jmp 0x1a88b
movq -0x1c0(%rbp), %rdi
callq 0x9f20
movq -0x1b8(%rbp), %rax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
movq -0x1c0(%rbp), %rdi
callq 0x9f20
movq -0x48(%rbp), %rdi
callq 0x68a0