[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: lua-test failure help on Vxworks 7?
- From: "Kuhl, Brian" <brian.kuhl@...>
- Date: Mon, 8 Apr 2019 18:20:23 +0000
Hi Roberto,
Many thanks for the reply.
(I've got all the basic tests to pass already, sorry if I wasn't clear on that?
With the exception of the single tests in strings.lua and files.lua. )
I'm primarily focused on the non-portable tests, which utilize areas where VxWorks has some POSIX support.
Thanks for the hint about ".isdst"
I drilled down on the string.lua failure and it is an issue with least significant bit in the mantissa returned by VxWorks C library strtod()
There is similar issue with strtof(), but this is the first I've seen a test case for double.
string.lua instrumented :
i is 308.000000
tonumber(string.format('%.99f', -(10^i)) is -0x8.e679c2f5e4528p+1020
string.format('%a', -(10^i)) is -0x8.e679c2f5e452p+1020
output from C code below:
d= 10^308 == -0x8.e679c2f5e45200p+1020
d2= strtod(10^308) == -0x8.e679c2f5e45280p+1020
In function start -- /yow-build62-lx2/bkuhl/workspace/test_strtof/dkm.c:20 d == d2 -- assertion failed
#include "vxWorks.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
void start(void) {
char * end;
char buf[400];
double d2 ;
double d = -pow(10,308);
sprintf(buf, "%.99f", d);
d2 = strtod(buf,&end);
printf( "\nd= 10^308 == %.14a ", d);
printf( "\nd2= strtod(10^308) == %.14a \n", d2);
assert( d == d2 );
}
Brian
> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Roberto Ierusalimschy
> Sent: Monday, April 08, 2019 11:56 AM
> To: Lua mailing list <lua-l@lists.lua.org>
> Subject: Re: lua-test failure help on Vxworks 7?
>
> > Hi Lua experts,
> > <re-post in plain text>
> > I’d appreciate any hints that might not be obvious to the new user.
> > I’m working on a port of Lua 5.3.5 to the current VxWorks 7, (patch
> below). I’m an employee of Wind River that specializes in porting 3rd party
> software to VxWorks. But I don’t know Lua.
> > I’m running the 5.3.4 test suite and getting failures in few places, I’ll be slowly
> be debugging them over the coming weeks as side project.
> > I’m not using the testC library yet. I’ll get there ☺
>
> Did you read the instructions in https://www.lua.org/tests/? You should really
> start with the basic tests (that will avoid your problems with 'main.lua',
> 'files.lua', and 'attrib.lua'). Once you have that working, go to the next step. As
> warned there, beware that the complete tests are not portable.
>
> > strings.lua
> > ========
> > Looks like tonumber() is not my friend for some reason. I’m on
> > possibly related internal thread on similar issues with the VxWorks C library.
> What’s different between the C calls that string.format() uses vs. what
> tonumber() uses??
> >
> > failed assert strings.lua:226
> > do -- longest number that can be formatted
> > local i = 1
> > local j = 10000
> > while i + 1 < j do -- binary search for maximum finite float
> > local m = (i + j) // 2
> > if 10^m < math.huge then i = m else j = m end
> > end
> > local s = string.format('%.99f', -(10^i))
> > assert(tonumber(s) == -(10^i))
> > end
>
> It would help if you could tell what is happening here. Did you print the various
> values produced?
>
> print(i, 10^i, s, tonumber(s))
>
>
> > files.lua
> > ======
> > This I have to call this with _ports == true, to avoid the tests using popen(),
> which VxWorks doesn’t have.
> >
> > I still get a failure in this assert:
> > do
> > local D = os.date("*t")
> > local t = os.time(D)
> > assert(type(D.isdst) == 'boolean')
> > end
>
> Sorry, this test should be coded as not portable. The manual is clear about this:
>
> This last field [isdst] may be absent
> if the information is not available.
>
> (Did the previous test work?)
>
> -- Roberto