在 HPC 上自动测试来自 SVN 的二进制文件

发布于 2024-07-25 08:35:37 字数 240 浏览 6 评论 0原文

我想根据需要或使用 Cron 作业在 SVN 存储库中的 Fortran 二进制文件上设置一些测试用例的自动化测试。 让问题稍微复杂一些的是,测试用例将在计算集群上运行,因此每个测试用例都需要生成一个 PBS 脚本。 (Linux 环境)

有很多 Web 测试和单元测试解决方案,但是,我找不到任何可以直接测试二进制文件的东西。 比如说,提供输入,并将输出与预期的解决方案进行比较。

关于如何处理这个问题有什么建议吗?

I would like to setup some automated testing of test cases upon Fortran binaries within an SVN Repository, on demand, or with a Cron job. To complicate the issue slightly, the test cases would be run on a computational cluster, so that each test case would need to generate a PBS script. (Linux Environment)

There are a lot of web testing, and unit testing solutions out there, however, I could not find anything for testing binaries directly. Say, provide inputs, and compare the outputs with the expected solution.

Any suggestions on how should this approached?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

画尸师 2024-08-01 08:35:37

我同意这对于脚本来说是非常简单的。 根据二进制文件的配置方式以及程序之间的差异,您甚至可以将测试脚本作为 SVN 存储库的一部分。

由于您处于批处理系统中,因此您可以自由地安排测试。 您可能希望有一个通用的“验证”作业,您可以向其提供设置参数(例如,预期的程序输出和实际的程序输出的位置)。 Nick 提到使用 grep< /code> 检查 qstat 的输出中是否有您的作业 ID,但您可以告诉 PBS 保留一个作业,直到另一个作业完成。 这意味着您有类似的内容:

...
#PBS -N run_test_1
#PBS -a 200906270000
...
<compile test>
<run test>
<save output>

提交时,保存 qsub 返回的作业 ID(如何执行此操作取决于您的平台 - 通常类似于 job_id=$(qsub $JOB_FILE ) 就足够了)。 然后,将该值插入到另一个脚本中:

...
#PBS -N verify_test_1
#PBS -W depend=afterany:$job_id
<run comparison>
...

这将(当插入 job_id 的正确值时)将测试运行的执行保留到 2009 年 6 月 27 日午夜,并保留验证作业直到测试作业完成(afterany 指令指示它应该始终在第一个作业之后运行 - 而不仅仅是在它成功时运行)。

不过,根据集群的周转时间,您可以将所有这些放入一个脚本中,但您仍然可以使用 PBS 基于时间的保留来仅在特定时间运行。 我最近开始使用 Python 而不是 shell 脚本来处理与系统相关的工作 - 我昨天测试了使 Python 脚本可执行并将 PBS 指令直接添加到源代码中 - 它似乎工作得很好。

I agree that this is something that would be pretty straightforward to script. Depending on how your binaries are configured and how different your programs are from one another, you could even include the testing scripts as part of your SVN repository.

Since you're in a batch system, you have some freedom for scheduling the tests. You may want to have a generic "verify" job that you can provide setup parameters to (e.g. to locations of expected and actual program output output). Nick mentioned using grep to check the output of qstat for your job ID, but you can tell PBS to hold a job until another job completes. This would mean that you have something like:

...
#PBS -N run_test_1
#PBS -a 200906270000
...
<compile test>
<run test>
<save output>

when submitted, save the job ID returned by qsub (how you do this is dependent on your platform - usually something like job_id=$(qsub $JOB_FILE) is sufficient). Then, plug that value in to another script:

...
#PBS -N verify_test_1
#PBS -W depend=afterany:$job_id
<run comparison>
...

This will (when the proper value of job_id is inserted) hold the execution of the test run until midnight on June 27, 2009, and hold the execution of the verification job until the test job completes (the afterany directive indicates that it should always run after the first job - not just if it's successful).

Depending on your cluster's turnaround time, though, you could put all of this in one script, though you could still use the PBS time-based holds to only run at a particular time. I've recently started using Python instead of shell scripts to handle even this system-related jobs - I tested yesterday making the Python script executable and adding the PBS directives straight into the source - it seemed to work very well.

财迷小姐 2024-08-01 08:35:37

可能有一个更好的答案,即更预先打包,但我相信 Buildbot 具有足够的可配置性,只要您可以编写 python 脚本来运行二进制文件,它就应该可以满足您的需求。

http://buildbot.net/

There may be a better answer that is more pre-packaged, but I believe that Buildbot is configurable enough that as long as you can write a python script to run your binary, it should work for what you want.

http://buildbot.net/

归途 2024-08-01 08:35:37

似乎对于简单的输入/输出测试,您可以自己编写一个脚本来执行此操作...

例如,

for each program
    compile
    submit to queue
    wait for finish
    check output

在实践中,您可能想要向队列提交多个作业,但想法是相同的。

以下是我的一些关于如何完成每一步的想法。

提交

您可以使用模板 PBS 脚本,并使用 sed 在提交之前使用程序的输入值查找/替换输入标记

等待完成

您可以重复 grep qstat 的输出以获取作业 ID,等待其完成

检查输出

根据预期输出检查作业的输出文件。 您可以将预期输出保存到文件并使用 diff,或者拥有每次运行都必须匹配的正则表达式列表

It seems like for simple input/output testing you could knock up a script yourself to do this...

e.g.

for each program
    compile
    submit to queue
    wait for finish
    check output

In practice, you'd probably want to submit more than one job to the queue, but the idea is the same.

Here are a few ideas off the top of my head on how you could do each step.

Submitting

You could use a template PBS script, and use sed to find/replace intput tokens with input values for the program before submitting

Waiting for finish

You could repeatedly grep the output of qstat for your job id, to wait for it to finish

Check output

Check the job's output file against expected output. You could either save the expected output to a file and use diff, or have a list of regular expression that must match for each run

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文