SHARE
TWEET

Untitled

a guest Nov 17th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int main(int argc, char **argv)
  2. {
  3.     uint64_t pt = alloc_page_frame();
  4.     assert(page_table_query(pt, 0xcafe) == NO_MAPPING);
  5.     page_table_update(pt, 0xcafe, 0xf00d);
  6.     assert(page_table_query(pt, 0xcafe) == 0xf00d);
  7.     page_table_update(pt, 0xcafe, 0xf00a);
  8.     assert(page_table_query(pt, 0xcafe) == 0xf00a);
  9.     page_table_update(pt, 0xcafe, 0xa01);
  10.     assert(page_table_query(pt, 0xcafe) == 0xa01);
  11.     page_table_update(pt, 0xcafe, NO_MAPPING);
  12.     assert(page_table_query(pt, 0xcafe) == NO_MAPPING);
  13.     page_table_update(pt, 0xab, 0xaa);
  14.     page_table_update(pt, 0xab, 0xac);
  15.     assert(page_table_query(pt, 0xab) == 0xac);
  16.     page_table_update(pt, 0xab, 0xaddd);
  17.     assert(page_table_query(pt, 0xab)== 0xaddd);
  18.     assert(page_table_query(pt, 0xcafa) == NO_MAPPING);
  19.     assert(page_table_query(pt, 0x0) == NO_MAPPING);
  20.     page_table_update(pt, 0xcafe, 0xf00a);
  21.     assert(page_table_query(pt, 0xcafe) == 0xf00a);
  22.     page_table_update(pt, 0xcafe, 0xf00b);
  23.     assert(page_table_query(pt, 0xcafe) == 0xf00b);
  24.     uint64_t pt2 = alloc_page_frame();
  25.     assert(page_table_query(pt2, 0xcafe) == NO_MAPPING);
  26.     page_table_update(pt2, 0xcafe, 0xf00c);
  27.     assert(page_table_query(pt2, 0xcafe) == 0xf00c);
  28.     page_table_update(pt2, 0xcafe, NO_MAPPING);
  29.     assert(page_table_query(pt2, 0xcafe) == NO_MAPPING);
  30.  
  31.     printf("All tests passed\n");
  32.  
  33.     return 0;
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top