Closed Konstantin8105 closed 3 years ago
How to run test for that issue:
go test -v -tags=integration -run=TestIntegrationScripts/tests/time.c
go test -v -run=TestCSTD
I was going to take a crack at this but it looks like the existing time tests fail which makes me skittish about adding anything.
=== RUN TestIntegrationScripts
=== RUN TestIntegrationScripts/tests/time.c
TAP: # Total tests: 0
--- FAIL: TestIntegrationScripts (0.64s)
--- FAIL: TestIntegrationScripts/tests/time.c (0.64s)
main_test.go:280:
Expect:
`1..19
# asctime
1 ok - asctime(timeinfo) == "Thu Jan 1 22:13:20 1970\n"
# ctime
2 ok - s != NULL
3 ok - s == "Fri Dec 31 HH:mm:58 1999\n"
# gmtime
4 ok - timeinfo->tm_sec == 20
5 ok - timeinfo->tm_min == 13
6 ok - timeinfo->tm_hour == 22
7 ok - timeinfo->tm_mday == 1
8 ok - timeinfo->tm_mon == 0
9 ok - timeinfo->tm_year == 70
10 ok - timeinfo->tm_wday == 4
11 ok - timeinfo->tm_yday == 0
12 ok - timeinfo->tm_isdst == 0
# mktime
13 ok - timeinfo.tm_wday == 6
14 ok - timeinfo.tm_year == 100
15 ok - timeinfo.tm_mon == 4
16 ok - timeinfo.tm_mday == 20
# time
17 ok - now != 0
18 ok - now != 0
19 ok - now == tloc
`
Actial:
`# command-line-arguments [command-line-arguments.test]
build/tests/time/main_test.go:211:21: undefined: __int8_t
`
Parts of code:
+========================+
File : ./build/tests/time/main_test.go
Line : 192 : // Warning (*ast.CStyleCastExpr): $GOPATH/src/github.com/Konstantin8105/c4go/tests/time.c:72 :argument position is 3. Cannot transpileToExpr. err = Cannot transpileImplicitCastExpr. err = Cannot transpileToExpr. err = Not acceptable nil node
Line : 193 : // Warning (*ast.CallExpr): $GOPATH/src/github.com/Konstantin8105/c4go/tests/time.c:72 :Cannot transpileToStmt : Cannot transpileToExpr. err = Error in transpileCallExpr : name of call function is noarch.Printf. argument position is 3. Cannot transpileToExpr. err = Cannot transpileImplicitCastExpr. err = Cannot transpileToExpr. err = Not acceptable nil node
Line : 194 : // Warning (*ast.ImplicitCastExpr): $GOPATH/src/github.com/Konstantin8105/c4go/tests/time.c:79 :argument position is 0. Cannot transpileToExpr. err = Cannot transpileImplicitCastExpr. err = Cannot transpileToExpr. err = Not acceptable nil node
Line : 195 : // Warning (*ast.BinaryOperator): $GOPATH/src/github.com/Konstantin8105/c4go/tests/time.c:79 :Cannot transpile BinaryOperator with type 'struct tm *' : result type = {unknown53}. Error: operator is `=`. cannot atomic for right part. Cannot transpileToExpr. err = Error in transpileCallExpr : name of call function is noarch.Gmtime. argument position is 0. Cannot transpileToExpr. err = Cannot transpileImplicitCastExpr. err = Cannot transpileToExpr. err = Not acceptable nil node
Line : 196 : // Warning (*ast.BinaryOperator): $GOPATH/src/github.com/Konstantin8105/c4go/tests/time.c:79 :Cannot transpileToStmt : Cannot transpileToExpr. err = Cannot transpile BinaryOperator with type 'struct tm *' : result type = {unknown53}. Error: operator is `=`. cannot atomic for right part. Cannot transpileToExpr. err = Error in transpileCallExpr : name of call function is noarch.Gmtime. argument position is 0. Cannot transpileToExpr. err = Cannot transpileImplicitCastExpr. err = Cannot transpileToExpr. err = Not acceptable nil node
Line : 197 :
Line : 198 : package main
Line : 199 :
Line : 200 : import "io/ioutil"
Line : 201 : import "testing"
Line : 202 : import "os"
Line : 203 : import "fmt"
Line : 204 : import "math"
Line : 205 : import "github.com/Konstantin8105/c4go/linux"
Line : 206 : import "github.com/Konstantin8105/c4go/noarch"
Line : 207 :
Line : 208 : type size_t uint32
Line : 209 : type va_list int64
Line : 210 : type __gnuc_va_list int64
Line : 211 *: type __int_least8_t __int8_t
Line : 212 : type __uint_least8_t __uint8_t
Line : 213 : type __int_least16_t __int16_t
Line : 214 : type __uint_least16_t uint16
Line : 215 : type __int_least32_t __int32_t
Line : 216 : type __uint_least32_t uint32
* 1 "1..19" "# command-line-arguments [command-line-arguments.test]"
* 2 "# asctime" "build/tests/time/main_test.go:211:21: undefined: __int8_t"
* 3 "1 ok - asctime(timeinfo) == \"Thu Jan 1 22:13:20 1970\\n\""""
* 4 "# ctime"
* 5 "2 ok - s != NULL"
* 6 "3 ok - s == \"Fri Dec 31 HH:mm:58 1999\\n\""
* 7 "# gmtime"
* 8 "4 ok - timeinfo->tm_sec == 20"
* 9 "5 ok - timeinfo->tm_min == 13"
* 10 "6 ok - timeinfo->tm_hour == 22"
* 11 "7 ok - timeinfo->tm_mday == 1"
* 12 "8 ok - timeinfo->tm_mon == 0"
* 13 "9 ok - timeinfo->tm_year == 70"
* 14 "10 ok - timeinfo->tm_wday == 4"
* 15 "11 ok - timeinfo->tm_yday == 0"
* 16 "12 ok - timeinfo->tm_isdst == 0"
* 17 "# mktime"
* 18 "13 ok - timeinfo.tm_wday == 6"
* 19 "14 ok - timeinfo.tm_year == 100"
* 20 "15 ok - timeinfo.tm_mon == 4"
* 21 "16 ok - timeinfo.tm_mday == 20"
* 22 "# time"
* 23 "17 ok - now != 0"
* 24 "18 ok - now != 0"
* 25 "19 ok - now == tloc"
* 26 ""
FAIL
exit status 1
FAIL github.com/Konstantin8105/c4go 0.644s
@Konstantin8105 do you know why the above errors might be occuring?
@IngCr3at1on , tests is ok by travis and my local laptop. Now, darwin(MacOS) is not supported. Could you clarify:
Sure; Arch Linux, go version go1.11 linux/amd64, clang version 7.0.0
It is look very nice. Now, we use clang 6.0 for testing. May be is the problem. https://github.com/Konstantin8105/c4go/blob/44a79fa6145545d7bf9786eb423940aa22eed835/.travis.yml#L34 May be you have some specific implementation of glibc.
Add test and implementation on Go for function
time.h
localtime
Description: https://en.cppreference.com/w/c/chrono/localtime File for test code add :c4go/tests/time.c
Example see #155