]> git.proxmox.com Git - mirror_ovs.git/blame - tests/test-daemon.py
ofp-actions: Translate OF1.0 "enqueue" actions for OF1.1+.
[mirror_ovs.git] / tests / test-daemon.py
CommitLineData
e0edde6f 1# Copyright (c) 2010, 2011 Nicira, Inc.
9c64f238 2#
99155935
BP
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at:
9c64f238 6#
99155935 7# http://www.apache.org/licenses/LICENSE-2.0
9c64f238 8#
99155935
BP
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
b153e667 15import argparse
6793129d 16import signal
99155935
BP
17import sys
18import time
19
20import ovs.daemon
21import ovs.util
22
50e97486
EJ
23
24def handler(signum, _):
6793129d
EJ
25 raise Exception("Signal handler called with %d" % signum)
26
50e97486 27
b153e667 28def main():
6793129d
EJ
29
30 signal.signal(signal.SIGHUP, handler)
31
b153e667
EJ
32 parser = argparse.ArgumentParser(
33 description="Open vSwitch daemonization test program for Python.")
34 parser.add_argument("-b", "--bail", action="store_true",
35 help="Exit with an error after daemonize_start().")
99155935 36
b153e667
EJ
37 ovs.daemon.add_args(parser)
38 args = parser.parse_args()
39 ovs.daemon.handle_args(args)
99155935 40
99155935 41 ovs.daemon.daemonize_start()
b153e667 42 if args.bail:
99155935
BP
43 sys.stderr.write("%s: exiting after daemonize_start() as requested\n"
44 % ovs.util.PROGRAM_NAME)
45 sys.exit(1)
46 ovs.daemon.daemonize_complete()
47
48 while True:
49 time.sleep(1)
50
50e97486 51
99155935 52if __name__ == '__main__':
6793129d 53 try:
b153e667 54 main()
6793129d
EJ
55 except SystemExit:
56 # Let system.exit() calls complete normally
57 raise
58 except:
59 sys.exit(ovs.daemon.RESTART_EXIT_CODE)