RFR: JDK-8055209 - create initial set of SPI tests

Alexey Konstantinov alexey.konstantinov at oracle.com
Fri Aug 15 22:56:46 UTC 2014


Hi Stas, 


This version looks OK. 


Thanks, 
Alexey 

----- Original Message ----- 
From: stanislav.smirnov at oracle.com 
To: alexey.konstantinov at oracle.com, dio-dev at openjdk.java.net 
Sent: Friday, August 15, 2014 9:13:41 PM GMT +04:00 Abu Dhabi / Muscat 
Subject: Re: RFR: JDK-8055209 - create initial set of SPI tests 



Please take a look on updated SPI tests using try-with-resources 
Existing GPIO tests have been already modified, will send it as a separate review after SPI and UART which I submitted recently 

15.08.2014 21:02, Stas Smirnov пишет: 


I took a look on existing gpio tests, they are ok, however after submitting required tests for spi and uart I think I will modify them a bit to start using try-with-resources style, I assume it will be better. 
So thank you one more time for catching it. 

15.08.2014 20:52, Stas Smirnov пишет: 


Hi Alexey, 

thanks for reviewing. 
Originally I was using finally block to close instances, but while moving lines seems to lost it so thank you for catching it. 
Use of try-with-resources might work here, I will take a look on SPI tests, only them cause existing gpio tests are not affected by this. 

15.08.2014 20:37, Alexey Konstantinov пишет: 


Hi Stas, 

More findings, sorry. 

SPIWriteAndReadTest.testWriteAndRead() does not close the devices it opens. I think it should. 

This also caused me to think that many tests probably need some global redesigning. Consider this test: 

85 private Status testWordLength() { 
86 Status result = Status.passed("OK"); 
87 start("Checking current word length"); 
88 
89 SPIDevice spiDevice; 
90 
91 Iterator<SPIConfig> devices = SPIDevices.iterator(); 
92 while(devices.hasNext()){ 
93 SPIConfig spiConfig = devices.next(); 
94 try { 
95 spiDevice = spiConfig.open(); 
96 System.out.println("Word length for this Slave: " + spiDevice.getWordLength()); 
97 spiDevice.close(); 
98 } catch (IOException e) { 
99 result = printFailedStatus("Unexpected IOException: " + e.getClass().getName() + ":" + e.getMessage()); 
100 } 
101 } 
102 
103 stop(); 
104 
105 return result; 
106 } 

If spiDevice.getWordLength() generates an exception, the device is left forever open and the next tests wanting to deal with it will all fail with unexpected IOEs until you reboot. Maybe try-with-resources would help? 

Thanks, 
Alexey 

On 8/15/2014 8:20 PM, Stas Smirnov wrote: 


Hm, sorry, but the link is incorrect, here is the one <http://cr.openjdk.java.net/%7Estsmirno/8055209e/> 

15.08.2014 19:57, Stas Smirnov пишет: 


Updated webrev <http://cr.openjdk.java.net/%7Estsmirno/8055209d/> is now available 

15.08.2014 19:38, Stas Smirnov пишет: 


Alexey, thanks for catching this, my eyes were closed when I put it there:) 

right thing will be 
String srcStr = new String(src.array()); 

System.out.println("Write SPI: data = " + srcStr); 
spiDevice.writeAndRead(src, dst); 
spiDevice.end(); 

String dstStr = new String(dst.array()); 
System.out.println("Read SPI: " + dstStr); 

if(!srcStr.equals(dstStr)){ 
result = printFailedStatus("Data does not match"); 
} 

15.08.2014 19:14, Alexey Konstantinov пишет: 


Hi Stas, 

Could you double check the test logic of SPIWriteAndReadTest.testWriteAndRead()? I'd suppose that the final check srcStr.equals(dstStr)) will always fail, because it does not seem to me that there are any reasons for dstStr to get updated as result of writing something to the dst buffer. 

Thanks, 
Alexey 

On 8/15/2014 6:54 PM, Stas Smirnov wrote: 


Please use this, correct link to the webrev <http://cr.openjdk.java.net/%7Estsmirno/8055209c/> 

15.08.2014 18:03, Stas Smirnov пишет: 


issue: JDK-8055209 <https://bugs.openjdk.java.net/browse/JDK-8055209> 
webrev: 8055137 <http://cr.openjdk.java.net/%7Estsmirno/8055209/> 

Hi All, 

Need a review for an update. 
In this update I have added 4 tests classes, to verify config, to verify permissions, word length and write/read operation and fixed a typo in the testbase class. 

-- 

Best regards, 
Stas Smirnov 

Stas Smirnov | Java Embedded 
Phone: +7 812 3346130 | Mobile: +7 921 9262241 
Oracle Development SPB, LLC 
10th Krasnoarmeyskaya 22A, St. Petersburg, 190103, Russia 


















-- 

	

Best regards, 
Stas Smirnov 

	Stas Smirnov | Java Embedded 
Phone: +7 812 3346130 | Mobile: +7 921 9262241 
Oracle Development SPB, LLC 
10th Krasnoarmeyskaya 22A, St. Petersburg, 190103, Russia


More information about the dio-dev mailing list