RFR: JDK-8055209 - create initial set of SPI tests
Stas Smirnov
stanislav.smirnov at oracle.com
Fri Aug 15 16:52:36 UTC 2014
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