Skip to content

Commit

Permalink
misc/cgo/test: fix issue 24161 test for 1.11 and earlier
Browse files Browse the repository at this point in the history
The test uses functions from C that were introduced in OSX 1.12.
Include stubs for those functions when compiling for 1.11 and earlier.
This test really a compile-time test, it doesn't matter much what the
executed code actually does.
Use a nasty #define hack to work around the fact that cgo doesn't
support static global variables.

Update golang#24161
Fixes golang#26355

Change-Id: Icf6f7bc9b6b36cacc81d5d0e033a2ebaff7e0298
Reviewed-on: https://go-review.googlesource.com/123715
Run-TryBot: Keith Randall <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
randall77 committed Jul 13, 2018
1 parent 489a263 commit a241922
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions misc/cgo/test/issue24161e0/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ package issue24161e0
#cgo LDFLAGS: -framework CoreFoundation -framework Security
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
typedef CFStringRef SecKeyAlgorithm;
static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
#define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
static SecKeyAlgorithm foo(void){return NULL;}
#endif
*/
import "C"
import "testing"
Expand Down
6 changes: 6 additions & 0 deletions misc/cgo/test/issue24161e1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ package issue24161e1
#cgo LDFLAGS: -framework CoreFoundation -framework Security
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
typedef CFStringRef SecKeyAlgorithm;
static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
#define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
static SecKeyAlgorithm foo(void){return NULL;}
#endif
*/
import "C"
import (
Expand Down
6 changes: 6 additions & 0 deletions misc/cgo/test/issue24161e2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ package issue24161e2
#cgo LDFLAGS: -framework CoreFoundation -framework Security
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
typedef CFStringRef SecKeyAlgorithm;
static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
#define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
static SecKeyAlgorithm foo(void){return NULL;}
#endif
*/
import "C"
import (
Expand Down

0 comments on commit a241922

Please sign in to comment.