Browse Source

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>
Stefan Andritoiu 9 years ago
parent
commit
40f9135412

+ 9
- 0
CMakeLists.txt View File

57
 option (BUILDSWIGJAVA "Build swig java modules" OFF)
57
 option (BUILDSWIGJAVA "Build swig java modules" OFF)
58
 option (IPK "Generate IPK using CPack" OFF)
58
 option (IPK "Generate IPK using CPack" OFF)
59
 option (RPM "Generate RPM using CPack" OFF)
59
 option (RPM "Generate RPM using CPack" OFF)
60
+option (BUILDTESTS "Generate check-ups for upm" OFF)
60
 
61
 
61
 # Find swig
62
 # Find swig
62
 if (BUILDSWIG)
63
 if (BUILDSWIG)
208
 if(BUILDJAVAEXAMPLES)
209
 if(BUILDJAVAEXAMPLES)
209
   add_subdirectory (examples/java)
210
   add_subdirectory (examples/java)
210
 endif()
211
 endif()
212
+
213
+if(BUILDTESTS)
214
+    find_package (PythonInterp REQUIRED)
215
+    if (${PYTHONINTERP_FOUND})
216
+        enable_testing ()
217
+        add_subdirectory (tests)
218
+    endif ()
219
+endif()

+ 3
- 52
doxy/samples.mapping.txt View File

1
 # Mapping C++ sample files to Java sample files
1
 # Mapping C++ sample files to Java sample files
2
 a110x-intr.cxx	A110X_intrSample.java
2
 a110x-intr.cxx	A110X_intrSample.java
3
 a110x.cxx	A110XSample.java
3
 a110x.cxx	A110XSample.java
4
-ad8232.cxx	AD8232Sample.java
5
 adc121c021.cxx	ADC121C021Sample.java
4
 adc121c021.cxx	ADC121C021Sample.java
6
-adis16448.cxx	ADIS16448Sample.java
7
-adxl335.cxx	ADXL335Sample.java
8
 adxl345.cxx	Adxl345Sample.java
5
 adxl345.cxx	Adxl345Sample.java
9
-ak8975.cxx	AK8975Sample.java
10
-am2315.cxx	AM2315Sample.java
11
-apds9002.cxx	APDS9002Sample.java
12
 biss0001.cxx	BISS0001Sample.java
6
 biss0001.cxx	BISS0001Sample.java
13
 bmpx8x.cxx	BMPX8XSample.java
7
 bmpx8x.cxx	BMPX8XSample.java
14
 buzzer-sound.cxx	Buzzer_soundSample.java
8
 buzzer-sound.cxx	Buzzer_soundSample.java
15
 cjq4435.cxx	CJQ4435Sample.java
9
 cjq4435.cxx	CJQ4435Sample.java
16
 ds1307.cxx	DS1307Sample.java
10
 ds1307.cxx	DS1307Sample.java
17
-eboled.cxx	EBOLEDSample.java
18
-ecs1030.cxx	ECS1030Sample.java
19
 enc03r.cxx	ENC03RSample.java
11
 enc03r.cxx	ENC03RSample.java
20
 es08a.cxx	ES08ASample.java
12
 es08a.cxx	ES08ASample.java
21
-flex.cxx	FlexSample.java
22
-gp2y0a.cxx	GP2Y0ASample.java
23
 grovebutton.cxx	GroveButtonSample.java
13
 grovebutton.cxx	GroveButtonSample.java
24
-grovecircularled.cxx	GroveCircularLEDSample.java
25
-grovecollision.cxx	GroveCollisionSample.java
26
 groveehr.cxx	GroveEHRSample.java
14
 groveehr.cxx	GroveEHRSample.java
27
-groveeldriver.cxx	GroveElDriverSample.java
28
-groveelectromagnet.cxx	GroveElectromagnetSample.java
29
-groveemg.cxx	GroveEMGSample.java
30
-grovegprs.cxx	GroveGPRSSample.java
31
-grovegsr.cxx	GroveGSRSample.java
32
 groveled.cxx	GroveLEDSample.java
15
 groveled.cxx	GroveLEDSample.java
33
 grovelinefinder.cxx	GroveLineFinderSample.java
16
 grovelinefinder.cxx	GroveLineFinderSample.java
34
 grovelight.cxx	GroveLightSample.java
17
 grovelight.cxx	GroveLightSample.java
35
-groveloudness.cxx	GroveLoudnessSample.java
36
 grovemoisture.cxx	GroveMoistureSample.java
18
 grovemoisture.cxx	GroveMoistureSample.java
37
-groveo2.cxx	GroveO2Sample.java
38
 groverelay.cxx	GroveRelaySample.java
19
 groverelay.cxx	GroveRelaySample.java
39
 groverotary.cxx	GroveRotarySample.java
20
 groverotary.cxx	GroveRotarySample.java
40
 grovescam.cxx	GROVESCAMSample.java
21
 grovescam.cxx	GROVESCAMSample.java
48
 hcsr04.cxx	HCSR04Sample.java
29
 hcsr04.cxx	HCSR04Sample.java
49
 hm11.cxx	HM11Sample.java
30
 hm11.cxx	HM11Sample.java
50
 hmc5883l.cxx	Hmc5883lSample.java
31
 hmc5883l.cxx	Hmc5883lSample.java
51
-hp20x.cxx	HP20XSample.java
52
-ht9170.cxx	HT9170Sample.java
53
 htu21d.cxx	HTU21DSample.java
32
 htu21d.cxx	HTU21DSample.java
54
-hx711.cxx	HX711Sample.java
55
-hyld9767.cxx	HYLD9767Sample.java
56
-ina132.cxx	INA132Sample.java
57
 itg3200.cxx	Itg3200Sample.java
33
 itg3200.cxx	Itg3200Sample.java
58
 jhd1313m1-lcd.cxx	Jhd1313m1_lcdSample.java
34
 jhd1313m1-lcd.cxx	Jhd1313m1_lcdSample.java
59
-joystick12-example.cxx	Joystick12_exampleSample.java
60
-l298-stepper.cxx	L298_stepperSample.java
61
-l298.cxx	L298Sample.java
62
-lcm1602-lcd.cxx	Lcm1602_lcdSample.java
35
+joystick12.cxx	Joystick12Sample.java
36
+lcm1602-i2c.cxx	Lcm1602_i2cSample.java
63
 ldt0028.cxx	LDT0028Sample.java
37
 ldt0028.cxx	LDT0028Sample.java
64
-lol-example.cxx	LoL_exampleSample.java
65
-lpd8806.cxx	LPD8806Sample.java
38
+lol.cxx	LoLSample.java
66
 lsm303.cxx	LSM303Sample.java
39
 lsm303.cxx	LSM303Sample.java
67
-lsm9ds0.cxx	LSM9DS0Sample.java
68
 m24lr64e.cxx	M24LR64ESample.java
40
 m24lr64e.cxx	M24LR64ESample.java
69
-max31723.cxx	MAX31723Sample.java
70
-max31855.cxx	MAX31855Sample.java
71
 max44000.cxx	MAX44000Sample.java
41
 max44000.cxx	MAX44000Sample.java
72
-max5487.cxx	MAX5487Sample.java
73
-maxds3231m.cxx	MAXDS3231MSample.java
74
-mg811.cxx	MG811Sample.java
75
 mic.cxx	MicrophoneSample.java
42
 mic.cxx	MicrophoneSample.java
76
-mlx90614.cxx	MLX90614Sample.java
77
 mma7455.cxx	MMA7455Sample.java
43
 mma7455.cxx	MMA7455Sample.java
78
 mma7660.cxx	MMA7660Sample.java
44
 mma7660.cxx	MMA7660Sample.java
79
 mpl3115a2.cxx	MPL3115A2Sample.java
45
 mpl3115a2.cxx	MPL3115A2Sample.java
80
 mpr121.cxx	MPR121Sample.java
46
 mpr121.cxx	MPR121Sample.java
81
-mpu60x0.cxx	MPU60X0Sample.java
82
 mpu9150.cxx	MPU9150Sample.java
47
 mpu9150.cxx	MPU9150Sample.java
83
-mpu9250.cxx	MPU9250Sample.java
84
 mq2.cxx	MQ2Sample.java
48
 mq2.cxx	MQ2Sample.java
85
-mq3.cxx	MQ3Sample.java
86
 mq303a.cxx	MQ303ASample.java
49
 mq303a.cxx	MQ303ASample.java
87
 mq5.cxx	MQ5Sample.java
50
 mq5.cxx	MQ5Sample.java
88
-mq9.cxx	MQ9Sample.java
89
 my9221-ledbar.cxx	MY9221_ledbarSample.java
51
 my9221-ledbar.cxx	MY9221_ledbarSample.java
90
-my9221-updown.cxx	MY9221_updownSample.java
91
-nrf24l01-broadcast.cxx	NRF24L01_broadcastSample.java
92
 nrf24l01-receiver.cxx	NRF24L01_receiverSample.java
52
 nrf24l01-receiver.cxx	NRF24L01_receiverSample.java
93
 nrf24l01-transmitter.cxx	NRF24L01_transmitterSample.java
53
 nrf24l01-transmitter.cxx	NRF24L01_transmitterSample.java
94
 nunchuck.cxx	NUNCHUCKSample.java
54
 nunchuck.cxx	NUNCHUCKSample.java
95
 otp538u.cxx	OTP538USample.java
55
 otp538u.cxx	OTP538USample.java
96
-pca9685.cxx	PCA9685Sample.java
97
-pn532-writeurl.cxx	PN532_writeurlSample.java
98
-pn532.cxx	PN532Sample.java
99
 ppd42ns.cxx	PPD42NSSample.java
56
 ppd42ns.cxx	PPD42NSSample.java
100
 pulsensor.cxx	PulsensorSample.java
57
 pulsensor.cxx	PulsensorSample.java
101
 rfr359f.cxx	RFR359FSample.java
58
 rfr359f.cxx	RFR359FSample.java
102
-rgbringcoder.cxx	RGBRingCoderSample.java
103
 rotaryencoder.cxx	RotaryEncoderSample.java
59
 rotaryencoder.cxx	RotaryEncoderSample.java
104
 rpr220-intr.cxx	RPR220_intrSample.java
60
 rpr220-intr.cxx	RPR220_intrSample.java
105
 rpr220.cxx	RPR220Sample.java
61
 rpr220.cxx	RPR220Sample.java
106
-sainsmartks.cxx	SAINSMARTKSSample.java
107
-sm130.cxx	SM130Sample.java
108
-ssd1306-oled.cxx	SSD1306_oledSample.java
109
 ssd1308-oled.cxx	SSD1308_oledSample.java
62
 ssd1308-oled.cxx	SSD1308_oledSample.java
110
 ssd1327-oled.cxx	SSD1327_oledSample.java
63
 ssd1327-oled.cxx	SSD1327_oledSample.java
111
 st7735.cxx	ST7735Sample.java
64
 st7735.cxx	ST7735Sample.java
112
 stepmotor.cxx	StepMotorSample.java
65
 stepmotor.cxx	StepMotorSample.java
113
-ta12200.cxx	TA12200Sample.java
114
 tm1637.cxx	TM1637Sample.java
66
 tm1637.cxx	TM1637Sample.java
115
 tp401.cxx	TP401Sample.java
67
 tp401.cxx	TP401Sample.java
116
 tsl2561.cxx	TSL2561Sample.java
68
 tsl2561.cxx	TSL2561Sample.java
117
 ttp223.cxx	TTP223Sample.java
69
 ttp223.cxx	TTP223Sample.java
118
 ublox6.cxx	Ublox6Sample.java
70
 ublox6.cxx	Ublox6Sample.java
119
 uln200xa.cxx	ULN200XASample.java
71
 uln200xa.cxx	ULN200XASample.java
120
-waterlevel.cxx	WaterLevelSample.java
121
 wt5001.cxx	WT5001Sample.java
72
 wt5001.cxx	WT5001Sample.java
122
 yg1006.cxx	YG1006Sample.java
73
 yg1006.cxx	YG1006Sample.java

+ 2
- 2
examples/java/CMakeLists.txt View File

61
 add_example(HP20xExample hp20x)
61
 add_example(HP20xExample hp20x)
62
 add_example(HTU21DSample htu21d)
62
 add_example(HTU21DSample htu21d)
63
 add_example(Itg3200Sample itg3200)
63
 add_example(Itg3200Sample itg3200)
64
-add_example(Joystick12_exampleSample joystick12)
64
+add_example(Joystick12Sample joystick12)
65
 add_example(LDT0028Sample ldt0028)
65
 add_example(LDT0028Sample ldt0028)
66
-add_example(LoL_exampleSample lol)
66
+add_example(LoLSample lol)
67
 add_example(LSM303Sample lsm303)
67
 add_example(LSM303Sample lsm303)
68
 add_example(M24LR64ESample m24lr64e)
68
 add_example(M24LR64ESample m24lr64e)
69
 add_example(MAX44000Sample max44000)
69
 add_example(MAX44000Sample max44000)

+ 44
- 0
examples/java/Joystick12Sample.java View File

1
+/*
2
+ * Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
3
+ * Copyright (c) 2015 Intel Corporation.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject to
11
+ * the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+public class Joystick12Sample {
26
+
27
+	public static void main(String[] args) throws InterruptedException {
28
+		//! [Interesting]
29
+		// Instantiate a joystick on analog pins A0 and A1
30
+		upm_joystick12.Joystick12 joystick = new upm_joystick12.Joystick12(0,1);
31
+
32
+		// Print the X and Y input values every second
33
+		while(true){
34
+			float x = joystick.getXInput();
35
+			float y = joystick.getYInput();
36
+
37
+			System.out.println("Driving X: " + x + " , and Y: " + y );
38
+
39
+			Thread.sleep(1000);
40
+		}
41
+		//! [Interesting]
42
+	}
43
+
44
+}

+ 47
- 0
examples/java/LoLSample.java View File

1
+/*
2
+ * Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
3
+ * Copyright (c) 2015 Intel Corporation.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject to
11
+ * the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+//NOT TESTED!!!
26
+public class LoLSample {
27
+
28
+	public static void main(String[] args) throws InterruptedException {
29
+		// ! [Interesting]
30
+		upm_lol.LoL sensor = new upm_lol.LoL();
31
+
32
+		int x = 0, y = 0;
33
+		while (true) {
34
+			// revert pixel
35
+			sensor.setPixel(x, y, sensor.getPixel(x, y));
36
+
37
+			if (++x == 13) {
38
+				x = 0;
39
+				y++;
40
+			}
41
+			if (y == 9)
42
+				y = 0;
43
+			Thread.sleep(10);
44
+		}
45
+		// ! [Interesting]
46
+	}
47
+}

+ 20
- 6
src/CMakeLists.txt View File

1
+macro (file_to_list readfile outlist)
2
+  FILE(READ "${readfile}" contents)
3
+  STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
4
+  STRING(REGEX REPLACE "\n" ";" contents "${contents}")
5
+  set("${outlist}" "${contents}" )
6
+endmacro()
7
+
8
+file_to_list ("javaswig_blacklist" JAVASWIG_BLACKLIST)
9
+file_to_list ("pythonswig_blacklist" PYTHONSWIG_BLACKLIST)
10
+file_to_list ("nodeswig_blacklist" NODESWIG_BLACKLIST)
11
+
1
 macro(subdirlist result curdir)
12
 macro(subdirlist result curdir)
2
   file(GLOB children RELATIVE ${curdir} ${curdir}/*)
13
   file(GLOB children RELATIVE ${curdir} ${curdir}/*)
3
   set(dirlist "")
14
   set(dirlist "")
159
     endmacro()
170
     endmacro()
160
 
171
 
161
   endif(BUILDSWIGNODE)
172
   endif(BUILDSWIGNODE)
162
-#  if(BUILDSWIGJAVA)
163
-#    add_subdirectory (java)
164
-#  endif(BUILDSWIGJAVA)
165
 
173
 
166
 endif()
174
 endif()
167
 
175
 
181
   )
189
   )
182
   upm_create_install_pkgconfig (upm-${libname}.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
190
   upm_create_install_pkgconfig (upm-${libname}.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
183
   if (SWIG_FOUND)
191
   if (SWIG_FOUND)
184
-    upm_swig_python()
185
-    upm_swig_node()
186
-    upm_swig_java()
192
+    if (NOT ";${PYTHONSWIG_BLACKLIST};" MATCHES ";${libname};")
193
+      upm_swig_python()
194
+    endif()
195
+    if (NOT ";${NODESWIG_BLACKLIST};" MATCHES ";${libname};")
196
+      upm_swig_node()
197
+    endif()
198
+    if (NOT ";${JAVASWIG_BLACKLIST};" MATCHES ";${libname};")
199
+      upm_swig_java()
200
+    endif()
187
   endif()
201
   endif()
188
   if (BUILDDOC)
202
   if (BUILDDOC)
189
     upm_doxygen()
203
     upm_doxygen()

+ 1
- 0
src/javaswig_blacklist View File

1
+nrf8001

+ 0
- 0
src/nodeswig_blacklist View File


+ 0
- 0
src/pythonswig_blacklist View File


+ 17
- 0
tests/CMakeLists.txt View File

1
+add_test (NAME check_consistency COMMAND ${PYTHON_EXECUTABLE}
2
+    ${CMAKE_CURRENT_SOURCE_DIR}/check_consistency.py
3
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
4
+
5
+if (BUILDSWIGJAVA)
6
+    add_test (NAME check_autoloadlibrary COMMAND ${PYTHON_EXECUTABLE}
7
+        ${CMAKE_CURRENT_SOURCE_DIR}/check_autoloadlibrary.py
8
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
9
+
10
+    add_test (NAME check_samplenames COMMAND ${PYTHON_EXECUTABLE}
11
+        ${CMAKE_CURRENT_SOURCE_DIR}/check_samplenames.py
12
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
13
+
14
+    add_test (NAME check_clean COMMAND ${PYTHON_EXECUTABLE}
15
+        ${CMAKE_CURRENT_SOURCE_DIR}/check_clean.py
16
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
17
+endif ()

+ 44
- 0
tests/check_autoloadlibrary.py View File

1
+#!/usr/bin/python
2
+
3
+import unittest as u
4
+import re, fnmatch, os
5
+
6
+rootDir = '../src/'
7
+prefix = """
8
+%pragma(java) jniclasscode=%{
9
+    static {
10
+        try {
11
+            System.loadLibrary(\""""
12
+
13
+sufix = """\");
14
+        } catch (UnsatisfiedLinkError e) {
15
+            System.err.println("Native code library failed to load. \\n" + e);
16
+            System.exit(1);
17
+        }
18
+    }
19
+%}"""
20
+
21
+class AutoLoadLibrary(u.TestCase):
22
+
23
+    def test_existing_snippet(self):
24
+        broken_modules = []
25
+
26
+        for subdir, dirs, files in os.walk(rootDir):
27
+            for fileName in files:
28
+                if fnmatch.fnmatch(fileName, 'javaupm_*.i'):
29
+                    moduleName = fileName[:-2]
30
+                    snippet = prefix + moduleName + sufix
31
+
32
+                    with open(os.path.join(subdir, fileName), "r") as f:
33
+                        if  not snippet in f.read():
34
+                            broken_modules.append(moduleName)
35
+
36
+        self.assertEqual( len(broken_modules), 0,
37
+                "\nThe following modules do not contain the standard auto load library code:\n" + \
38
+                "\n".join(broken_modules) + \
39
+                "\nConsider adding the following snippet to the SWIG interface file:\n" + \
40
+                prefix + "<module_name>" + sufix)
41
+
42
+
43
+if __name__ == '__main__':
44
+      u.main()

+ 35
- 0
tests/check_clean.py View File

1
+#!/usr/bin/python
2
+
3
+import unittest as u
4
+import re, fnmatch, os
5
+
6
+rootDir = '../build/src/'
7
+swigtypeStr = 'SWIGTYPE'
8
+
9
+class Clean(u.TestCase):
10
+
11
+    def test_existing_swigtype(self):
12
+        unclean = []
13
+
14
+        for dirName in os.listdir(rootDir):
15
+            dirPath = os.path.join(rootDir, dirName)
16
+            if not os.path.isdir(dirPath):
17
+                continue
18
+
19
+            ok = True
20
+            for subdir, dirs, files in os.walk(dirPath):
21
+                if not ok:
22
+                    break
23
+                for fileName in files:
24
+                    if swigtypeStr in fileName:
25
+                        unclean.append(dirName)
26
+                        ok = False
27
+                        break
28
+
29
+        self.assertEqual( len(unclean), 0,
30
+                "\nThe following modules have unclean Java bindings:\n" + \
31
+                "\n".join(unclean) + "\n\n" + \
32
+                "Consider adding them to the SWIGJAVA blacklist")
33
+
34
+if __name__ == '__main__':
35
+    u.main()

+ 60
- 0
tests/check_consistency.py View File

1
+#!/usr/bin/python
2
+
3
+import unittest as u
4
+import re, fnmatch, os
5
+
6
+rootDir = '../src/'
7
+javaBlacklistFile = '../src/javaswig_blacklist'
8
+pythonBlacklistFile = '../src/pythonswig_blacklist'
9
+nodeBlacklistFile = '../src/nodeswig_blacklist'
10
+
11
+
12
+class BlacklistConsistency(u.TestCase):
13
+
14
+    def test_java_blacklist(self):
15
+
16
+        with open(javaBlacklistFile) as f:
17
+            blacklist = [line.rstrip('\n') for line in f]
18
+
19
+            for libraryName in blacklist:
20
+                files = os.listdir( os.path.join(rootDir, libraryName))
21
+                interfaceFileName = "javaupm_" + libraryName + ".i"
22
+
23
+                if interfaceFileName in files:
24
+                    self.fail("\n" + libraryName + " is in javaswig blacklist.\n" + \
25
+                            "Remove it from blacklist or remove " + \
26
+                            interfaceFileName + " from sources.")
27
+
28
+
29
+    def test_python_blacklist(self):
30
+
31
+        with open(pythonBlacklistFile) as f:
32
+            blacklist = [line.rstrip('\n') for line in f]
33
+
34
+            for libraryName in blacklist:
35
+                files = os.listdir( os.path.join(rootDir, libraryName))
36
+                interfaceFileName = "pyupm_" + libraryName + ".i"
37
+
38
+                if interfaceFileName in files:
39
+                    self.fail("\n" + libraryName + " is in pythonswig blacklist.\n" + \
40
+                            "Remove it from blacklist or remove " + \
41
+                            interfaceFileName + " from sources.")
42
+
43
+
44
+    def test_node_blacklist(self):
45
+
46
+        with open(nodeBlacklistFile) as f:
47
+            blacklist = [line.rstrip('\n') for line in f]
48
+
49
+            for libraryName in blacklist:
50
+                files = os.listdir( os.path.join(rootDir, libraryName))
51
+                interfaceFileName = "jsupm_" + libraryName + ".i"
52
+
53
+                if interfaceFileName in files:
54
+                    self.fail("\n" + libraryName + " is in nodeswig blacklist.\n" + \
55
+                            "Remove it from blacklist or remove " + \
56
+                            interfaceFileName + " from sources.")
57
+
58
+
59
+if __name__ == '__main__':
60
+    u.main()

+ 53
- 0
tests/check_samplenames.py View File

1
+#!/usr/bin/python
2
+
3
+import unittest as u
4
+import re, fnmatch, os, sys
5
+
6
+sampleMappingFile = '../doxy/samples.mapping.txt'
7
+cSamplesDir = '../examples/c++/'
8
+javaSamplesDir = '../examples/java/'
9
+
10
+
11
+class SampleNames(u.TestCase):
12
+
13
+    def test_existing_samples(self):
14
+        missing_c_files = []
15
+        missing_java_files = []
16
+
17
+        with open (sampleMappingFile, "r") as f:
18
+            for line in f:
19
+                sampleNames = line.split();
20
+
21
+                cSampleName = sampleNames[0]
22
+                if not cSampleName.endswith('.cxx'):
23
+                    continue
24
+
25
+                javaSampleName = sampleNames[1]
26
+                if not javaSampleName.endswith('.java'):
27
+                    continue
28
+
29
+                ok = False
30
+                for file in os.listdir(cSamplesDir):
31
+                    if file == cSampleName:
32
+                        ok = True
33
+                        break
34
+
35
+                if not ok:
36
+                    missing_c_files.append(cSampleName)
37
+
38
+                ok = False
39
+                for file in os.listdir(javaSamplesDir):
40
+                    if file == javaSampleName:
41
+                        ok = True
42
+                        break
43
+
44
+                if not ok:
45
+                    missing_java_files.append(javaSampleName)
46
+
47
+        self.assertEqual( len(missing_java_files) + len(missing_c_files), 0,
48
+                "\nThe following files are missing from samples:\n" + \
49
+                "\n".join(missing_c_files) + "\n" + "\n".join(missing_java_files))
50
+
51
+if __name__ == '__main__':
52
+          u.main()
53
+