summary refs log blame commit diff stats
path: root/test/all_tests.py
blob: 0c184df5d20154871240c96b291c3ecfb595e3c8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
                     














                                                                       



                                                        
 
              
          



                                                          
               
 






                                                                           
                           
#!/usr/bin/env python
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""
Run all the tests inside this directory as a test suite.
Usage: ./all_tests.py [verbosity]
"""

import os.path
import sys
rangerpath = os.path.join(os.path.dirname(__file__), '..')
if sys.path[1] != rangerpath:
	sys.path[1:1] = [rangerpath]

import unittest

if __name__ == '__main__':
	verbosity = int(sys.argv[1]) if len(sys.argv) > 1 else 1
	tests     = (fname[:-3] for fname in os.listdir(sys.path[0]) \
	             if fname[:3] == 'tc_' and fname[-3:] == '.py')
	suite     = unittest.TestLoader().loadTestsFromNames(tests)
	result    = unittest.TextTestRunner(verbosity=verbosity).run(suite)
	if len(result.errors + result.failures) > 0:
		sys.exit(1)
# compare EAX and EBX 75/jump-if-not-equal $kernel-string-equal?:false/disp8 # ++i 41/increment-ECX # ++s1 47/increment-EDI # ++s2 46/increment-ESI eb/jump $kernel-string-equal?:loop/disp8 $kernel-string-equal?:break: # return *s1 == 0 8a/copy-byte 0/mod/indirect 7/rm32/EDI . . . 0/r32/AL . . # copy byte at *EDI to AL 3d/compare-EAX-and 0/imm32 75/jump-if-not-equal $kernel-string-equal?:false/disp8 $kernel-string-equal?:true: b8/copy-to-EAX 1/imm32 eb/jump $kernel-string-equal?:end/disp8 $kernel-string-equal?:false: b8/copy-to-EAX 0/imm32 $kernel-string-equal?:end: # . restore registers 5f/pop-to-EDI 5e/pop-to-ESI 5b/pop-to-EBX 5a/pop-to-EDX 59/pop-to-ECX # . epilog 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP c3/return # - tests test-compare-null-kernel-string-with-empty-array: # EAX = kernel-string-equal?(Null-kernel-string, "") # . . push args 68/push ""/imm32 68/push Null-kernel-string/imm32 # . . call e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(EAX, 1, msg) # . . push args 68/push "F - test-compare-null-kernel-string-with-empty-array"/imm32 68/push 1/imm32/true 50/push-EAX # . . call e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP c3/return test-compare-null-kernel-string-with-non-empty-array: # EAX = kernel-string-equal?(Null-kernel-string, "Abc") # . . push args 68/push "Abc"/imm32 68/push Null-kernel-string/imm32 # . . call e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(EAX, 0, msg) # . . push args 68/push "F - test-compare-null-kernel-string-with-non-empty-array"/imm32 68/push 0/imm32/false 50/push-EAX # . . call e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP c3/return test-compare-kernel-string-with-equal-array: # EAX = kernel-string-equal?(_test-Abc-kernel-string, "Abc") # . . push args 68/push "Abc"/imm32 68/push _test-Abc-kernel-string/imm32 # . . call e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(EAX, 1, msg) # . . push args 68/push "F - test-compare-kernel-string-with-equal-array"/imm32 68/push 1/imm32/true 50/push-EAX # . . call e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP c3/return test-compare-kernel-string-with-inequal-array: # EAX = kernel-string-equal?(_test-Abc-kernel-string, "Adc") # . . push args 68/push "Adc"/imm32 68/push _test-Abc-kernel-string/imm32 # . . call e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(EAX, 0, msg) # . . push args 68/push "F - test-compare-kernel-string-with-equal-array"/imm32 68/push 0/imm32/false 50/push-EAX # . . call e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP c3/return test-compare-kernel-string-with-empty-array: # EAX = kernel-string-equal?(_test-Abc-kernel-string, "") # . . push args 68/push ""/imm32 68/push _test-Abc-kernel-string/imm32 # . . call e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(EAX, 0, msg) # . . push args 68/push "F - test-compare-kernel-string-with-equal-array"/imm32 68/push 0/imm32/false 50/push-EAX # . . call e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP c3/return test-compare-kernel-string-with-shorter-array: # EAX = kernel-string-equal?(_test-Abc-kernel-string, "Ab") # . . push args 68/push "Ab"/imm32 68/push _test-Abc-kernel-string/imm32 # . . call e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(EAX, 0, msg) # . . push args 68/push "F - test-compare-kernel-string-with-shorter-array"/imm32 68/push 0/imm32/false 50/push-EAX # . . call e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP c3/return test-compare-kernel-string-with-longer-array: # EAX = kernel-string-equal?(_test-Abc-kernel-string, "Abcd") # . . push args 68/push "Abcd"/imm32 68/push _test-Abc-kernel-string/imm32 # . . call e8/call kernel-string-equal?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP # check-ints-equal(EAX, 0, msg) # . . push args 68/push "F - test-compare-kernel-string-with-longer-array"/imm32 68/push 0/imm32/false 50/push-EAX # . . call e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP c3/return == data Null-kernel-string: 00/null _test-Abc-kernel-string: 41/A 62/b 63/c 00/null # . . vim:nowrap:textwidth=0