Skip to content

Instantly share code, notes, and snippets.

@iagox86
Created November 21, 2014 21:10
Show Gist options
  • Save iagox86/6635c67f65dfb8bffb56 to your computer and use it in GitHub Desktop.
Save iagox86/6635c67f65dfb8bffb56 to your computer and use it in GitHub Desktop.
** TESTING BINARY CREATION **
++ PASSED: A binary is successfully created
++ PASSED: The binary's object is returned
-- FAILED: The binary's object is a hash (EXPECTED: Hash, RECEIVED: Binary)
++ PASSED: The binary's id value is present and numeric
++ PASSED: The binary's name is right (VALUE: Binary Test)
++ PASSED: The binary's comment is right (VALUE: Test binary)
-- FAILED: The binary's data is correct (EXPECTED: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, RECEIVED: QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE=
)
** TESTING RETRIEVING ALL BINARIES **
++ PASSED: Checking if our binary is present
** TESTING SEARCHING FOR A BINARY **
++ PASSED: The binary is successfully found
++ PASSED: The binary's object is returned
++ PASSED: The binary's object is a hash
++ PASSED: The binary's id value matches the original binary's (VALUE: 184)
++ PASSED: The binary's name maches the original binary's (VALUE: Binary Test)
++ PASSED: The binary's comment maches the original binary's (VALUE: Test binary)
++ PASSED: The binary's data maches the original binary's (VALUE: QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE=
)
** TESTING SAVING THE BINARY **
++ PASSED: A binary is successfully saved
++ PASSED: The binary's object is returned
++ PASSED: The binary's object is a hash
++ PASSED: The binary's id value matches the original binary's (VALUE: 184)
++ PASSED: The binary's name was properly updated (VALUE: new binary name)
++ PASSED: The binary's comment was properly updated (VALUE: updated comment)
++ PASSED: The binary's data maches the original binary's (VALUE: QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE=
)
** VERIFYING THE UPDATE BY RE-FETCHING THE RECORD **
++ PASSED: A binary is successfully saved
++ PASSED: The binary's object is returned
++ PASSED: The binary's object is a hash
++ PASSED: The binary's id value matches the original binary's (VALUE: 184)
++ PASSED: The binary's name was properly updated (VALUE: new binary name)
++ PASSED: The binary's comment was properly updated (VALUE: updated comment)
++ PASSED: The binary's data maches the original binary's (VALUE: QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE=
)
** CREATE A WORKSPACE **
++ PASSED: A workspace is successfully created
++ PASSED: The workspace's object is returned
++ PASSED: The workspace's object is a hash
++ PASSED: The workspace's id value is present and numeric
++ PASSED: The workspace's name is right (VALUE: test workspace)
** TESTING RETRIEVING ALL WORKSPACES **
++ PASSED: Making sure the new binary only has one workspace (VALUE: 1)
++ PASSED: Making sure the id of the retrieved workspace is right (VALUE: 166)
-- FAILED: Making sure the workspace belongs to the correct binary (EXPECTED: 184, RECEIVED: )
{:workspace_id=>166, :name=>"test workspace", :settings=>{}}
** FINDING THE WORKSPACE **
++ PASSED: A workspace is successfully found
++ PASSED: The workspace's object is returned
++ PASSED: The workspace's object is a hash
++ PASSED: The workspace's id matches the created workspace (VALUE: 166)
++ PASSED: The workspace's name matches the created workspace (VALUE: test workspace)
** UPDATING THE WORKSPACE **
++ PASSED: A workspace is successfully updated
++ PASSED: The workspace's object is returned
++ PASSED: The workspace's object is a hash
++ PASSED: The workspace's id matches the created workspace (VALUE: 166)
++ PASSED: The workspace's name was updated properly (VALUE: new name!?)
** DOING ANOTHER SEARCH FOR THE UPDATED WORKSPACE, JUST TO BE SURE **
++ PASSED: A workspace is successfully updated
++ PASSED: The workspace's object is returned
++ PASSED: The workspace's object is a hash
++ PASSED: The workspace's id matches the created workspace (VALUE: 166)
++ PASSED: The workspace's name was updated properly (VALUE: new name!?)
** CREATE A VIEW **
#<View:0x00000002a21988 @o={:name=>"test view", :view_id=>146, :revision=>1}>
++ PASSED: A view is successfully created
++ PASSED: The view's object is returned
++ PASSED: The view's object is a hash
++ PASSED: The view's id value is present and numeric
++ PASSED: The view's name is right (VALUE: test view)
++ PASSED: No segments were returned
++ PASSED: The first revision
** TESTING RETRIEVING ALL VIEWS **
++ PASSED: Making sure the new workspace only has one view (VALUE: 1)
++ PASSED: Making sure the id of the retrieved view is right (VALUE: 146)
-- FAILED: Making sure the view belongs to the correct workspace (EXPECTED: 166, RECEIVED: )
{:name=>"test view", :view_id=>146, :revision=>1}
++ PASSED: The revision hasn't changed (VALUE: 1)
** FINDING THE VIEW **
++ PASSED: A view is successfully found
++ PASSED: The view's object is returned
++ PASSED: The view's object is a hash
++ PASSED: The view's id matches the created view (VALUE: 146)
++ PASSED: The view's name matches the created view (VALUE: test view)
++ PASSED: No segments were returned
** UPDATING THE VIEW **
++ PASSED: A view is successfully updated
++ PASSED: The view's object is returned
++ PASSED: The view's object is a hash
++ PASSED: The view's id matches the created view (VALUE: 146)
++ PASSED: The view's name was updated properly (VALUE: new name!?)
++ PASSED: No segments were returned
** DOING ANOTHER SEARCH FOR THE UPDATED VIEW, JUST TO BE SURE **
++ PASSED: A view is successfully updated
++ PASSED: The view's object is returned
++ PASSED: The view's object is a hash
++ PASSED: The view's id matches the created view (VALUE: 146)
++ PASSED: The view's name was updated properly (VALUE: new name!?)
++ PASSED: No segments were returned
** CREATE SEGMENT **
++ PASSED: The segment was created
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was created
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Segment isn't returning any nodes
++ PASSED: Segment isn't returning any data
** FIND SEGMENTS (W/ DEFAULT) **
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Segment isn't returning any nodes
++ PASSED: Segment isn't returning any data
** FIND SEGMENTS (WITHOUT DATA, WITHOUT NODES) **
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Segment isn't returning any data
++ PASSED: Segment isn't returning any nodes
** FIND SEGMENTS (WITHOUT DATA, WITH NODES) **
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Segment isn't returning any data
++ PASSED: Nodes are returned as an array
** FIND SEGMENTS (WITH DATA, WITHOUT NODES **
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Data is returned as a string
-- FAILED: Checking the data returned (EXPECTED: AAAAAAAA, RECEIVED: QUFBQUFBQUE=
)
++ PASSED: Segment isn't returning any nodes
** FIND SEGMENTS (WITH DATA, WITH NODES **
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Data is returned as a string
-- FAILED: Checking the data returned (EXPECTED: AAAAAAAA, RECEIVED: QUFBQUFBQUE=
)
++ PASSED: Nodes are returned as an array
** FIND SEGMENTS (WITHOUT SEGMENTS, BECAUSE YOLO) **
++ PASSED: No segments were returned
** FIND ALL SEGMENTS **
++ PASSED: Checking if getting all segments returns exactly one segment (VALUE: 1)
** DELETING THE SEGMENT **
++ PASSED: Checking if the segment was deleted (VALUE: 0)
** TESTING UNDO (SHOULD RESTORE THE DELETED SEGMENT) **
++ PASSED: Checking if the segment was restored (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Data is returned as a string
-- FAILED: Checking the data returned (EXPECTED: AAAAAAAA, RECEIVED: AAAAAAAA
)
++ PASSED: Nodes are returned as an array
** DOUBLE-CHECKING UNDO **
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Data is returned as a string
-- FAILED: Checking the data returned (EXPECTED: AAAAAAAA, RECEIVED: AAAAAAAA
)
++ PASSED: Nodes are returned as an array
** TESTING A SECOND UNDO (SHOULD UNDO THE SEGMENT'S INITIAL CREATION) **
++ PASSED: Checking if redo returned properly
++ PASSED: Checking if redo successfully deleted the segment (VALUE: 0)
** TESTING REDO (SHOULD RESTORE THE SEGMENT) **
++ PASSED: Checking if the segment was restored (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Data is returned as a string
-- FAILED: Checking the data returned (EXPECTED: AAAAAAAA, RECEIVED: )
++ PASSED: Nodes are returned as an array
** DOUBLE-CHECKING REDO **
++ PASSED: The segment was found
++ PASSED: Only one segment was returned (VALUE: 1)
++ PASSED: The segment was found
++ PASSED: Segment has the proper name (VALUE: s1)
++ PASSED: The revision is increasing
++ PASSED: Data is returned as a string
-- FAILED: Checking the data returned (EXPECTED: AAAAAAAA, RECEIVED: )
++ PASSED: Nodes are returned as an array
** CREATING A SEGMENT TO HOPEFULLY KILL THE REDO BUFFER **
++ PASSED: Making sure there are now 2 segments (VALUE: 2)
** ATTEMPTING A REDO, WHICH SHOULD FAIL **
++ PASSED: Making sure there are still 2 segments (VALUE: 2)
++ PASSED: The first segment is still present
++ PASSED: The new segment is still present
** ATTEMPTING ANOTHER UNDO, WHICH SHOULD DELETE THE NEW SEGMENT **
{:s1=>{:name=>"s1", :revision=>7}, :deleteme=>{:name=>"deleteme", :revision=>8}}
-- FAILED: Making sure there are still 2 segments (EXPECTED: 1, RECEIVED: 2)
++ PASSED: The first segment is still present
-- FAILED: The new segment is gone (EXPECTED: nil, RECEIVED: {:name=>"deleteme", :revision=>8})
** ATTEMPTING A REDO, WHICH SHOULD RESTORE THE NEW SEGMENT **
++ PASSED: Making sure there are still 2 segments (VALUE: 2)
++ PASSED: The first segment is still present
++ PASSED: The new segment is back
** ATTEMPTING ANOTHER UNDO, WHICH SHOULD DELETE THE NEW SEGMENT *AGAIN* **
++ PASSED: Making sure we're back to one segment (VALUE: 1)
++ PASSED: The first segment is still present
++ PASSED: The new segment is gone
** ATTEMPTING A FINAL UNDO, WHICH SHOULD BRING US BACK TO THE ORIGINAL STATE **
++ PASSED: Making sure there are still 2 segments (VALUE: 0)
++ PASSED: The first segment is gone
++ PASSED: The new segment is gone
** CREATING A BRAND NEW SEGMENT TO TEST NODES IN **
++ PASSED: Checking if only the new segment exists (VALUE: 1)
++ PASSED: Checking that the segment was created
** FINDING THE SEGMENT **
++ PASSED: Checking if the segment was returned
++ PASSED: Checking if nodes are present
++ PASSED: Verifying that 8 nodes were returned (VALUE: 8)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
** CREATING A 32-BIT NODE **
++ PASSED: Checking if the new_node function returned properly
++ PASSED: Verifying that only one segment was returned (VALUE: 1)
++ PASSED: Checking if the segment was formatted properly
-- FAILED: Verifying that two nodes were returned (the node with the new xref and the original node) (EXPECTED: 2, RECEIVED: 1)
** MAKING SURE THERE ARE EXACTLY 5 NODES PRESENT **
++ PASSED: Checking if the segment was returned
++ PASSED: Checking if nodes are present
++ PASSED: Verifying that five nodes were returned (VALUE: 5)
++ PASSED: Verifying node's type (VALUE: dword)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying that the location of node 4 is correct (testing my tests, dawg) (VALUE: 4)
++ PASSED: Verifying the new node's cross reference (VALUE: 0)
** CREATING A NON-OVERLAPPING 32-BIT NODE **
++ PASSED: Checking if the new_node function returned properly
++ PASSED: Verifying that one segment was returned (VALUE: 1)
++ PASSED: Checking if the segment was formatted properly
-- FAILED: Verifying that two nodes were returned (the xref was updated again) (EXPECTED: 2, RECEIVED: 1)
** MAKING SURE BOTH NODES ARE IN GOOD SHAPE **
++ PASSED: Checking if the segment was returned
++ PASSED: Checking if nodes are present
++ PASSED: Verifying that the proper number of nodes were returned (VALUE: 2)
++ PASSED: Verifying node's type (VALUE: dword)
++ PASSED: Verifying node's type (VALUE: dword)
** CREATING AN OVERLAPPING 32-BIT NODE **
++ PASSED: Verifying the correct number of nodes were returned (VALUE: 5)
** MAKING SURE IT'S STILL IN GOOD SHAPE **
++ PASSED: Checking if the segment was returned
++ PASSED: Checking if nodes are present
++ PASSED: Verifying that the proper number of nodes were returned (VALUE: 5)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: dword)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
** UNDOING THE THIRD NODE **
++ PASSED: Checking that the right number of nodes were returned (VALUE: 2)
++ PASSED: Verifying node's type (VALUE: dword)
++ PASSED: Verifying node's type (VALUE: dword)
** UNDOING THE SECOND NODE **
++ PASSED: Checking that the right number of nodes were returned (VALUE: 4)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Checking that the right number of nodes were returned (VALUE: 5)
++ PASSED: Verifying node's type (VALUE: dword)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
** UNDOING THE FIRST NODE **
-- FAILED: Checking that the right number of nodes were returned (EXPECTED: 4, RECEIVED: 5)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Verifying that the nodes are all undefined (VALUE: undefined)
++ PASSED: Checking that the right number of nodes were returned (VALUE: 8)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
** REDO: CREATING A 32-BIT NODE **
++ PASSED: Checking if the new_node function returned properly
++ PASSED: Verifying that only one segment was returned (VALUE: 1)
++ PASSED: Checking if the segment was formatted properly
-- FAILED: Verifying that two nodes were returned (the node with the new xref and the original node) (EXPECTED: 2, RECEIVED: 1)
** MAKING SURE THERE ARE EXACTLY 5 NODES PRESENT **
++ PASSED: Checking if the segment was returned
++ PASSED: Checking if nodes are present
++ PASSED: Verifying that five nodes were returned (VALUE: 5)
++ PASSED: Verifying node's type (VALUE: dword)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying that the location of node 4 is correct (testing my tests, dawg) (VALUE: 4)
++ PASSED: Verifying the new node's cross reference (VALUE: 0)
** REDO: CREATING A NON-OVERLAPPING 32-BIT NODE **
++ PASSED: Checking if the new_node function returned properly
++ PASSED: Verifying that one segment was returned (VALUE: 1)
++ PASSED: Checking if the segment was formatted properly
-- FAILED: Verifying that two nodes were returned (the xref was updated again) (EXPECTED: 2, RECEIVED: 1)
** MAKING SURE BOTH NODES ARE IN GOOD SHAPE **
++ PASSED: Checking if the segment was returned
++ PASSED: Checking if nodes are present
++ PASSED: Verifying that the proper number of nodes were returned (VALUE: 2)
++ PASSED: Verifying node's type (VALUE: dword)
++ PASSED: Verifying node's type (VALUE: dword)
** REDO: CREATING AN OVERLAPPING 32-BIT NODE **
++ PASSED: Verifying the correct number of nodes were returned (VALUE: 5)
** MAKING SURE IT'S STILL IN GOOD SHAPE **
{:name=>"s2",
:revision=>23,
:data=>"QUJDREVGR0g=\n",
:nodes=>
[{:type=>"undefined",
:address=>0,
:length=>1,
:value=>"<undefined> 0x41 ; 'A'",
:details=>{},
:raw=>"QQ==\n",
:revision=>23,
:xrefs=>[4]},
{:type=>"undefined",
:address=>1,
:length=>1,
:value=>"<undefined> 0x42 ; 'B'",
:details=>{},
:raw=>"Qg==\n",
:revision=>23},
{:type=>"undefined",
:address=>2,
:length=>1,
:value=>"<undefined> 0x43 ; 'C'",
:details=>{},
:raw=>"Qw==\n",
:revision=>23},
{:type=>"undefined",
:address=>3,
:length=>1,
:value=>"<undefined> 0x44 ; 'D'",
:details=>{},
:raw=>"RA==\n",
:revision=>23},
{:type=>"undefined",
:address=>4,
:length=>1,
:value=>"<undefined> 0x45 ; 'E'",
:details=>{},
:raw=>"RQ==\n",
:xrefs=>nil,
:revision=>23},
{:address=>4,
:type=>"dword",
:length=>4,
:value=>"db 42424242",
:details=>{:test=>321, :test2=>"654"},
:refs=>[0],
:raw=>"RkdI\n",
:revision=>22}]}
++ PASSED: Checking if the segment was returned
++ PASSED: Checking if nodes are present
-- FAILED: Verifying that the proper number of nodes were returned (EXPECTED: 5, RECEIVED: 6)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
-- FAILED: Verifying node's type (EXPECTED: dword, RECEIVED: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
++ PASSED: Verifying node's type (VALUE: undefined)
ALL DONE! EVERYTHING IS GOOD!!!
CLEANING UP
** DELETING VIEW
#<View:0x000000029d0010 @o={:deleted=>true}>
** DELETE THE WORKSPACE
#<Workspace:0x00000002571708 @o={:deleted=>true}>
** DELETE THE BINARY
#<Binary:0x00000002591300 @o={:deleted=>true}>
Tests passed: 266 / 285 (93.33)
Tests failed: 19 / 285 (6.67)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment