/* Copyright 2004 Hewlett-Packard Development Company, L.P. Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. */ // // Test shareable image entry points. // // The test Stopwatch class (taken from the actual C++ Stopwatch class) // code exists in sw_shr.exe sharable image. // // Each of the class's public member functions need to be called to make sure // that they are accessable and functioning correctly. // // The test will also verify that the global G_sw object is accessable. This // object exists within the SW_SHR shareable image and is a test of // exporting a global class. // #include #include // test calls time() also #include "sw.hxx" void display_sw_state (Stopwatch &sw_param) { cout << " Status = " << sw_param.status() << " G_sw: = " << G_sw.status() << endl; cout << " SYSTEM CPU time = " << sw_param.system() << " G_sw: = " << G_sw.system() << endl; cout << " User CPU time = " << sw_param.user() << " G_sw: = " << G_sw.user() << endl; cout << " Real time = " << sw_param.real() << " G_sw: = " << G_sw.real() << endl; cout << " Resolution = " << sw_param.resolution() << " G_sw: = " << G_sw.resolution() << endl << endl; } int main () { Stopwatch test_timer; // constructor is called here if (time(0) == (time_t) -1) { cout << " time(0) returns -1 - stopwatch test exiting before failure" << endl; return 1; } cout << "Initial state: - Local:" << endl << endl; display_sw_state (test_timer); test_timer.start(); cout << "After call to start on local Stopwatch object :" << endl << endl; display_sw_state (test_timer); cout.flush(); cout << "Waiting 5 seconds..." << endl; while (test_timer.real() < 5.0) {}; cout << "After 5 seconds delay:" << endl << endl; display_sw_state (test_timer); if (G_sw.real() < test_timer.real()) { // // Sanity check, need to make sure that the global stopwatch // is running. // cout << "Error with test, Global stopwatch real time is less than local" << endl; return 1; } test_timer.reset(); cout << "Waiting 5 \"user time\" 5 seconds:" << endl; while (test_timer.user() < 5.0) {}; cout << "After 5 second wait:" << endl; display_sw_state (test_timer); // // Try stopping the global sw. // cout << "Stopping System timer:" << endl << endl; G_sw.stop(); if (G_sw.status() != 0) { cout << "Error - G_sw did not stop" << endl; } display_sw_state (G_sw); return 1; }