// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
cmpq $0x0, 0x98(%rsi)
je 0xccd6
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x128(%rbp), %rdx
orq $-0x1, (%rdx)
pushq $0x3
popq %rsi
leaq -0x29(%rbp), %rcx
callq 0xd8e6
leaq -0x128(%rbp), %rdi
callq 0x827c
movl $0x1, -0x128(%rbp)
callq 0x5540
movq %rax, %r12
leaq -0xb0(%rbp), %rdi
movq %r13, %rsi
callq 0x5580
leaq 0x56f1(%rip), %rsi      # 0x12202
leaq -0x90(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x51c0
leaq -0xb0(%rbp), %rsi
leaq -0x90(%rbp), %rdx
movq %r14, %rdi
callq 0xc938
movl %eax, %r13d
leaq -0x90(%rbp), %rdi
callq 0x58a8
leaq -0xb0(%rbp), %rdi
callq 0x58a8
testl %r13d, %r13d
jne 0xcba2
leaq 0x50(%r14), %rsi
leaq -0x70(%rbp), %rdi
callq 0x5580
leaq 0x5647(%rip), %rsi      # 0x121b2
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x51c0
leaq -0x70(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movq %r14, %rdi
callq 0xc938
movl %eax, %r13d
leaq -0x50(%rbp), %rdi
callq 0x58a8
leaq -0x70(%rbp), %rdi
callq 0x58a8
testl %r13d, %r13d
je 0xcbd4
leaq -0xf8(%rbp), %rdi
movl $0x80, %esi
callq 0x8122
leaq -0x128(%rbp), %rdi
callq 0xd968
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xd3e5(%rip), %rdi      # 0x19fc0
leaq 0x559c(%rip), %rsi      # 0x1217e
callq 0x5480
movq %rax, %rdi
callq 0x5240
leaq 0x4737(%rip), %rdi      # 0x1132d
callq 0x53e0
leaq 0x55ad(%rip), %rdi      # 0x121af
callq 0x53e0
leaq 0x55af(%rip), %rdi      # 0x121bd
callq 0x53e0
movq 0xd3a6(%rip), %rdi      # 0x19fc0
leaq 0x55aa(%rip), %rsi      # 0x121cb
callq 0x5480
movq %rax, %rdi
callq 0x5240
leaq 0x55b9(%rip), %rdi      # 0x121ee
callq 0x53e0
callq 0x5540
movq %rax, %r13
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0xd946
movq %rax, %rcx
subq %r12, %r13
movl $0xf4240, %esi          # imm = 0xF4240
movq %r13, %rax
cqto
idivq %rsi
movq %rax, (%rcx)
callq 0x5540
movq %rax, %r12
movq %r14, %rdi
callq 0xcd5a
testb %al, %al
jne 0xcc86
leaq -0x120(%rbp), %rdi
pushq $0x40
popq %rsi
callq 0x7ffc
callq 0x5540
movq %rax, %r13
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xd946
movq %rax, %rcx
subq %r12, %r13
movl $0xf4240, %esi          # imm = 0xF4240
movq %r13, %rax
cqto
idivq %rsi
movq %rax, (%rcx)
leaq -0x128(%rbp), %rdi
movq %r15, %rsi
callq 0x8354
movq 0x98(%r14), %rdi
leaq -0x128(%rbp), %rsi
callq 0x857a
jmp 0xcbb3
leaq 0x5443(%rip), %rdi      # 0x12120
leaq 0x5341(%rip), %rsi      # 0x12025
leaq 0x5451(%rip), %rcx      # 0x1213c
movl $0xa4, %edx
callq 0x5310
jmp 0xcd3b
jmp 0xcd3b
jmp 0xcd3b
jmp 0xcd3b
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0x58a8
jmp 0xcd0e
movq %rax, %r14
leaq -0x70(%rbp), %rdi
jmp 0xcd2f
movq %rax, %r14
leaq -0x90(%rbp), %rdi
callq 0x58a8
jmp 0xcd28
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x58a8
jmp 0xcd3e
movq %rax, %r14
jmp 0xcd4a
movq %rax, %r14
leaq -0x128(%rbp), %rdi
callq 0xd968
movq %rbx, %rdi
callq 0x763c
movq %r14, %rdi
callq 0x5780