Skip to content

Commit 29c7ecc

Browse files
committed
adding testing functions for validity of containers
1 parent dd690f0 commit 29c7ecc

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

singularity/build/utils.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020

2121
import sys
2222

23-
import subprocess
23+
from subprocess import (
24+
Popen,
25+
PIPE,
26+
STDOUT
27+
)
2428

2529
import tempfile
2630
import zipfile
2731

2832
######################################################################################
29-
# Retry Functions
33+
# Testing/Retry Functions
3034
######################################################################################
3135

3236
def stop_if_result_none(result):
@@ -37,6 +41,21 @@ def stop_if_result_none(result):
3741
return do_retry
3842

3943

44+
def test_container(image_path):
45+
'''test_container is a simple function to send a command to a container, and
46+
return the status code and any message run for the test. It does it by
47+
way of sending an echo of some message, which (I think?) should
48+
work in most linux.
49+
:param image_path: path to the container image
50+
'''
51+
testing_command = ["singularity", "exec", image, 'echo pancakemania']
52+
output = Popen(testing_command,stderr=STDOUT,stdout=PIPE)
53+
t = output.communicate()[0],output.returncode
54+
result = {'message':t[0],
55+
'return_code':t[1]}
56+
return result
57+
58+
4059
######################################################################################
4160
# Build Templates
4261
######################################################################################

singularity/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.93"
1+
__version__ = "0.95"
22
AUTHOR = 'Vanessa Sochat'
33
AUTHOR_EMAIL = '[email protected]'
44
NAME = 'singularity'

0 commit comments

Comments
 (0)