Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/gireg.lua fails on current debian testing #173

Closed
psychon opened this issue Sep 23, 2017 · 3 comments
Closed

tests/gireg.lua fails on current debian testing #173

psychon opened this issue Sep 23, 2017 · 3 comments

Comments

@psychon
Copy link
Collaborator

psychon commented Sep 23, 2017

No idea what is going on here, but:

gireg   : 77:const                              FAIL
             tests/gireg.lua:801: got value `44', expected `44.22'
stack traceback:
	[C]: in function 'error'
	tests/test.lua:88: in function 'fail'
	tests/test.lua:91: in function 'check'
	tests/test.lua:101: in function 'checkv'
	tests/gireg.lua:801: in function <tests/gireg.lua:798>
	[C]: in function 'xpcall'
	tests/test.lua:50: in function 'runfunc'
	tests/test.lua:73: in function 'run'
	tests/test.lua:141: in main chunk
	[C]: in ?

Also, no idea since when this fails, but I guess some change in some library caused this to break. Since I do not have the time to investigate this right now, I'm just reporting it. Anyone else seeing this? Anyone on debian testing, but not seeing this? Any idea which upgrade caused it to fail?

@psychon
Copy link
Collaborator Author

psychon commented Sep 24, 2017

No idea what is going on.

tests/Regress-1.0.gir has

    <constant name="DOUBLE_CONSTANT"
              value="44.220000"
              c:type="REGRESS_DOUBLE_CONSTANT">
      <type name="gdouble" c:type="gdouble"/>
    </constant>

but with the following patch

diff --git a/lgi/marshal.c b/lgi/marshal.c
index 555beaf..f5c57d7 100644
--- a/lgi/marshal.c
+++ b/lgi/marshal.c
@@ -1258,7 +1258,10 @@ lgi_marshal_2lua (lua_State *L, GITypeInfo *ti, GIArgInfo *ai, GIDirection dir,
 
     case GI_TYPE_TAG_FLOAT:
     case GI_TYPE_TAG_DOUBLE:
+      puts("float/double");
       g_return_if_fail (parent != LGI_PARENT_FORCE_POINTER);
+      printf("value: %g\n", (double) (tag == GI_TYPE_TAG_FLOAT)
+		      ? arg->v_float : arg->v_double);
       lua_pushnumber (L, (tag == GI_TYPE_TAG_FLOAT)
 		      ? arg->v_float : arg->v_double);
       break;
diff --git a/tests/gireg.lua b/tests/gireg.lua
index d8499e6..badbf56 100644
--- a/tests/gireg.lua
+++ b/tests/gireg.lua
@@ -16,6 +16,7 @@ local check = testsuite.check
 local checkv = testsuite.checkv
 local gireg = testsuite.group.new('gireg')
 
+--[[
 function gireg.type_boolean()
    local R = lgi.Regress
    checkv(R.test_boolean(true), true, 'boolean')
@@ -794,6 +795,7 @@ function gireg.flags_out()
    check(out.FLAG3 == true)
    check(#out == 0)
 end
+--]]
 
 function gireg.const()
    local R = lgi.Regress
@@ -803,6 +805,7 @@ function gireg.const()
    checkv(R.Mixed_Case_Constant, 4423, 'number')
 end
 
+--[[
 function gireg.struct_a()
    local R = lgi.Regress
    check(select('#', R.TestStructA()) == 1)
@@ -1403,3 +1406,4 @@ function gireg.callback_async()
    collectgarbage()
    check(R.test_callback_thaw_async() == 1)
 end
+--]]
diff --git a/tests/test.lua b/tests/test.lua
index 2a4c69b..c752f05 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -107,6 +107,7 @@ end
 local testpath = arg[0]:sub(1, arg[0]:find('[^%/\\]+$') - 1):gsub('[/\\]$', '')
 for _, sourcefile in ipairs {
    'gireg.lua',
+   --[[
    'marshal.lua',
    'corocbk.lua',
    'record.lua',
@@ -118,6 +119,7 @@ for _, sourcefile in ipairs {
    'cairo.lua',
    'pango.lua',
    'gio.lua',
+   --]]
 } do
    dofile(testpath .. '/' .. sourcefile)
 end

I get

float/double
value: 44
gireg   :  1:const                              FAIL
             tests/gireg.lua:803: got value `44', expected `44.22'

So the value that g_constant_info_get_value in core_constant() gave us is already wrong...?
gdb confirms this. When doing print val in core_constant(), I get:

(gdb) print val
$2 = {v_boolean = 0, v_int8 = 0 '\000', v_uint8 = 0 '\000', v_int16 = 0, v_uint16 = 0, v_int32 = 0, v_uint32 = 0, 
  v_int64 = 4631389266797133824, v_uint64 = 4631389266797133824, v_float = 0, v_double = 44, v_short = 0, v_ushort = 0, 
  v_int = 0, v_uint = 0, v_long = 4631389266797133824, v_ulong = 4631389266797133824, v_ssize = 4631389266797133824, 
  v_size = 4631389266797133824, v_string = 0x4046000000000000 <error: Cannot access memory at address 0x4046000000000000>, 
  v_pointer = 0x4046000000000000}

@psychon
Copy link
Collaborator Author

psychon commented Sep 24, 2017

The following patch fixes the issue:

diff --git a/tests/Makefile b/tests/Makefile
index 3c796ce..f74803d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -81,4 +81,4 @@ Regress-1.0.gir : $(REGRESS)
         -lregress
 
 Regress-1.0.typelib : Regress-1.0.gir
-       g-ir-compiler --output=$@ $<
+       LC_ALL=C g-ir-compiler --output=$@ $<

My usual locale (de_DE) uses , as decimal separator instead of ., so I guess that's the issue here. However, I'm sure that "once upon a time" this worked...?

@psychon
Copy link
Collaborator Author

psychon commented Sep 24, 2017

Reported upstream https://bugzilla.gnome.org/show_bug.cgi?id=788087

@psychon psychon closed this as completed Sep 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant