Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am building a Debian squeeze package using git-buildpackage. In the build there are tests that run. I would like to be able to detect in these tests whether they are being run in the context of a package build. This way I can skip any tests that require external network access.

What is a good way to detect that a test is being run in the context of a Debian package build?

share|improve this question
    
I doubt that there is any way to detect that something is a 'test'. AFAIK tests can be written in any language and do anything. About the only think I can think of is to use something like strace to watch for network connections. –  Zoredache Nov 29 '12 at 17:36
    
I am not trying to detect whether something is a test, rather, when building a package tests are run. Inside that test I want to detect that the test is being run in the context of a package build rather than a being run "normally". –  user35042 Nov 29 '12 at 17:50
    
It sounds to me like you are asking for a magical mind-reading program, not something that could exist in reality. A package build is simply simply running a script. That script can start any arbitrary program. I simply cannot think of any way that you could clearly define 'normally' enough to detect things that are not 'normal'. –  Zoredache Nov 29 '12 at 18:07

1 Answer 1

I think you can inspect environment variables like DEB_BUILD_ARCH_OS (full list here: http://man.he.net/man1/dpkg-architecture )

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.