xref: /AOO41X/main/xmerge/source/palmtests/bin/verify_sane.pl (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1#!/usr/bin/perl
2#########################################################################
3
4 #*************************************************************************
5 #
6# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7#
8# Copyright 2000, 2010 Oracle and/or its affiliates.
9#
10# OpenOffice.org - a multi-platform office productivity suite
11#
12# This file is part of OpenOffice.org.
13#
14# OpenOffice.org is free software: you can redistribute it and/or modify
15# it under the terms of the GNU Lesser General Public License version 3
16# only, as published by the Free Software Foundation.
17#
18# OpenOffice.org is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21# GNU Lesser General Public License version 3 for more details
22# (a copy is included in the LICENSE file that accompanied this code).
23#
24# You should have received a copy of the GNU Lesser General Public License
25# version 3 along with OpenOffice.org.  If not, see
26# <http://www.openoffice.org/license.html>
27# for a copy of the LGPLv3 License.
28#
29 #*************************************************************************
30
31####################################################################
32# File Name: template.pl
33# Version  : 1.0
34# Project  : XMerge
35# Author   : Brian Cameron
36# Date	   : 5th Sept. 2001
37#
38#
39# Takes x and y from the command line and taps the screen there.
40# Assumes pose is already running.
41#
42##########################################################################
43
44use POSIX "sys_wait_h";   # Need this for waitpid with WNOHANG
45use EmRPC;  # EmRPC::OpenConnection, CloseConnection
46use EmFunctions;
47use EmUtils;
48
49if ($#ARGV != 0)
50{
51  print "\nUsage: $0 timeout\n\n";
52  exit -1;
53}
54
55$timeout = $ARGV[0];
56
57if (!defined($up_pid = fork()))
58{
59   print "ERROR, problem forking.\n"
60}
61elsif ($up_pid)
62{
63   print "\nChecking to see if pose is started properly.\n";
64
65   # Parent process
66   #
67   sleep($timeout);
68
69   waitpid($up_pid, WNOHANG);
70
71   if (kill(0, $up_pid))
72   {
73      print "Pose did not start successfully...\n";
74      kill(9, $up_pid);
75      exit(-1);
76   }
77   else
78   {
79      # The child process exited okay, so we know it will not
80      # hang...but the open_connection will just die if pose
81      # isn't started...so try it in the parent.
82      #
83      open_connection();
84      close_connection();
85
86      print "Verified pose started successfully...\n";
87      exit(0);
88   }
89}
90else
91{
92   # Child process - Try to open/close the connection.  This
93   # can hang if pose did not start properly...
94   #
95   open_connection();
96   close_connection();
97}
98
99sub open_connection
100{
101  print "opening connection\n";
102  EmRPC::OpenConnection(6415, "localhost");
103}
104
105sub close_connection
106{
107  print "closing connection\n";
108  EmRPC::CloseConnection();
109}
110
111