aboutsummaryrefslogtreecommitdiffstats
path: root/capstone/suite/regress
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /capstone/suite/regress
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'capstone/suite/regress')
-rw-r--r--capstone/suite/regress/LICENSE30
-rw-r--r--capstone/suite/regress/Makefile10
-rw-r--r--capstone/suite/regress/invalid_read_in_print_operand.c14
-rwxr-xr-xcapstone/suite/regress/regress.py34
4 files changed, 88 insertions, 0 deletions
diff --git a/capstone/suite/regress/LICENSE b/capstone/suite/regress/LICENSE
new file mode 100644
index 000000000..dd85900f2
--- /dev/null
+++ b/capstone/suite/regress/LICENSE
@@ -0,0 +1,30 @@
+This is the software license for Unicorn regression tests. The regression tests
+are written by several Unicorn contributors (See CREDITS.TXT) and maintained by
+Hoang-Vu Dang <dang.hvu@gmail.com>
+
+Copyright (c) 2015, Unicorn contributors
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of the developer(s) nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/capstone/suite/regress/Makefile b/capstone/suite/regress/Makefile
new file mode 100644
index 000000000..bbc73c74a
--- /dev/null
+++ b/capstone/suite/regress/Makefile
@@ -0,0 +1,10 @@
+LIBNAME = capstone
+
+invalid_read_in_print_operand: invalid_read_in_print_operand.o
+ ${CC} $< -O3 -Wall -l$(LIBNAME) -o $@
+
+%.o: %.c
+ ${CC} -c -I../../include $< -o $@
+
+clean:
+ rm -rf *.o invalid_read_in_print_operand
diff --git a/capstone/suite/regress/invalid_read_in_print_operand.c b/capstone/suite/regress/invalid_read_in_print_operand.c
new file mode 100644
index 000000000..144ae9411
--- /dev/null
+++ b/capstone/suite/regress/invalid_read_in_print_operand.c
@@ -0,0 +1,14 @@
+#include <capstone.h>
+
+#define BINARY "\x3b\x30\x62\x93\x5d\x61\x03\xe8"
+
+int main(int argc, char **argv, char **envp) {
+ csh handle;
+ if (cs_open(CS_ARCH_X86, CS_MODE_64, &handle)) {
+ printf("cs_open(…) failed\n");
+ return 1;
+ }
+ cs_insn *insn;
+ cs_disasm(handle, (uint8_t *)BINARY, sizeof(BINARY) - 1, 0x1000, 0, &insn);
+ return 0;
+}
diff --git a/capstone/suite/regress/regress.py b/capstone/suite/regress/regress.py
new file mode 100755
index 000000000..2e4f2536b
--- /dev/null
+++ b/capstone/suite/regress/regress.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+import unittest
+
+from os.path import dirname, basename, isfile
+import glob
+
+# Find all unittest type in this directory and run it.
+
+class RegressTest(unittest.TestCase):
+ pass
+
+def main():
+ unittest.main()
+
+if __name__ == '__main__':
+ directory = dirname(__file__)
+ if directory == '':
+ directory = '.'
+ modules = glob.glob(directory+"/*.py")
+ __all__ = [ basename(f)[:-3] for f in modules if isfile(f)]
+ suite = unittest.TestSuite()
+
+ for module in __all__:
+ m = __import__(module)
+ for cl in dir(m):
+ try:
+ realcl = getattr(m,cl)
+ if issubclass(realcl, unittest.TestCase):
+ suite.addTest(realcl())
+ except Exception as e:
+ pass
+
+ unittest.TextTestRunner().run(suite)