1 #include "ace/Get_Opt.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_NS_stdlib.h"
5 #include "ace/OS_NS_string.h"
7 // Static Singleton instance.
8 Options
*Options::instance_
= 0;
13 if (Options::instance_
== 0)
14 Options::instance_
= new Options ();
16 return Options::instance_
;
20 Options::program_name ()
22 return this->program_name_
;
26 Options::slave_name ()
28 return this->slave_name_
;
38 Options::exec_slave ()
40 return this->exec_slave_
;
44 Options::iteration_count ()
46 return this->iteration_count_
;
52 return this->use_sbrk_
;
56 Options::max_msg_size ()
58 return this->max_msg_size_
;
62 Options::spawn_count ()
64 return this->spawn_count_
;
68 Options::spawn_threads ()
70 return this->spawn_threads_
;
76 return this->use_mmap_
;
82 return this->use_shmem_
;
91 // Explain usage and exit.
94 Options::print_usage_and_die ()
96 //FUZZ: disable check_for_lack_ACE_OS
98 ACE_TEXT ("usage: %n")
99 ACE_TEXT ("\n[-d] (run in debugging mode)\n")
100 ACE_TEXT ("[-e] (use exec(2) in addition to fork(2))\n")
101 ACE_TEXT ("[-l] (use C++ new operator rather than sbrk(2)\n")
102 ACE_TEXT ("[-L max_msg_size]\n")
103 ACE_TEXT ("[-m] (use mmap rather than SysV shared memory)\n")
104 ACE_TEXT ("[-p] (use processes rather than threads)\n")
105 ACE_TEXT ("[-s] (use SysV shared memory rather than mmap)\n")
106 ACE_TEXT ("[-t number of threads or processes to spawn]\n")
107 ACE_TEXT ("[-T] (enable tracking)\n")
108 ACE_TEXT ("[-n iteration_count]\n")));
109 //FUZZ: enable check_for_lack_ACE_OS
118 iteration_count_ (100),
127 ACE_OS::strcpy (this->slave_name_
, "slave");
131 Options::parse_args (int argc
, ACE_TCHAR
*argv
[])
133 ACE_Get_Opt
get_opt (argc
, argv
, ACE_TEXT ("dehlL:mn:pst:T"));
135 ACE_OS::strcpy (this->program_name_
, ACE_TEXT_ALWAYS_CHAR (argv
[0]));
136 ACE_LOG_MSG
->open (argv
[0]);
138 // Put in a special-case check for child process.
139 if (ACE_OS::strcmp (this->program_name_
, slave_name_
) == 0)
146 (c
= get_opt ()) != -1;
155 this->exec_slave_
= 1;
158 this->print_usage_and_die ();
165 this->max_msg_size_
= ACE_OS::atoi (get_opt
.opt_arg ());
171 this->iteration_count_
= ACE_OS::atoi (get_opt
.opt_arg ());
173 case 'p': // Spawn processes rather than threads
174 this->spawn_threads_
= 0;
177 // Use System V shared memory...
178 this->use_shmem_
= 1;
181 this->spawn_count_
= ACE_OS::atoi (get_opt
.opt_arg ());
184 #if defined (ACE_HAS_TRACE)
185 ACE_Trace::start_tracing ();
186 #endif /* ACE_HAS_TRACE */
189 this->print_usage_and_die ();
195 // Switch to using MMAP when the -p and -e options are enabled.
196 if (this->exec_slave_
== 1 && this->spawn_threads_
== 0)