mirror of
https://github.com/golang/go
synced 2024-11-19 08:44:39 -07:00
godefs: rudimentary tests
currently only defined for darwin R=golang-dev, r CC=golang-dev https://golang.org/cl/4528123
This commit is contained in:
parent
783c46b197
commit
a5b5e2b79e
@ -14,3 +14,6 @@ OFILES=\
|
||||
HFILES=a.h
|
||||
|
||||
include ../../Make.ccmd
|
||||
|
||||
test: $(TARG)
|
||||
./test.sh
|
||||
|
45
src/cmd/godefs/test.sh
Executable file
45
src/cmd/godefs/test.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2011 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
eval $(gomake --no-print-directory -f ../../Make.inc go-env)
|
||||
|
||||
TMP="testdata_tmp.go"
|
||||
TEST="testdata.c"
|
||||
GOLDEN="testdata_${GOOS}_${GOARCH}.golden"
|
||||
|
||||
case ${GOARCH} in
|
||||
"amd64") CCARG="-f-m64";;
|
||||
"386") CCARG="-f-m32";;
|
||||
*) CCARG="";;
|
||||
esac
|
||||
|
||||
cleanup() {
|
||||
rm ${TMP}
|
||||
}
|
||||
|
||||
error() {
|
||||
cleanup
|
||||
echo $1
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! -e ${GOLDEN} ]; then
|
||||
echo "skipping - no golden defined for this platform"
|
||||
exit
|
||||
fi
|
||||
|
||||
./godefs -g test ${CCARG} ${TEST} > ${TMP}
|
||||
if [ $? != 0 ]; then
|
||||
error "Error: Could not run godefs for ${TEST}"
|
||||
fi
|
||||
|
||||
diff ${TMP} ${GOLDEN}
|
||||
if [ $? != 0 ]; then
|
||||
error "FAIL: godefs for ${TEST} did not match ${GOLDEN}"
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
echo "PASS"
|
41
src/cmd/godefs/testdata.c
Normal file
41
src/cmd/godefs/testdata.c
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Issue 432 - enum fields in struct can cause misaligned struct fields
|
||||
typedef enum {
|
||||
a
|
||||
} T1;
|
||||
|
||||
struct T2 {
|
||||
uint8_t a;
|
||||
T1 b;
|
||||
T1 c;
|
||||
uint16_t d;
|
||||
};
|
||||
|
||||
typedef struct T2 T2;
|
||||
typedef T2 $T2;
|
||||
|
||||
// Issue 1162 - structs with fields named Pad[0-9]+ conflict with field
|
||||
// names used by godefs for padding
|
||||
struct T3 {
|
||||
uint8_t a;
|
||||
int Pad0;
|
||||
};
|
||||
|
||||
typedef struct T3 $T3;
|
||||
|
||||
// Issue 1466 - forward references to types in stabs debug info were
|
||||
// always treated as enums
|
||||
struct T4 {};
|
||||
|
||||
struct T5 {
|
||||
struct T4 *a;
|
||||
};
|
||||
|
||||
typedef struct T5 T5;
|
||||
typedef struct T4 $T4;
|
||||
typedef T5 $T5;
|
31
src/cmd/godefs/testdata_darwin_386.golden
Normal file
31
src/cmd/godefs/testdata_darwin_386.golden
Normal file
@ -0,0 +1,31 @@
|
||||
// ./godefs -g test -f-m32 testdata.c
|
||||
|
||||
// MACHINE GENERATED - DO NOT EDIT.
|
||||
|
||||
package test
|
||||
|
||||
// Constants
|
||||
|
||||
// Types
|
||||
|
||||
type T2 struct {
|
||||
A uint8;
|
||||
Pad_godefs_0 [3]byte;
|
||||
B uint32;
|
||||
C uint32;
|
||||
D uint16;
|
||||
Pad_godefs_1 [2]byte;
|
||||
}
|
||||
|
||||
type T3 struct {
|
||||
A uint8;
|
||||
Pad_godefs_0 [3]byte;
|
||||
Pad0 int32;
|
||||
}
|
||||
|
||||
type T4 struct {
|
||||
}
|
||||
|
||||
type T5 struct {
|
||||
A *T4;
|
||||
}
|
31
src/cmd/godefs/testdata_darwin_amd64.golden
Normal file
31
src/cmd/godefs/testdata_darwin_amd64.golden
Normal file
@ -0,0 +1,31 @@
|
||||
// ./godefs -g test -f-m64 testdata.c
|
||||
|
||||
// MACHINE GENERATED - DO NOT EDIT.
|
||||
|
||||
package test
|
||||
|
||||
// Constants
|
||||
|
||||
// Types
|
||||
|
||||
type T2 struct {
|
||||
A uint8;
|
||||
Pad_godefs_0 [3]byte;
|
||||
B uint32;
|
||||
C uint32;
|
||||
D uint16;
|
||||
Pad_godefs_1 [2]byte;
|
||||
}
|
||||
|
||||
type T3 struct {
|
||||
A uint8;
|
||||
Pad_godefs_0 [3]byte;
|
||||
Pad0 int32;
|
||||
}
|
||||
|
||||
type T4 struct {
|
||||
}
|
||||
|
||||
type T5 struct {
|
||||
A *T4;
|
||||
}
|
@ -49,6 +49,10 @@ GOMAXPROCS=10 gomake testshort
|
||||
time gomake test
|
||||
) || exit $?
|
||||
|
||||
(xcd cmd/godefs
|
||||
gomake test
|
||||
) || exit $?
|
||||
|
||||
[ "$GOARCH" == arm ] ||
|
||||
[ "$GOHOSTOS" == windows ] ||
|
||||
(xcd ../misc/cgo/stdio
|
||||
|
Loading…
Reference in New Issue
Block a user