简体   繁体   English

尝试在32位Windows上运行64位测试

[英]Trying to run 64-bit tests on 32-bit windows

We're running our unit tests as a post-build step in our builds. 我们正在将单元测试作为构建中的构建后步骤进行。 Now I've run into a problem with this on our autobuild machines that automatically pull and build every revision in svn. 现在,我在我们的自动构建机器上遇到了一个问题,这些机器会自动拉动并构建svn中的每个修订。

The autobuild script pulls down a revision, does some setup and then calls devenv.exe /build on it. 自动构建脚本会提取一个修订,进行一些设置,然后在其上调用devenv.exe / build。 This, in turn, will build everything and then try to run the tests. 反过来,这将构建所有内容,然后尝试运行测试。 The build gets stuck and never completes. 构建卡住,永远无法完成。

If you build the solution manually, what happens at the run tests point is a popup dialog box saying the test executable is not a valid Win32 application. 如果您手动构建解决方案,则在运行测试点会发生一个弹出对话框,指出测试可执行文件不是有效的Win32应用程序。 I'm assuming the autobuilds somehow get this box as well, but hidden away in a non-interactive session somewhere. 我假设自动构建也会以某种方式获取此框,但隐藏在某个地方的非交互式会话中。

I've had two ideas for a solution this far: 到目前为止,我对解决方案有两个想法:

  1. Check in a test-runner application which tries to run the tests and detects the failure. 检入尝试运行测试并检测到故障的测试运行器应用程序。 This is undesirable though since this would mean creating this extra kludge of code and adding it to be used only on windows builds etc. 尽管这是不希望有的,因为这将意味着创建额外的代码并将其添加到仅在Windows构建等中使用。

  2. Somehow test if windows is 32-bit or 64-bit in the build scripts (we're running cmake), and simply don't run the tests if they wouldn't work. 以某种方式在构建脚本中测试Windows是32位还是64位(我们正在运行cmake),如果它们不起作用,则不要运行测试。 This is preferable, but requires a way of checking if windows is 32-bit or 64-bit, preferably without having to check in another "test-windows-type" helper tool. 这是可取的,但是需要一种检查Windows是32位还是64位的方法,最好不必检入另一个“ test-windows-type”帮助工具。

Any further ideas or hints on how to implement suggestion 2 would be much appreciated. 对于如何实施建议2的任何其他想法或提示,将不胜感激。

Update: Note here: This is a cross-compile running on a 32-bit machine but compiling a 64-bit exe. 更新:此处注意:这是在32位计算机上运行但编译64位exe的交叉编译。 If I could just check properties of the compiler, there wouldn't have been a problem. 如果我只检查编译器的属性,就不会有问题。 But I'm after properties of the build machine , not of the build itself, which is clearly 64-bit. 但是我关注的是构建机器的属性,而不是构建本身的属性,后者显然是64位的。

Check the %PROCESSOR_ARCHITECTURE% environment variable : 检查%PROCESSOR_ARCHITECTURE%环境变量:

  • x86 on a 32-bit machine. 32位计算机上的x86
  • AMD64 on a 64-bit machine (cf. here ). 在64位计算机上使用AMD64 (请参见此处 )。

您应该能够检查CMake生成器,对于32/64位窗口,我认为它有所不同。

You can check the CMAKE_SIZEOF_VOID_P variable in your build script to detect the type. 您可以在构建脚本中检查CMAKE_SIZEOF_VOID_P变量以检测类型。 See documentation here . 请参阅此处的文档。 Then you can skip running the tests if this variable is 32. 如果此变量为32,则可以跳过运行测试。

Update : Sorry I overlooked your real issue. 更新 :对不起,我忽略了您的实际问题。 I think the best approach may be to apply a try-run test and use the RUN_RESULT_VAR to determine if the app ran successfully. 我认为最好的方法可能是应用试运行测试并使用RUN_RESULT_VAR来确定应用程序是否成功运行。

不能回答您提出的特定问题,但是您可能应该考虑在x64机器上构建应用程序,该机器可以运行32位测试以及64位测试...

I found out one way to identify if the system is 64-bit or not, which should be possible to access from cmake. 我发现了一种识别系统是否为64位的方法,应该可以从cmake进行访问。 It feels as a rather ugly hack though that could break on any random version of windows, so I'd still rather find another way. 尽管这可能会在任何随机版本的Windows上中断,但感觉还是很丑陋,因此我还是想另辟way径。

The %ProgramFiles(x86)% environment variable only exists in 64bit OS versions. %ProgramFiles(x86)%环境变量仅存在于64位OS版本中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM