Skip to content

Commit

Permalink
Added regression tests for avast/retdec#428 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
metthal committed Nov 20, 2018
1 parent 72c5da5 commit bcbc43d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 1 addition & 2 deletions tools/fileinfo/features/hashes/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,4 @@ def test_correctly_computes_export_hash(self):

self.assertEqual(self.fileinfo.output['exportTable']['crc32'], 'b4a8ec08')
self.assertEqual(self.fileinfo.output['exportTable']['md5'], '69c3263d43b9c3a5fad072fd81519e50')
self.assertEqual(self.fileinfo.output['exportTable']['sha256'], 'b59f469f07123abee30e93a83e8b8908ed7faa8b140dba0093204b6b3efd541c')

self.assertEqual(self.fileinfo.output['exportTable']['sha256'], 'b59f469f07123abee30e93a83e8b8908ed7faa8b140dba0093204b6b3efd541c')
20 changes: 19 additions & 1 deletion tools/fileinfo/features/typerefs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,63 @@ class TestTypeRefNested(Test):
args='--verbose --json'
)

def test_correctly_analyzes_typerefs_default(self):
def test_correctly_analyzes_typerefs_nested(self):
assert self.fileinfo.succeeded

self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][0]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][0]['name'], 'CompilationRelaxationsAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][0]['nameSpace'], 'System.Runtime.CompilerServices')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][1]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][1]['name'], 'RuntimeCompatibilityAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][1]['nameSpace'], 'System.Runtime.CompilerServices')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][2]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][2]['name'], 'DebuggableAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][2]['nameSpace'], 'System.Diagnostics')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][3]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][3]['name'], 'DebuggingModes.DebuggableAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][3]['nameSpace'], 'System.Diagnostics')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][4]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][4]['name'], 'TargetFrameworkAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][4]['nameSpace'], 'System.Runtime.Versioning')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][5]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][5]['name'], 'AssemblyCompanyAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][5]['nameSpace'], 'System.Reflection')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][6]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][6]['name'], 'AssemblyConfigurationAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][6]['nameSpace'], 'System.Reflection')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][7]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][7]['name'], 'AssemblyFileVersionAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][7]['nameSpace'], 'System.Reflection')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][8]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][8]['name'], 'AssemblyInformationalVersionAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][8]['nameSpace'], 'System.Reflection')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][9]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][9]['name'], 'AssemblyProductAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][9]['nameSpace'], 'System.Reflection')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][10]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][10]['name'], 'AssemblyTitleAttribute')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][10]['nameSpace'], 'System.Reflection')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][11]['libraryName'], 'System.Runtime')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][11]['name'], 'Object')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][11]['nameSpace'], 'System')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][12]['libraryName'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][12]['name'], 'CustomClass1')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][12]['nameSpace'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][13]['libraryName'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][13]['name'], 'CustomClass2')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][13]['nameSpace'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][14]['libraryName'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][14]['name'], 'CustomSubClassA.CustomClass1')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][14]['nameSpace'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][15]['libraryName'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][15]['name'], 'CustomSubClassB.CustomClass2')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][15]['nameSpace'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][16]['libraryName'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][16]['name'], 'CustomSubSubClassX.CustomSubClassB.CustomClass2')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][16]['nameSpace'], 'CustomLibrary')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][17]['libraryName'], 'System.Console')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][17]['name'], 'Console')
self.assertEqual(self.fileinfo.output['dotnetInfo']['typeRefTable']['types'][17]['nameSpace'], 'System')

def test_correctly_computes_typeref_hash(self):
assert self.fileinfo.succeeded
Expand Down

0 comments on commit bcbc43d

Please sign in to comment.