bugSimulavr: an AVR simulator - Bugs: bug #47629, adc_diff_t25 tests 00 and 02 fail...

 
 

bug #47629: adc_diff_t25 tests 00 and 02 fail on 64bit Ubuntu 14.04

Submitter:  None
Submitted:  Tue 05 Apr 2016 08:38:41 PM UTC
   
 
Category:  Test Suite Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  chrta
Originator Email:  * -email is unavailable- Open/Closed:  Closed
Component Version:  * simulavr
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 05 Apr 2016 08:38:41 PM UTC, original submission:  

Simulavr version: rel-1.1 branch (commit: 4d3c8c0fae3efa95)

Test suite fails on 64bit Ubuntu 14.04 with following errors:


======================================================================
FAIL: test_00 (adc_diff_t25.TestCase)
adc_diff_t25_attiny25::check adc conversion, differential channel, bipolar mode
----------------------------------------------------------------------
Traceback (most recent call last):
  File "adc_diff_t25.py", line 83, in test_00
    self.assertValue(0.8, 1.0, 2.56, False)
  File "adc_diff_t25.py", line 52, in assertValue
    self.assertEqual(v, e, "expected adc value is 0x%x, got 0x%x" % (e, v))
AssertionError: expected adc value is 0x3d9, got 0x3d8

======================================================================
FAIL: test_02 (adc_diff_t25.TestCase)
adc_diff_t25_attiny25::check adc conversion, differential channel, unipolar mode with IPR
----------------------------------------------------------------------
Traceback (most recent call last):
  File "adc_diff_t25.py", line 147, in test_02
    self.assertValue(1.0, 0.8, 2.56)
  File "adc_diff_t25.py", line 52, in assertValue
    self.assertEqual(v, e, "expected adc value is 0x%x, got 0x%x" % (e, v))
AssertionError: expected adc value is 0x4f, got 0x50



Environment



Ubuntu 14.04.4 LTS (GNU/Linux 4.2.0-27-generic x86_64)

$ uname -a
Linux ubuntu64 4.2.0-27-generic #32~14.04.1-Ubuntu SMP Fri Jan 22 15:32:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4

$ python --version
Python 2.7.6



Investigation


Floating point calculations give slightly different result in C++ Simulavr code and in Python tests. And after truncation of the fractional part, integer results differ by 1.

The code from adc_diff_t25.py:


  def assertValue(self, pValue, nValue, refValue, unipolar = True):
    if unipolar:
      rng = 1024
    else:
      rng = 512
    v = self.sim.getWordByName(self.dev, "adc_value")
    e = int(((pValue - nValue) / refValue) * rng) & 0x3ff
    self.assertEqual(v, e, "expected adc value is 0x%x, got 0x%x" % (e, v))


Failure in test_00 is caused by following values:

v = 984
((pValue - nValue) / refValue) * rng = -39.9999999999999929 (after truncation to int becomes -39 and not -40)


Failure in test_02 is caused by following values:

v = 80
((pValue - nValue) / refValue) * rng = 79.9999999999999858 (after truncation to int becomes 79 and not 80)


Probably, the behavior described here takes place: http://www.viva64.com/en/b/0074/


Solution


Test voltage value(s) should be adjusted to produce a more stable result (I've changed 0.8 to 0.79999).

The patch attached.


Best regards,
Igor A. Perminov

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #36843:  fix_regress_amd64.patch added by None (1KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chrta (Updated the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-05-01 chrta StatusNone Fixed
        Assigned toNone chrta
        Open/ClosedOpen Closed
    2016-04-05 None Attached File- Added fix_regress_amd64.patch, #36843

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code