mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
java: Added sanity checks and integrated them in CMake. Updated sample names and sample mapping.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
46996e5251
commit
40f9135412
17
tests/CMakeLists.txt
Normal file
17
tests/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
add_test (NAME check_consistency COMMAND ${PYTHON_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/check_consistency.py
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if (BUILDSWIGJAVA)
|
||||
add_test (NAME check_autoloadlibrary COMMAND ${PYTHON_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/check_autoloadlibrary.py
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_test (NAME check_samplenames COMMAND ${PYTHON_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/check_samplenames.py
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_test (NAME check_clean COMMAND ${PYTHON_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/check_clean.py
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif ()
|
44
tests/check_autoloadlibrary.py
Executable file
44
tests/check_autoloadlibrary.py
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import unittest as u
|
||||
import re, fnmatch, os
|
||||
|
||||
rootDir = '../src/'
|
||||
prefix = """
|
||||
%pragma(java) jniclasscode=%{
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary(\""""
|
||||
|
||||
sufix = """\");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. \\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
%}"""
|
||||
|
||||
class AutoLoadLibrary(u.TestCase):
|
||||
|
||||
def test_existing_snippet(self):
|
||||
broken_modules = []
|
||||
|
||||
for subdir, dirs, files in os.walk(rootDir):
|
||||
for fileName in files:
|
||||
if fnmatch.fnmatch(fileName, 'javaupm_*.i'):
|
||||
moduleName = fileName[:-2]
|
||||
snippet = prefix + moduleName + sufix
|
||||
|
||||
with open(os.path.join(subdir, fileName), "r") as f:
|
||||
if not snippet in f.read():
|
||||
broken_modules.append(moduleName)
|
||||
|
||||
self.assertEqual( len(broken_modules), 0,
|
||||
"\nThe following modules do not contain the standard auto load library code:\n" + \
|
||||
"\n".join(broken_modules) + \
|
||||
"\nConsider adding the following snippet to the SWIG interface file:\n" + \
|
||||
prefix + "<module_name>" + sufix)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
u.main()
|
35
tests/check_clean.py
Executable file
35
tests/check_clean.py
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import unittest as u
|
||||
import re, fnmatch, os
|
||||
|
||||
rootDir = '../build/src/'
|
||||
swigtypeStr = 'SWIGTYPE'
|
||||
|
||||
class Clean(u.TestCase):
|
||||
|
||||
def test_existing_swigtype(self):
|
||||
unclean = []
|
||||
|
||||
for dirName in os.listdir(rootDir):
|
||||
dirPath = os.path.join(rootDir, dirName)
|
||||
if not os.path.isdir(dirPath):
|
||||
continue
|
||||
|
||||
ok = True
|
||||
for subdir, dirs, files in os.walk(dirPath):
|
||||
if not ok:
|
||||
break
|
||||
for fileName in files:
|
||||
if swigtypeStr in fileName:
|
||||
unclean.append(dirName)
|
||||
ok = False
|
||||
break
|
||||
|
||||
self.assertEqual( len(unclean), 0,
|
||||
"\nThe following modules have unclean Java bindings:\n" + \
|
||||
"\n".join(unclean) + "\n\n" + \
|
||||
"Consider adding them to the SWIGJAVA blacklist")
|
||||
|
||||
if __name__ == '__main__':
|
||||
u.main()
|
60
tests/check_consistency.py
Executable file
60
tests/check_consistency.py
Executable file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import unittest as u
|
||||
import re, fnmatch, os
|
||||
|
||||
rootDir = '../src/'
|
||||
javaBlacklistFile = '../src/javaswig_blacklist'
|
||||
pythonBlacklistFile = '../src/pythonswig_blacklist'
|
||||
nodeBlacklistFile = '../src/nodeswig_blacklist'
|
||||
|
||||
|
||||
class BlacklistConsistency(u.TestCase):
|
||||
|
||||
def test_java_blacklist(self):
|
||||
|
||||
with open(javaBlacklistFile) as f:
|
||||
blacklist = [line.rstrip('\n') for line in f]
|
||||
|
||||
for libraryName in blacklist:
|
||||
files = os.listdir( os.path.join(rootDir, libraryName))
|
||||
interfaceFileName = "javaupm_" + libraryName + ".i"
|
||||
|
||||
if interfaceFileName in files:
|
||||
self.fail("\n" + libraryName + " is in javaswig blacklist.\n" + \
|
||||
"Remove it from blacklist or remove " + \
|
||||
interfaceFileName + " from sources.")
|
||||
|
||||
|
||||
def test_python_blacklist(self):
|
||||
|
||||
with open(pythonBlacklistFile) as f:
|
||||
blacklist = [line.rstrip('\n') for line in f]
|
||||
|
||||
for libraryName in blacklist:
|
||||
files = os.listdir( os.path.join(rootDir, libraryName))
|
||||
interfaceFileName = "pyupm_" + libraryName + ".i"
|
||||
|
||||
if interfaceFileName in files:
|
||||
self.fail("\n" + libraryName + " is in pythonswig blacklist.\n" + \
|
||||
"Remove it from blacklist or remove " + \
|
||||
interfaceFileName + " from sources.")
|
||||
|
||||
|
||||
def test_node_blacklist(self):
|
||||
|
||||
with open(nodeBlacklistFile) as f:
|
||||
blacklist = [line.rstrip('\n') for line in f]
|
||||
|
||||
for libraryName in blacklist:
|
||||
files = os.listdir( os.path.join(rootDir, libraryName))
|
||||
interfaceFileName = "jsupm_" + libraryName + ".i"
|
||||
|
||||
if interfaceFileName in files:
|
||||
self.fail("\n" + libraryName + " is in nodeswig blacklist.\n" + \
|
||||
"Remove it from blacklist or remove " + \
|
||||
interfaceFileName + " from sources.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
u.main()
|
53
tests/check_samplenames.py
Executable file
53
tests/check_samplenames.py
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import unittest as u
|
||||
import re, fnmatch, os, sys
|
||||
|
||||
sampleMappingFile = '../doxy/samples.mapping.txt'
|
||||
cSamplesDir = '../examples/c++/'
|
||||
javaSamplesDir = '../examples/java/'
|
||||
|
||||
|
||||
class SampleNames(u.TestCase):
|
||||
|
||||
def test_existing_samples(self):
|
||||
missing_c_files = []
|
||||
missing_java_files = []
|
||||
|
||||
with open (sampleMappingFile, "r") as f:
|
||||
for line in f:
|
||||
sampleNames = line.split();
|
||||
|
||||
cSampleName = sampleNames[0]
|
||||
if not cSampleName.endswith('.cxx'):
|
||||
continue
|
||||
|
||||
javaSampleName = sampleNames[1]
|
||||
if not javaSampleName.endswith('.java'):
|
||||
continue
|
||||
|
||||
ok = False
|
||||
for file in os.listdir(cSamplesDir):
|
||||
if file == cSampleName:
|
||||
ok = True
|
||||
break
|
||||
|
||||
if not ok:
|
||||
missing_c_files.append(cSampleName)
|
||||
|
||||
ok = False
|
||||
for file in os.listdir(javaSamplesDir):
|
||||
if file == javaSampleName:
|
||||
ok = True
|
||||
break
|
||||
|
||||
if not ok:
|
||||
missing_java_files.append(javaSampleName)
|
||||
|
||||
self.assertEqual( len(missing_java_files) + len(missing_c_files), 0,
|
||||
"\nThe following files are missing from samples:\n" + \
|
||||
"\n".join(missing_c_files) + "\n" + "\n".join(missing_java_files))
|
||||
|
||||
if __name__ == '__main__':
|
||||
u.main()
|
||||
|
Reference in New Issue
Block a user