1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
5 # Fuzz is a script whose purpose is to check through ACE/TAO/CIAO files for
6 # easy to spot (by a perl script, at least) problems.
8 use lib
"$ENV{ACE_ROOT}/bin";
9 if (defined $ENV{srcdir
}) {
10 use lib
"$ENV{srcdir}/bin";
17 use PerlACE
::Run_Test
;
21 # Add tests for these:
23 # - Guards in .h files
24 # - no global functions
25 # - other commit_check checks
27 # And others in ACE_Guidelines and Design Rules
29 # Also add a -g flag to ignore tao_idl generated files
33 # Lists of all the files
45 @files_changelog = ();
59 # To keep track of errors and warnings
63 # to register suppressed tests
64 %suppressed_tests = ();
66 # to register excluded directories
69 ##############################################################################
71 # Use 'svn -q st' to get a list of locally modified
72 # files to look through
73 sub find_mod_svn_files
()
75 unless (open (SVN
, "svn -q st |")) {
76 print STDERR
"Error: Could not run svn\n";
81 # 1234567 (see "svn help st" for column definitions)
82 if (/^[MA].....\s+(.*)$/) {
90 # Use 'git status -s' to get a list of locally modified
91 # files to look through
92 sub find_mod_git_files
()
94 unless (open (GIT
, "git status -s |")) {
95 print STDERR
"Error: Could not run git\n";
100 if (/^ [MA] +(.*)$/) {
108 sub find_mod_files
()
110 if (!(find_mod_svn_files
() && find_mod_git_files
())) {
111 print "Could use neither svn nor git to find modified files\n";
119 # exclude will contain the full file name
121 foreach (@excluded_dirs) {
122 if ($exclude =~ /$_/) {
129 # Find_Files will search for files with certain extensions in the
133 # wanted is only used for the File::Find
136 store_file
($File::Find
::name
);
139 find
(\
&wanted
, '.');
147 return if is_excluded
($name);
149 if ($name =~ /\.(c|cc|cpp|cxx|tpp)$/i) {
150 push @files_cpp, ($name);
152 elsif ($name =~ /\.(inl|i)$/i) {
153 push @files_inl, ($name);
155 elsif ($name =~ /\.(h|hh|hpp|hxx)$/i) {
156 push @files_h, ($name);
158 elsif ($name =~ /\.(htm|html)$/i) {
159 push @files_html, ($name);
161 elsif ($name =~ /\.(bor)$/i) {
162 push @files_bor, ($name);
164 elsif ($name =~ /\.(GNU)$/i) {
165 push @files_gnu, ($name);
167 elsif ($name =~ /\.(dsp|vcp)$/i) {
168 push @files_dsp, ($name);
170 elsif ($name =~ /\.(dsw|vcp)$/i) {
171 push @files_dsw, ($name);
173 elsif ($name =~ /\.(pidl|idl|idl3|idl3p)$/i) {
174 push @files_idl, ($name);
176 elsif ($name =~ /\.pl$/i) {
177 if ($name =~ /fuzz.pl/) {
180 push @files_pl, ($name);
181 if ($name =~ /^run.*\.pl$/i) {
182 push @files_run_pl, ($name);
185 elsif ($name =~ /\.py$/i) {
186 push @files_py, ($name);
188 elsif ($name =~ /\.(rb|erb)$/i) {
189 push @files_rb, ($name);
191 elsif ($name =~ /\.features$/i) {
192 push @files_features, ($name);
194 elsif ($name =~ /\.vcproj$/i) {
195 push @files_vcproj, ($name);
197 elsif ($name =~ /\.sln$/i) {
198 push @files_sln, ($name);
200 elsif ($name =~ /ChangeLog/i && -f
$name) {
201 push @files_changelog, ($name);
203 elsif ($name =~ /\/GNUmakefile
.*.[^~]$/) {
204 push @files_makefile, ($name);
206 elsif ($name =~ /\.(mpc|mwc|mpb|mpt)$/i) {
207 push @files_mpc, ($name);
209 elsif ($name =~ /\.(icc|ncb|zip)$/i) {
210 push @files_noncvs, ($name);
212 elsif ($name =~ /\.(cdp)$/i) {
213 push @files_cdp, ($name);
215 elsif ($name =~ /\.(doxygen)$/i) {
216 push @files_doxygen, ($name);
218 elsif ($name =~ /\.(conf)$/i) {
219 if ($name =~ /\.(WCHAR_T.conf|UTF-16.conf)$/i) {
222 push @files_conf, ($name);
224 elsif ($name =~ /\.(conf.xml)$/i) {
225 if ($name =~ /\.(WCHAR_T.conf.xml|UTF-16.conf.xml)$/i) {
228 push @files_conf, ($name);
230 elsif ($name =~ /\.(pm|cmd|java|sh|txt|xml)$/i) {
231 push @files_generic, ($name);
233 elsif ($name =~ /README$/i) {
234 push @files_generic, ($name);
238 ##############################################################################
244 print "Error: $msg\n";
249 sub print_warning
($)
252 print "Warning: $msg\n";
256 ##############################################################################
257 ## Check if test is suppressed
261 my $method = (split (/::/, (caller(1))[3]))[-1];
262 return (defined $suppressed_tests{$method} ?
1 : 0);
265 ##############################################################################
268 # The point of this test is to check for the existence of ACE_INLINE
269 # or ASYS_INLINE in a .cpp file. This is most commonly caused by
270 # copy/pasted code from a .inl/.i file
271 sub check_for_inline_in_cpp
()
273 return if is_suppressed
();
275 print "Running ACE_INLINE/ASYS_INLINE check\n";
276 foreach $file (@files_cpp) {
277 if (open (FILE
, $file)) {
278 print "Looking at file $file\n" if $opt_d;
281 print_error
("$file:$.: ACE_INLINE found");
283 if (/^ASYS_INLINE/) {
284 print_error
("$file:$.: ASYS_INLINE found");
290 print STDERR
"Error: Could not open $file\n";
295 # This test checks to make sure we have no files with $Id string in them.
296 sub check_for_id_string
()
298 return if is_suppressed
();
300 print "Running \$Id\$ string check\n";
301 foreach $file (@files_cpp, @files_inl, @files_h, @files_mpc, @files_bor,
302 @files_gnu, @files_html, @files_idl, @files_pl,
303 @files_cdp, @files_py, @files_conf, @files_generic, @files_features) {
305 if (open (FILE
, $file)) {
306 print "Looking at file $file\n" if $opt_d;
309 print_error
("$file:$.: Incorrect \$id\$ found (correct casing)");
312 print_error
("$file:$.: Incorrect \$Id:\$ found (remove colon)");
314 if (/\$Id\$/ || /\$Id: /) {
320 print_error
("$file: \$Id\$ string found, not used anymore.");
324 print STDERR
"Error: Could not open $file\n";
330 sub check_for_msc_ver_string
()
332 return if is_suppressed
();
334 print "Running _MSC_VER check\n";
335 foreach $file (@files_cpp, @files_inl, @files_h) {
337 if (open (FILE
, $file)) {
340 print "Looking at file $file\n" if $opt_d;
342 if (/FUZZ\: disable check_for_msc_ver/) {
345 if (/FUZZ\: enable check_for_msc_ver/) {
348 if ($disable == 0 and /\_MSC_VER \<= 1200/) {
352 if ($disable == 0 and /\_MSC_VER \>= 1200/) {
356 if ($disable == 0 and /\_MSC_VER \> 1200/) {
360 if ($disable == 0 and /\_MSC_VER \< 1300/) {
364 if ($disable == 0 and /\_MSC_VER \<= 1300/) {
368 if ($disable == 0 and /\_MSC_VER \>= 1300/) {
372 if ($disable == 0 and /\_MSC_VER \< 1310/) {
376 if ($disable == 0 and /\_MSC_VER \>= 1310/) {
383 print_error
("$file:$mscline: Incorrect _MSC_VER check found");
387 print STDERR
"Error: Could not open $file\n";
392 # This test checks for the newline at the end of a file
393 sub check_for_newline
()
395 return if is_suppressed
();
397 print "Running newline check\n";
398 foreach $file (@files_cpp, @files_inl, @files_h,
399 @files_html, @files_idl, @files_pl) {
400 if (open (FILE
, $file)) {
402 print "Looking at file $file\n" if $opt_d;
407 if ($line !~ /\n$/) {
408 print_error
("$file:$.: No ending newline found in $file");
412 print STDERR
"Error: Could not open $file\n";
418 # This test checks for files that are not allowed to be in svn
419 sub check_for_noncvs_files
()
421 return if is_suppressed
();
423 print "Running non svn files check\n";
424 foreach $file (@files_noncvs, @files_dsp, @files_dsw, @files_makefile, @files_bor) {
425 print_error
("File $file should not be in svn!");
429 # This test checks for the use of ACE_SYNCH_MUTEX in TAO/CIAO,
430 # TAO_SYNCH_MUTEX should used instead.
432 sub check_for_ACE_SYNCH_MUTEX
()
434 return if is_suppressed
();
436 print "Running ACE_SYNCH_MUTEX check\n";
437 ITERATION
: foreach $file (@files_cpp, @files_inl, @files_h) {
438 if (open (FILE
, $file)) {
440 print "Looking at file $file\n" if $opt_d;
442 if (/FUZZ\: disable check_for_ACE_SYNCH_MUTEX/) {
445 if (/FUZZ\: enable check_for_ACE_SYNCH_MUTEX/) {
449 if ($disable == 0 and /ACE_SYNCH_MUTEX/) {
450 # It is okay to use ACE_SYNCH_MUTEX in ACE
451 # so don't check the ACE directory. The below
452 # will check it for TAO and CIAO.
453 if (($file !~ /.*TAO.*/)) {
457 # Disable the check in the ESF directory for the
458 # time being until we fix the issues there.
459 if(($file =~ /.*TAO\/orbsvcs\
/orbsvcs\/ESF
.*/)) {
463 print_error
("$file:$.: found ACE_SYNCH_MUTEX, use TAO_SYNCH_MUTEX instead");
469 print STDERR
"Error: Could not open $file\n";
474 # This test checks for not having export files in CIAO, all have to be ---
475 # generated using TAO_IDL. If you have a file that must be in the repository
476 # remove the generated automatically by line
477 sub check_for_export_file
()
479 return if is_suppressed
();
481 print "Running export file check\n";
482 ITERATION
: foreach $file (@files_h) {
483 if (($file =~ /.*CIAO.*export.h/) || ($file =~ /.*DAnCE.*export.h/)) {
484 if (open (FILE
, $file)) {
485 print "Looking at file $file\n" if $opt_d;
487 if (/generated automatically by/) {
488 print_error
("$file:$.: file should be generated by TAO_IDL, check -Gxh** option");
494 print STDERR
"Error: Could not open $file\n";
501 # This test checks for the use of ACE_Thread_Mutex in TAO/CIAO,
502 # TAO_SYNCH_MUTEX should used instead to make the code build
503 # in single-threaded builds.
504 sub check_for_ACE_Thread_Mutex
()
506 return if is_suppressed
();
508 print "Running ACE_Thread_Mutex check\n";
509 ITERATION
: foreach $file (@files_cpp, @files_inl, @files_h) {
510 if (open (FILE
, $file)) {
512 print "Looking at file $file\n" if $opt_d;
514 if (/FUZZ\: disable check_for_ACE_Thread_Mutex/) {
517 if (/FUZZ\: enable check_for_ACE_Thread_Mutex/) {
521 if ($disable == 0 and /ACE_Thread_Mutex/) {
522 # It is okay to use ACE_Thread_Mutex in ACE
523 # so don't check the ACE directory. The below
524 # will check it for TAO and CIAO.
525 if (($file !~ /.*TAO.*/)) {
529 print_error
("$file:$.: found ACE_Thread_Mutex, use TAO_SYNCH_MUTEX instead to allow the code to work in single-threaded builds");
535 print STDERR
"Error: Could not open $file\n";
540 # This test checks for the use of ACE_Guard
541 # ACE_GUARD should used because it checks if we really got a lock
542 # in single-threaded builds.
543 sub check_for_ACE_Guard
()
545 return if is_suppressed
();
547 print "Running ACE_Guard check\n";
548 ITERATION
: foreach $file (@files_cpp, @files_inl, @files_h) {
549 if (open (FILE
, $file)) {
551 print "Looking at file $file\n" if $opt_d;
553 if (/FUZZ\: disable check_for_ACE_Guard/) {
556 if (/FUZZ\: enable check_for_ACE_Guard/) {
560 if ($disable == 0 and /ACE_Guard/) {
561 print_error
("$file:$.: found ACE_Guard, use ACE_GUARD");
563 if ($disable == 0 and /ACE_Read_Guard/) {
564 print_error
("$file:$.: found ACE_Read_Guard, use ACE_READ_GUARD");
566 if ($disable == 0 and /ACE_Write_Guard/) {
567 print_error
("$file:$.: found ACE_Write_Guard, use ACE_WRITE_GUARD");
573 print STDERR
"Error: Could not open $file\n";
578 # This test checks for the use of tabs, spaces should be used instead of tabs
581 return if is_suppressed
();
583 print "Running tabs check\n";
584 ITERATION
: foreach $file (@files_cpp, @files_inl, @files_h, @files_idl, @files_cdp, @files_doxygen, @files_changelog) {
585 if (open (FILE
, $file)) {
587 print "Looking at file $file\n" if $opt_d;
589 if (/FUZZ\: disable check_for_tab/) {
592 if (/FUZZ\: enable check_for_tab/) {
595 if ($disable == 0 and /.*\t.*/) {
596 print_error
("$file:$.: found tab");
602 print STDERR
"Error: Could not open $file\n";
607 sub check_for_trailing_whitespace
()
609 return if is_suppressed
();
611 print "Running trailing_whitespaces check\n";
612 ITERATION
: foreach $file (@files_cpp, @files_inl, @files_h, @files_idl,
613 @files_cdp, @files_pl, @files_py, @files_generic) {
614 if (open (FILE
, $file)) {
616 print "Looking at file $file\n" if $opt_d;
618 if (/FUZZ\: disable check_for_trailing_whitespace/) {
621 if (/FUZZ\: enable check_for_trailing_whitespace/) {
624 if ($disable == 0 and /\s\n$/) {
625 print_error
("$file:$.: found trailing whitespace");
631 print STDERR
"Error: Could not open $file\n";
636 # This test checks for the lack of ACE_OS
637 sub check_for_lack_ACE_OS
()
639 return if is_suppressed
();
641 $OS_NS_arpa_inet_symbols = "inet_addr|inet_aton|inet_ntoa|inet_ntop|inet_pton";
643 $OS_NS_ctype_symbols = "isalnum|isalpha|iscntrl|isdigit|isgraph|islower|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper|isblank|isascii|isctype|iswctype";
645 $OS_NS_dirent_symbols = "closedir|opendir|readdir|readdir_r|rewinddir|scandir|alphasort|seekdir|telldir|opendir_emulation|scandir_emulation|closedir_emulation|readdir_emulation";
647 $OS_NS_dlfcn_symbols = "dlclose|dlerror|dlopen|dlsym";
649 $OS_NS_errno_symbols = "last_error|set_errno_to_last_error|set_errno_to_wsa_last_error";
651 $OS_NS_fcntl_symbols = "fcntl|open";
653 $OS_NS_math_symbols = "floor|ceil|log2";
655 $OS_NS_netdb_symbols = "gethostbyaddr|gethostbyaddr_r|gethostbyname|gethostbyname_r|getipnodebyaddr|getipnodebyname|getmacaddress|getprotobyname|getprotobyname_r|getprotobynumber|getprotobynumber_r|getservbyname|getservbyname_r|netdb_acquire|netdb_release";
657 $OS_NS_poll_symbols = "poll";
659 $OS_NS_pwd_symbols = "endpwent|getpwent|getpwnam|getpwnam_r|setpwent";
661 $OS_NS_regex_symbols = "compile|step";
663 $OS_NS_signal_symbols = "kill|pthread_sigmask|sigaction|sigaddset|sigdelset|sigemptyset|sigfillset|sigismember|signal|sigprocmask|sigsuspend|raise";
665 $OS_NS_stdio_symbols = "fileno|checkUnicodeFormat|clearerr|cuserid|fclose|fdopen|fflush|fgetc|getc|fgetpos|fgets|flock_adjust_params|flock_init|flock_destroy|flock_rdlock|flock_tryrdlock|flock_trywrlock|flock_unlock|flock_wrlock|fopen|default_win32_security_attributes|default_win32_security_attributes_r|get_win32_versioninfo|get_win32_resource_module|set_win32_resource_module|fprintf|ungetc|fputc|putc|fputs|fread|freopen|fseek|fsetpos|ftell|fwrite|perror|printf|puts|rename|rewind|snprintf|sprintf|tempnam|vsprintf|vsnprintf|asprintf|aswprintf|vasprintf|vaswprintf";
667 $OS_NS_stdlib_symbols = "_exit|abort|atexit|atof|atol|atoi|atop|bsearch|calloc|exit|free|getenv|getenvstrings|itoa|itoa_emulation|itow_emulation|malloc|mkstemp|mkstemp_emulation|mktemp|setenv|unsetenv|putenv|qsort|rand|rand_r|realloc|realpath|set_exit_hook|srand|strenvdup|strtod|strtol|strtol_emulation|strtoul|strtoul_emulation|strtoll|strtoll_emulation|strtoull|strtoull_emulation|system|getprogname|setprogname";
669 $OS_NS_string_symbols = "memchr|memchr_emulation|memcmp|memcpy|fast_memcpy|memmove|memset|strcat|strchr|strcmp|strcpy|strcspn|strdup|strdup_emulation|strecpy|strerror|strerror_emulation|strsignal|strlen|strncat|strnchr|strncmp|strncpy|strnlen|strnstr|strpbrk|strrchr|strrchr_emulation|strsncpy|strspn|strstr|strtok|strtok_r|strtok_r_emulation";
671 $OS_NS_strings_symbols = "strcasecmp|strncasecmp|strcasecmp_emulation";
673 $OS_NS_stropts_symbols = "getmsg|getpmsg|fattach|fdetach|ioctl|isastream|putmsg|putpmsg";
675 $OS_NS_sys_mman_symbols = "madvise|mmap|mprotect|msync|munmap|shm_open|shm_unlink";
677 $OS_NS_sys_msg_symbols = "msgctl|msgget|msgrcv|msgsnd";
679 $OS_NS_sys_resource_symbols = "getrlimit|getrusage|setrlimit";
681 $OS_NS_sys_select_symbols = "select";
683 $OS_NS_sys_sendfile_symbols = "sendfile|sendfile_emulation";
685 $OS_NS_sys_shm_symbols = "shmat|shmctl|shmdt|shmget";
687 $OS_NS_sys_socket_symbols = "accept|bind|closesocket|connect|enum_protocols|getpeername|getsockname|getsockopt|join_leaf|listen|recv|recvfrom|recvmsg|recvv|send|sendmsg|sendto|sendv|setsockopt|shutdown|if_nametoindex|if_indextoname|if_nameindex|socket_init|socket_fini|socket|socketpair";
689 $OS_NS_sys_stat_symbols = "creat|filesize|fstat|lstat|mkdir|mkfifo|stat|umask";
691 $OS_NS_sys_time_symbols = "gettimeofday";
693 $OS_NS_sys_uio_symbols = "readv|readv_emulation|writev|writev_emulation";
695 $OS_NS_sys_utsname_symbols = "uname";
697 $OS_NS_sys_wait_symbols = "wait|waitpid";
699 $OS_NS_Thread_symbols = "cleanup_tss|condattr_init|condattr_destroy|cond_broadcast|cond_destroy|cond_init|cond_signal|cond_timedwait|cond_wait|event_destroy|event_init|event_pulse|event_reset|event_signal|event_timedwait|event_wait|lwp_getparams|lwp_setparams|mutex_destroy|mutex_init|mutex_lock|mutex_lock_cleanup|mutex_trylock|mutex_unlock|priority_control|recursive_mutex_cond_unlock|recursive_mutex_cond_relock|recursive_mutex_destroy|recursive_mutex_init|recursive_mutex_lock|recursive_mutex_trylock|recursive_mutex_unlock|rw_rdlock|rw_tryrdlock|rw_trywrlock|rw_trywrlock_upgrade|rw_unlock|rw_wrlock|rwlock_destroy|rwlock_init|sched_params|scheduling_class|sema_destroy|sema_init|sema_post|sema_trywait|sema_wait|semctl|semget|semop|set_scheduling_params|sigtimedwait|sigwait|sigwaitinfo|thr_cancel|thr_cmp|thr_continue|thr_create|thr_equal|thr_exit|thr_getconcurrency|thr_getprio|thr_getspecific_native|thr_getspecific|thr_join|thr_get_affinity|thr_set_affinity|thr_key_detach|thr_key_used|thr_keycreate_native|thr_keycreate|thr_keyfree|thr_kill|thr_min_stack|thr_self|thr_setcancelstate|thr_setcanceltype|thr_setconcurrency|thr_setprio|thr_setspecific_native|thr_setspecific|thr_sigsetmask|thr_suspend|thr_testcancel|thr_yield|thread_mutex_destroy|thread_mutex_init|thread_mutex_lock|thread_mutex_trylock|thread_mutex_unlock|unique_name";
701 $OS_NS_time_symbols = "asctime|asctime_r|clock_gettime|clock_settime|ctime|ctime_r|difftime|gmtime|gmtime_r|localtime|localtime_r|mktime|nanosleep|readPPCTimeBase|strftime|strptime|strptime_emulation|strptime_getnum|time|timezone|tzset";
703 $OS_NS_unistd_symbols = "access|alarm|allocation_granularity|argv_to_string|chdir|rmdir|close|dup|dup2|execl|execle|execlp|execv|execve|execvp|fork|fork_exec|fsync|ftruncate|getcwd|getgid|getegid|getopt|getpagesize|getpgid|getpid|getppid|getuid|geteuid|hostname|isatty|lseek|llseek|num_processors|num_processors_online|pipe|pread|pwrite|read|read_n|readlink|sbrk|setgid|setegid|setpgid|setregid|setreuid|setsid|setuid|seteuid|sleep|string_to_argv|swab|sysconf|sysinfo|truncate|ualarm|unlink|write|write_n";
705 $OS_NS_wchar_symbols = "fgetwc|wcscat_emulation|wcschr_emulation|wcscmp_emulation|wcscpy_emulation|wcscspn_emulation|wcsicmp_emulation|wcslen_emulation|wcsncat_emulation|wcsncmp_emulation|wcsncpy_emulation|wcsnicmp_emulation|wcspbrk_emulation|wcsrchr_emulation|wcsrchr_emulation|wcsspn_emulation|wcsstr_emulation|wslen|wscpy|wscmp|wsncmp|ungetwc";
707 print "Running ACE_OS check\n";
708 foreach $file (@files_cpp, @files_inl) {
709 if (open (FILE
, $file)) {
711 print "Looking at file $file\n" if $opt_d;
713 if (/FUZZ\: disable check_for_lack_ACE_OS/) {
716 if (/FUZZ\: enable check_for_lack_ACE_OS/) {
720 if($file !~ /.c$/ && $file !~ /S.cpp$/ && $file !~ /S.inl$/ && $file !~ /C.cpp$/ && $file !~ /C.inl$/) {
721 if($file !~ /OS_NS_arpa_inet/) {
722 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_arpa_inet_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
723 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_arpa_inet.h");
726 if($file !~ /OS_NS_ctype/) {
727 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_ctype_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
728 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_ctype.h");
731 if($file !~ /OS_NS_dirent/) {
732 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_dirent_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
733 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_dirent.h");
736 if($file !~ /OS_NS_dlfcn/) {
737 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_dlfcn_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
738 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_dlfcn.h");
741 if($file !~ /OS_NS_errno/) {
742 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_errno_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
743 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_errno.h");
746 if($file !~ /OS_NS_fcntl/) {
747 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_fcntl_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
748 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_fcntl.h");
751 if($file !~ /OS_NS_math/) {
752 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_math_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
753 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_math.");
756 if($file !~ /OS_NS_netdb/) {
757 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_netdb_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
758 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_netdb.h");
761 if($file !~ /OS_NS_poll/) {
762 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_netdb_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
763 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_poll.h");
766 if($file !~ /OS_NS_pwd/) {
767 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_pwd_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
768 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_pwd.h");
771 if($file !~ /OS_NS_regex/) {
772 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_regex_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
773 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_regex.h");
776 if($file !~ /OS_NS_signal/) {
777 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_signal_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
778 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_signal.h");
781 if($file !~ /OS_NS_stdlib/) {
782 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_stdlib_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
783 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_stdlib.h");
786 if($file !~ /OS_NS_stdio/) {
787 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_stdio_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
788 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_stdio.h");
791 if($file !~ /OS_NS_string/) {
792 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_string_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
793 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_string.h");
796 if($file !~ /OS_NS_strings/) {
797 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_strings_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
798 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_strings.h");
801 if($file !~ /OS_NS_stropts/) {
802 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_stropts_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
803 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_stropts.h");
806 if($file !~ /OS_NS_sys_mman/) {
807 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_mman_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
808 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_mman.h");
811 if($file !~ /OS_NS_sys_msg/) {
812 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_msg_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
813 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_msg.h");
816 if($file !~ /OS_NS_sys_resource/) {
817 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_resource_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
818 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_resource.h");
821 if($file !~ /OS_NS_sys_select/) {
822 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_select_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
823 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_select.h");
826 if($file !~ /OS_NS_sys_sendfile/) {
827 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_sendfile_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
828 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_sendfile.h");
831 if($file !~ /OS_NS_sys_shm/) {
832 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_shm_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
833 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_shm.h");
836 if($file !~ /OS_NS_sys_socket/) {
837 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_socket_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
838 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_socket.h");
841 if($file !~ /OS_NS_sys_stat/) {
842 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_stat_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
843 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_stat.h");
846 if($file !~ /OS_NS_sys_time/) {
847 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_time_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
848 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_time.h");
851 if($file !~ /OS_NS_sys_uio/) {
852 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_uio_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
853 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_uio.h");
856 if($file !~ /OS_NS_sys_utsname/) {
857 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_utsname_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
858 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_utsname.h");
861 if($file !~ /OS_NS_sys_wait/) {
862 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_sys_wait_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
863 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_sys_wait.h");
866 if($file !~ /OS_NS_Thread/) {
867 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_Thread_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
868 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_Thread.h");
871 if($file !~ /OS_NS_time/) {
872 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_time_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
873 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_time.h");
876 if($file !~ /OS_NS_unistd/) {
877 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_unistd_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
878 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_unistd.h");
881 if($file !~ /OS_NS_wchar/) {
882 if(/(\s+:{0,2}|\(:{0,2}|\s*!:{0,2}|^|\):{0,2})($OS_NS_wchar_symbols)\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
883 print_error
("$file:$.: missing ACE_OS use ace/OS_NS_wchar.h");
892 print STDERR
"Error: Could not open $file\n";
897 # This test checks for the use of exception specification,
898 # exception specification has fallen out of favor, and generally
899 # should not be used.
900 sub check_for_exception_spec
()
902 return if is_suppressed
();
904 print "Running exception specification check\n";
906 foreach $file (@files_cpp, @files_inl, @files_h) {
907 if (open (FILE
, $file)) {
909 print "Looking at file $file\n" if $opt_d;
911 if (/FUZZ\: disable check_for_exception_sepc/) {
914 if (/FUZZ\: enable check_for_exception_sepc/) {
918 if(/throw\s*\(\s*\)/) {
921 elsif(/(^|\s+)throw\s*\(/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
922 print_error
("$file:$.: exception specification found");
929 print STDERR
"Error: Could not open $file\n";
934 # This test checks for the use of NULL,
935 # NULL shouldn't be used, use 0 instead
936 sub check_for_NULL
()
938 return if is_suppressed
();
940 print "Running NULL usage check\n";
942 foreach $file (@files_cpp, @files_inl, @files_h) {
943 if (open (FILE
, $file)) {
945 print "Looking at file $file\n" if $opt_d;
947 if (/FUZZ\: disable check_for_NULL/) {
950 if (/FUZZ\: enable check_for_NULL/) {
954 if(/(\(|\)|\s+|=)NULL(\)|\s+|\;|\,)/ and $` !~ /\/\// and $` !~ /\/\
*/ and $` !~ /\
*\
*+/ and $` !~ /\s
+\
*+\s
+/) {
955 print_error
("$file:$.: NULL found");
962 print STDERR
"Error: Could not open $file\n";
967 # This test checks for improper main declaration,
968 # the proper form should look like:
969 # int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
970 sub check_for_improper_main_declaration
()
972 return if is_suppressed
();
974 print "Running Improper main() declaration check\n";
976 foreach $file (@files_cpp) {
977 if (open (FILE
, $file)) {
981 my $not_found_end_line_count= 0;
982 print "Looking at file $file\n" if $opt_d;
984 if (!defined $multi_line) {
985 if (/FUZZ\: disable check_for_improper_main_declaration/) {
989 elsif (/FUZZ\: enable check_for_improper_main_declaration/) {
993 elsif ($disable == 0) {
994 s/^\s+//; ## Remove leading space
995 s/\s*(\/\/.*)?
$//; ## Remove trailing space and line comments
996 if (s/^(?:.*\s)?(main|ACE_TMAIN)\s*//) {
997 $type_of_main = $1; ## main or ACE_TMAIN
998 $multi_line = $_; ## Rest of the line
1006 $_ =~ s/^\s+//; ## Remove leading space
1007 $_ =~ s/\s*(\/\/.*)?
$//; ## Remove trailling space and line comments
1008 if ($multi_line eq "") { ## Append this line to existing statement.
1012 $multi_line .= ' ' . $_;
1015 $multi_line =~ s!^(/+\*.*?\*/\s*)*!!; ## Remove leading /* ... */ comments
1016 next if ($multi_line eq ""); ## Must have something after main
1017 if ($multi_line !~ m/^\(/) {
1018 ## Not a function opening bracket, we will ignore this one
1019 ## it is not a main function.
1021 $not_found_end_line_count = 0;
1023 elsif ($multi_line =~ s/^\(\s*([^\)]*?)\s*\)[^;\{]*?\{//) {
1024 $multi_line = $1; ## What was between the main's ( and )
1025 $multi_line =~ s/\s{2,}/ /g; ## Compress white space
1026 my $was = $multi_line;
1027 $multi_line =~ s!([^/])\*\s([^/])!$1\*$2!g; ## Remove space after * (except around comment)
1028 $multi_line =~ s!([^/])\s\[!$1\[!g; ## Remove space before [ (except following comment)
1029 $multi_line =~ s!\s?\*/\s?/\*\s?! !g; ## Connect seporate adjacent /* ... */ comments
1030 if ($multi_line =~ s!^([^,]*?)\s?,\s?(/+\*.*?\*/\s?)*!!) { # Fails if only 1 parameter (ignore this main)
1032 if ($multi_line =~ s/^(\w[\w\d]*)\s?//) { # Fails if no type for 2nd parameter (ignore this main)
1034 $multi_line =~ s!^(?:/+\*.*?\*/\s?)?(\**)(\w[\w\d]*|\s?/\*.*?\*/\s?)?!!;
1035 my $prefix = $1; ## should be * or **
1036 my $name = $2; ## is now arg2's variable name
1037 $multi_line =~ s!\s?\*/\s?/\*\s?! !g; ## Connect seporate adjacent /* ... */ comments
1039 ## remove any comment after postfix
1040 if ($multi_line =~ s!\s?(/+\*.*?\*/)$!! && $name eq '') {
1041 $name = "$1 "; ## Some name argv in comment after []
1043 ## multi_line now postfix, should be []
1045 if ($type_of_main ne 'ACE_TMAIN' ||
1046 $arg2_type ne 'ACE_TCHAR' ||
1047 !(($prefix eq '*' && $multi_line eq '[]') ||
1048 ($prefix eq '**' && $multi_line eq '' )) ) {
1049 print_error
("$file:$.: $type_of_main ($was) should be ACE_TMAIN ($arg1, ACE_TCHAR \*$name\[])");
1055 $not_found_end_line_count = 0;
1057 elsif ($not_found_end_line_count < 10) { # Limit the search for ( ... ) following main to ten lines
1058 ++$not_found_end_line_count;
1062 $not_found_end_line_count = 0;
1068 print STDERR
"Error: Could not open $file\n";
1073 # This test checks for the use of "inline" instead of ACE_INLINE
1074 sub check_for_inline
()
1076 return if is_suppressed
();
1078 print "Running inline check\n";
1079 foreach $file (@files_inl) {
1080 if (open (FILE
, $file)) {
1082 print "Looking at file $file\n" if $opt_d;
1084 if (/FUZZ\: disable check_for_inline/) {
1087 if (/FUZZ\: enable check_for_inline/) {
1090 if ($disable == 0 and m/^\s*inline/) {
1091 print_error
("$file:$.: 'inline' keyword found");
1097 print STDERR
"Error: Could not open $file\n";
1103 # This test checks for the inclusion of math.h. math.h should be avoided
1104 # since on some platforms, "exceptions" is defined as a struct, which will
1105 # cause problems with exception handling
1106 sub check_for_math_include
()
1108 return if is_suppressed
();
1110 print "Running math.h test\n";
1111 foreach $file (@files_h, @files_cpp, @files_inl) {
1112 if (open (FILE
, $file)) {
1114 print "Looking at file $file\n" if $opt_d;
1116 if (/FUZZ\: disable check_for_math_include/) {
1119 if (/FUZZ\: enable check_for_math_include/) {
1123 and /^\s*#\s*include\s*(\/\
*\
*\
/){0,1}\s*\<math\.h\>/) {
1124 print_error
("$file:$.: <math.h> included");
1130 print STDERR
"Error: Could not open $file\n";
1135 # This test checks for the inclusion of streams.h.
1136 # // FUZZ: disable check_for_streams_include
1137 sub check_for_streams_include
()
1139 return if is_suppressed
();
1141 print "Running ace/streams.h test\n";
1142 foreach $file (@files_h, @files_cpp, @files_inl) {
1143 if (open (FILE
, $file)) {
1145 print "Looking at file $file\n" if $opt_d;
1147 if (/FUZZ\: disable check_for_streams_include/) {
1150 if (/FUZZ\: enable check_for_streams_include/) {
1154 and /^\s*#\s*include\s*\"ace\/streams\
.h
\"/) {
1155 print_error
("$file:$.: expensive ace/streams.h included; consider ace/iosfwd.h");
1156 print " ace/streams.h is very expensive in both ";
1157 print "compile-time and footprint. \n";
1158 print " Please consider including ace/iosfwd.h instead.\n\n";
1164 print STDERR
"Error: Could not open $file\n";
1169 # This test checks for the inclusion of Synch*.h.
1170 sub check_for_synch_include
()
1172 return if is_suppressed
();
1174 print "Running ace/Synch*.h test\n";
1175 foreach $file (@files_h, @files_cpp, @files_inl) {
1176 if (open (FILE
, $file)) {
1178 print "Looking at file $file\n" if $opt_d;
1180 if (/FUZZ\: disable check_for_synch_include/) {
1183 if (/FUZZ\: enable check_for_synch_include/) {
1187 and (/^\s*#\s*include\s*\"(ace\/Synch\
.h
)\"/
1188 or /^\s*#\s*include\s*\"(ace\/Synch_T\
.h
)\"/)) {
1190 print_error
("$file:$.: expensive $synch included; consider individual synch file");
1191 print " $synch is very expensive in both ";
1192 print "compile-time and footprint. \n";
1193 print " Please consider including one of the ";
1194 print "individual synch files instead.\n\n";
1200 print STDERR
"Error: Could not open $file\n";
1205 # For general readability, lines should not contain more than 80 characters
1206 sub check_for_line_length
()
1208 return if is_suppressed
();
1210 print "Running line length test\n";
1211 foreach $file (@files_h, @files_cpp, @files_inl) {
1212 if (open (FILE
, $file)) {
1213 print "Looking at file $file\n" if $opt_d;
1216 # Make sure to ignore ACE_RCSID lines, since they
1217 # are difficult to get under 80 chars.
1218 if (/.{80,}/ and !/^ACE_RCSID/) {
1219 print_error
("$file:$.: line longer than 80 chars");
1225 print STDERR
"Error: Could not open $file\n";
1231 # For preprocessor directives, only the old C style comments (/* */)
1232 # should be used, not the newer // style.
1233 sub check_for_preprocessor_comments
()
1235 return if is_suppressed
();
1237 print "Running preprocessor comment test\n";
1238 foreach $file (@files_h, @files_cpp, @files_inl) {
1239 if (open (FILE
, $file)) {
1240 print "Looking at file $file\n" if $opt_d;
1243 print_error
("$file:$.: C++ comment in directive");
1249 print STDERR
"Error: Could not open $file\n";
1254 # We should not have empty files in the repo
1255 sub check_for_empty_files
()
1257 return if is_suppressed
();
1259 print "Running empty file test\n";
1260 foreach $file (@files_inl, @files_cpp, @files_rb) {
1261 my $found_non_empty_line = 0;
1262 if (open (FILE
, $file)) {
1263 print "Looking at file $file\n" if $opt_d;
1265 next if /^[[:blank:]]*$/; # skip empty lines
1266 next if /^[[:blank:]]*\/\
//; # skip C++ comments
1267 next if /^[[:blank:]]*\/\
*/; # skip C++ comments
1268 $found_non_empty_line = 1;
1272 if ($found_non_empty_line == 0) {
1273 print_error
("$file:1: empty file should not be in the repository");
1277 print STDERR
"Error: Could not open $file\n";
1283 # This test checks for the use of the Win32 Unicode string defines
1284 # or outdated ASYS_* macros
1285 # We should only be using the ACE_TCHAR, ACE_TEXT macros instead.
1288 return if is_suppressed
();
1290 print "Running TCHAR test\n";
1291 foreach $file (@files_h, @files_cpp, @files_inl) {
1292 if (open (FILE
, $file)) {
1294 print "Looking at file $file\n" if $opt_d;
1296 if (/FUZZ\: disable check_for_tchar/) {
1299 if (/FUZZ\: enable check_for_tchar/) {
1302 if ($disable == 0) {
1304 print_error
("$file:$.: LPTSTR found");
1308 print_error
("$file:$.: LPCTSTR found");
1312 print_error
("$file:$.: ASYS_TCHAR found");
1314 elsif (/TCHAR/ and !/ACE_TCHAR/) {
1315 ### Do a double check, since some macros do have TCHAR
1316 ### (like DEFAULTCHARS)
1317 if (/^TCHAR[^\w_]/ or /[^\w_]TCHAR[^\w_]/) {
1318 print_error
("$file:$.: TCHAR found");
1323 print_error
("$file:$.: ASYS_TEXT found");
1325 elsif (/TEXT/ and !/ACE_TEXT/) {
1326 ### Do a double check, since there are several macros
1327 ### that end with TEXT
1328 if (/^TEXT\s*\(/ or /[^\w_]TEXT\s*\(/) {
1329 print_error
("$file:$.: TEXT found");
1337 print STDERR
"Error: Could not open $file\n";
1342 # This checks to see if Makefiles define a DEPENDENCY_FILE, and if they do
1343 # whether or not it's in the cvs repo.
1344 sub check_for_dependency_file
()
1346 return if is_suppressed
();
1348 print "Running DEPENDENCY_FILE test\n";
1349 foreach $file (@files_makefile) {
1350 if (open (FILE
, $file)) {
1351 print "Looking at file $file\n" if $opt_d;
1353 if (/^DEPENDENCY_FILE\s* =\s*(.*)/) {
1356 $path =~ s/\/GNUmakefile.*/\
//;
1357 $depend = $path . $depend;
1358 unless (open (DFILE
, $depend)) {
1359 print_error
("DEPENDENCY_FILE \"$depend\" not found");
1360 print " Either add \"$depend\" to svn ";
1361 print "or remove DEPENDENCY_FILE variable\n";
1362 print " from $file\n\n";
1370 print_error
("cannot open $file");
1375 # This checks to see if GNUmakefiles define a MAKEFILE, and if it matches the
1376 # name of the GNUmakefile
1377 sub check_for_makefile_variable
()
1379 return if is_suppressed
();
1381 print "Running MAKEFILE variable test\n";
1382 foreach $file (@files_makefile) {
1383 if (!(substr($file,-4) eq ".bor")
1384 and !(substr($file,-3) eq ".am")
1385 and !(substr($file,-4) eq ".vac")
1386 and !(substr($file,-4) eq ".alt")) {
1387 if (open (FILE
, $file)) {
1388 print "Looking at file $file\n" if $opt_d;
1389 my $makevarfound = 0;
1390 my $filename = basename
($file,"");
1392 if (/^MAKEFILE\s*=\s*(.*)/) {
1395 if (!($makevar eq $filename)) {
1396 print_error
("$file:$.: MAKEFILE variable $makevar != $filename");
1397 print " Change MAKEFILE = $filename in $file.\n\n";
1401 if ($makevarfound == 0 and !($filename eq "GNUmakefile")) {
1402 print_error
("$file:$.: MAKEFILE variable missing in $file");
1403 print " Add MAKEFILE = $filename to the top of $file.\n\n";
1408 print_error
("cannot open $file");
1415 # This checks to make sure files include ace/post.h if ace/pre.h is included
1417 sub check_for_pre_and_post
()
1419 return if is_suppressed
();
1421 print "Running pre.h/post.h test\n";
1422 foreach $file (@files_h) {
1425 if (open (FILE
, $file)) {
1427 print "Looking at file $file\n" if $opt_d;
1429 if (/FUZZ\: disable check_for_pre_and_post/) {
1432 if (/FUZZ\: enable check_for_pre_and_post/) {
1435 if ($disable == 0) {
1436 if (/^\s*#\s*include\s*\"ace\/pre\
.h
\"/) {
1437 print_error
("$file:$.: pre.h missing \"/**/\"");
1440 if (/^\s*#\s*include\s*\s*\"ace\/post\
.h
\"/) {
1441 print_error
("$file:$.: post.h missing \"/**/\"");
1444 if (/^\s*#\s*include\s*\/\
*\
*\
/\s*\"ace\/pre\
.h
\"/) {
1447 if (/^\s*#\s*include\s*\/\
*\
*\
/\s*\"ace\/post\
.h
\"/) {
1454 if ($disable == 0 && $pre != $post) {
1455 print_error
("$file:1: pre.h/post.h mismatch");
1459 print STDERR
"Error: Could not open $file\n";
1464 # This test verifies that the same number of "#pragma warning(push)" and
1465 # "#pragma warning(pop)" pragmas are used in a given header.
1466 sub check_for_push_and_pop
()
1468 return if is_suppressed
();
1470 print "Running #pragma (push)/(pop) test\n";
1471 foreach $file (@files_h) {
1474 if (open (FILE
, $file)) {
1476 print "Looking at file $file\n" if $opt_d;
1478 if (/FUZZ\: disable check_for_push_and_pop/) {
1481 if (/FUZZ\: enable check_for_push_and_pop/) {
1484 if ($disable == 0) {
1485 if (/^\s*#\s*pragma\s*warning\s*\(\s*push[,1-4]*\s*\)/) {
1488 if (/^\s*#\s*pragma\s*warning\s*\(\s*pop\s*\)/) {
1495 if ($disable == 0 && $push_count != $pop_count) {
1496 print_error
("$file: #pragma warning(push)/(pop) mismatch");
1500 print STDERR
"Error: Could not open $file\n";
1505 # This test verifies that the same number of
1506 # "ACE_VERSIONED_NAMESPACE_BEGIN_DECL" and
1507 # "ACE_END_VERSIONED_NAMESPACE_DECL" macros are used in a given
1509 sub check_for_versioned_namespace_begin_end
()
1511 return if is_suppressed
();
1513 print "Running versioned namespace begin/end test\n";
1514 foreach $file (@files_cpp, @files_inl, @files_h) {
1515 my $begin_count = 0;
1517 if (open (FILE
, $file)) {
1518 print "Looking at file $file\n" if $opt_d;
1520 if (/^\s*\w+_BEGIN_VERSIONED_NAMESPACE_DECL/) {
1523 if (/^\s*\w+_END_VERSIONED_NAMESPACE_DECL/) {
1526 if ($begin_count > $end_count and
1527 /^\s*#\s*include(\s*\/\
*\
*\
/)?\s*"/) {
1528 print_error
("$file:$.: #include directive within Versioned namespace block");
1534 if ($begin_count != $end_count) {
1535 print_error
("$file: Versioned namespace begin($begin_count)/end($end_count) mismatch");
1539 print STDERR
"Error: Could not open $file\n";
1545 # Check doxygen @file comments
1546 sub check_for_mismatched_filename
()
1548 return if is_suppressed
();
1550 print "Running doxygen \@file test\n";
1551 foreach $file (@files_h, @files_cpp, @files_inl, @files_idl) {
1552 if (open (FILE
, $file)) {
1554 print "Looking at file $file\n" if $opt_d;
1556 if (m/\@file\s*([^\s]+)/){
1557 # $file includes complete path, $1 is the name after
1558 # @file. We must check whether the last part of $file
1560 if ($file !~ /$1$/) {
1561 print_error
("$file:$.: \@file mismatch in $file, found $1");
1568 print STDERR
"Error: Could not open $file\n";
1573 # check for bad run_test
1574 sub check_for_bad_run_test
()
1576 return if is_suppressed
();
1578 print "Running run_test.pl test\n";
1579 foreach $file (@files_run_pl) {
1580 if (open (FILE
, $file)) {
1581 my $is_run_test = 0;
1584 if (($file =~ /.*TAO\/examples\
/Advanced.*/)) {
1587 if (($file =~ /.*TAO\/orbsvcs\
/examples\/Security\
/Send_File.*/)) {
1591 print "Looking at file $file\n" if $opt_d;
1594 if (m/PerlACE/ || m/ACEutils/) {
1598 if ($is_run_test == 1) {
1600 print_error
("$file:$.: ACEutils.pm still in use");
1603 if (m/unshift \@INC/) {
1604 print_error
("$file:$.: unshifting \@INC; use \"use lib\"");
1607 if (m/\$EXEPREFIX/) {
1608 print_error
("$file:$.: using \$EXEPREFIX");
1612 print_error
("$file:$.: using \$EXE_EXT");
1615 if (m/Sys::Hostname/) {
1616 print_error
("$file:$.: using Sys::Hostname");
1619 if (m/PerlACE::wait_interval_for_process_creation/) {
1620 print_error
("$file:$.: using PerlACE::wait_interval_for_process_creation");
1623 if (m/PerlACE::waitforfile_timed/) {
1624 print_error
("$file:$.: using PerlACE::waitforfile_timed");
1627 if (m/PerlACE::is_vxworks_test/) {
1628 print_error
("$file:$.: using PerlACE::is_vxworks_test");
1631 if (m/PerlACE::add_lib_path/) {
1632 print_error
("$file:$.: using PerlACE::add_lib_path, use AddLibPath on the target");
1635 if (m/PerlACE::Run_Test/) {
1636 print_error
("$file:$.: using PerlACE::Run_Test, use PerlACE::TestTarget");
1639 if (m/PerlACE::random_port/) {
1640 print_error
("$file:$.: using PerlACE::random_port, use TestTarget::random_port");
1643 if (m/PerlACE::Process/) {
1644 print_error
("$file:$.: using PerlACE::Process");
1647 if (m/PerlACE::TestConfig/) {
1648 print_error
("$file:$.: using PerlACE::TestConfig");
1651 if (m/ACE_RUN_VX_TGTHOST/) {
1652 print_error
("$file:$.: using ACE_RUN_VX_TGTHOST, use TestTarget::HostName");
1655 if (m/Spawn(Wait(Kill)?)?\s*\(.+\->ProcessStop.*\)/) {
1656 print_error
("$file:$.: uses Stop together with Spawn");
1659 if (m/Spawn(Wait(Kill)?)?\s*\(\d+\)/) {
1660 print_error
("$file:$.: uses hardcoded timeout for Spawn");
1663 if (m/Kill\s*\(\d+\)/) {
1664 print_error
("$file:$.: uses hardcoded timeout for Kill");
1668 print_error
("$file:$.: using unlink");
1671 if (m/PerlACE::LocalFile/) {
1672 print_error
("$file:$.: using PerlACE::LocalFile");
1675 if (m/\$DIR_SEPARATOR/) {
1676 print_error
("$file:$.: using \$DIR_SEPARATOR");
1678 if (m/ACE\:\:/ && !m/PerlACE\:\:/) {
1679 print_error
("$file:$.: using ACE::*");
1682 if (m/Process\:\:/ && !m/PerlACE\:\:Process\:\:/) {
1683 print_error
("$file:$.: using Process::*");
1686 if (m/Process\:\:Create/) {
1687 print_error
("$file:$.: using Process::Create");
1691 print_warning
("$file:$.: using two-space indentation");
1695 print_error
("$file:$.: Indenting using tabs");
1698 if (m/^\s*\{/ && $sub != 1) {
1699 print_warning
("$file:$.: Using Curly Brace alone");
1702 if (m/timedout/i && !m/\#/) {
1703 print_error
("$file:$.: timedout message found");
1718 my @output = `perl -wc $file 2>&1`;
1720 foreach $output (@output) {
1722 if ($output =~ m/error/i) {
1723 print_error
($output);
1725 elsif ($output !~ m/syntax OK/) {
1726 print_warning
($output);
1735 # Check for links to ~schmidt/ACE_wrappers/, which should not be in the
1737 sub check_for_absolute_ace_wrappers
()
1739 return if is_suppressed
();
1741 print "Running absolute ACE_wrappers test\n";
1742 foreach $file (@files_html) {
1743 if (open (FILE
, $file)) {
1744 print "Looking at file $file\n" if $opt_d;
1746 if (m/\~schmidt\/ACE_wrappers\
//) {
1748 print_error
("$file:$.: ~schmidt/ACE_wrappers found");
1755 print STDERR
"Error: Could not open $file\n";
1760 # Check for generated headers in the code documentation
1761 sub check_for_generated_headers
()
1763 return if is_suppressed
();
1765 print "Running generated headers test\n";
1766 foreach $file (@files_cpp, @files_inl, @files_h) {
1767 if (open (FILE
, $file)) {
1768 print "Looking at file $file\n" if $opt_d;
1770 if (m/Code generated by the The ACE ORB \(TAO\) IDL Compiler/) {
1772 print_error
("$file:$.: header found");
1779 print STDERR
"Error: Could not open $file\n";
1784 sub check_for_numeric_log
()
1786 return if is_suppressed
();
1788 print "Running check for numeric flags in DAnCE and DDS4CCM\n";
1790 foreach $file (@files_inl, @files_cpp, @files_h) {
1791 if (open (FILE
, $file)) {
1793 # look for debug statements
1794 if (m/DANCE_DEBUG\s*\(\s*\d*\s*,/) {
1795 print_warning
("$file:$.: Found numeric log level in debug statement");
1797 if (m/DANCE_ERROR\s*\(\s*\d\s*,/) {
1798 print_warning
("$file:$.: Found numeric log level in error statement");
1800 if (m/DANCE_TRACE_LOG\s*\(\s*\d\s*,/) {
1801 print_warning
("$file:$.: Found numeric log level in trace log statement");
1803 if (m/DDS4CCM_DEBUG\s*\(\s*\d*\s*,/) {
1804 print_warning
("$file:$.: Found numeric log level in debug statement");
1806 if (m/DDS4CCM_ERROR\s*\(\s*\d\s*,/) {
1807 print_warning
("$file:$.: Found numeric log level in error statement");
1814 print STDERR
"Error: Could not open $file\n";
1819 # Make sure ACE_[OS_]TRACE matches the function/method
1820 sub check_for_bad_ace_trace
()
1822 return if is_suppressed
();
1824 print "Running TRACE test\n";
1825 foreach $file (@files_inl, @files_cpp) {
1826 if (open (FILE
, $file)) {
1830 print "Looking at file $file\n" if $opt_d;
1833 # look for methods or functions
1834 if (m/(^[^\s][^\(]*)\:\:([^\:^\(]*[^\s^\(])\s*/) {
1838 elsif (m/^([^\s^\(^\#]*) \(/i) {
1842 elsif (m/^(operator.*) \(/i) {
1846 elsif (m/^class (.*)\s*:/) {
1850 elsif (m/^class (.*)\s*$/) {
1855 # print "TRACE_CHECK. Class = $class\n";
1857 # Look for TRACE statements
1858 if (m/ACE_OS_TRACE\s*\(\s*\"(.*)\"/
1859 || m/ACE_TRACE\s*\(\s*\"(.*)\"/
1860 || m/CIAO_TRACE\s*\(\s*\"(.*)\"/
1861 || m/DANCE_TRACE\s*\(\s*\"(.*)\"/
1862 || m/DDS4CCM_TRACE\s*\(\s*\"(.*)\"/) {
1865 # reduce the classname
1866 if ($class =~ m/([^\s][^\<^\s]*)\s*\</) {
1870 # print "TRACE_CHECK. Found a trace. Class = $class\n";
1872 if ($class =~ m/([^\s^\&^\*]*)\s*$/) {
1876 # print "TRACE_CHECK. Augmenting class. Class = $class\n";
1878 if ($trace !~ m/\Q$function\E/
1879 || ($trace =~ m/\:\:/ && !($trace =~ m/\Q$class\E/ && $trace =~ m/\Q$function\E/))) {
1880 print_error
("$file:$.: Mismatched TRACE");
1881 print_error
("$file:$.: I see \"$trace\" but I think I'm in \""
1882 . $class . "::" . $function . "\"");
1889 print STDERR
"Error: Could not open $file\n";
1895 # This test checks for broken ChangeLog entries.
1896 sub check_for_changelog_errors
()
1898 return if is_suppressed
();
1900 print "Running ChangeLog check\n";
1901 foreach $file (@files_changelog) {
1902 if (open (FILE
, $file)) {
1903 my $found_backslash = 0;
1904 my $found_cvs_conflict = 0;
1906 print "Looking at file $file\n" if $opt_d;
1909 next if m/^\s*\/\
//;
1912 # Check for backslashes in paths.
1913 if (m/\*.*\\[^ ]*:/) {
1914 print_error
("$file:$.: Backslashes in file path");
1917 # Check for svn conflict tags
1918 if (m/^<<<<</ || m/^=====/ || m/^>>>>>/) {
1919 print_error
("$file:$.: svn conflict markers");
1925 print STDERR
"Error: Could not open $file\n";
1930 sub check_for_deprecated_macros
()
1932 return if is_suppressed
();
1934 ## Take the current working directory and remove everything up to
1935 ## ACE_wrappers (or ACE for the peer-style checkout). This will be
1936 ## used to determine when the use of ACE_THROW_SPEC is an error.
1937 my($cwd) = getcwd
();
1938 if ($cwd =~ s/.*(ACE_wrappers)/$1/) {
1940 elsif ($cwd =~ s/.*(ACE)/$1/) {
1943 print "Running deprecated macros check\n";
1944 foreach $file (@files_cpp, @files_inl, @files_h) {
1945 if (open (FILE
, $file)) {
1947 print "Looking at file $file\n" if $opt_d;
1949 if (/ACE_THROW_SPEC/) {
1950 ## Do not use ACE_THROW_SPEC in TAO or CIAO.
1951 if ($file =~ /TAO|CIAO/i || $cwd =~ /TAO|CIAO/i) {
1952 print_error
("$file:$.: ACE_THROW_SPEC found.");
1959 print STDERR
"Error: Could not open $file\n";
1963 # This test checks for ptr_arith_t usage in source code. ptr_arith_t
1964 # is non-portable. Use ptrdiff_t instead.
1965 sub check_for_ptr_arith_t
()
1967 return if is_suppressed
();
1969 print "Running ptr_arith_t check\n";
1970 foreach $file (@files_cpp, @files_inl, @files_h) {
1971 if (open (FILE
, $file)) {
1973 print "Looking at file $file\n" if $opt_d;
1976 next if m/^\s*\/\
//; # Ignore C++ comments.
1977 next if m/^\s*$/; # Skip lines only containing
1980 # Check for ptr_arith_t usage. This test should
1981 # ignore typedefs, and should only catch variable
1982 # declarations and parameter types.
1983 if (m/ptr_arith_t / || m/ptr_arith_t,/) {
1984 print_error
("$file:$.: ptr_arith_t; use ptrdiff_t instead.");
1990 print STDERR
"Error: Could not open $file\n";
1995 # This test checks for the #include <ace/...>
1996 # This check is suggested by Don Hinton to force user to use
1997 # " " instead of <> to avoid confict with Doxygen.
1998 sub check_for_include
()
2000 return if is_suppressed
();
2002 print "Running the include check\n";
2003 foreach $file (@files_h, @files_cpp, @files_inl, @files_idl) {
2004 my $bad_occurance = 0;
2005 if (open (FILE
, $file)) {
2007 print "Looking at file $file\n" if $opt_d;
2009 if (/FUZZ\: disable check_for_include/) {
2012 if (/FUZZ\: enable check_for_include/) {
2015 if ($disable == 0) {
2016 if (/^\s*#\s*include\s*<[(ace)|(TAO)|(CIAO)]\/.*>/) {
2017 print_error
("$file:$.: include <ace\/..> used");
2020 if (/^\s*#\s*include\s*<tao\/.*>/) {
2021 print_error
("$file:$.: include <tao\/..> used");
2024 if (/^\s*#\s*include\s*<ciao\/.*>/) {
2025 print_error
("$file:$.: include <ciao\/..> used");
2032 if ($disable == 0 && $bad_occurance > 0 ) {
2033 print_error
("$file:1: found $bad_occurance usage(s) of #include <> of ace\/tao\/ciao.");
2037 print STDERR
"Error: Could not open $file\n";
2042 # This test verifies that all equality, relational and logical
2043 # operators return bool, as is the norm for modern C++.
2045 # NOTE: This test isn't fool proof yet.
2046 sub check_for_non_bool_operators
()
2048 return if is_suppressed
();
2050 print "Running non-bool equality, relational and logical operator check\n";
2051 foreach $file (@files_h, @files_inl, @files_cpp) {
2052 if (open (FILE
, $file)) {
2053 print "Looking at file $file\n" if $opt_d;
2055 my $found_return_type = 0;
2058 if ($found_bool == 0
2063 || /[^\w]return\s*$/))
2066 $found_return_type = 0;
2070 if ($found_bool == 0 && $found_return_type == 0
2071 && /^(?:\w+|\s+\w+)\s*$/
2072 && !/[^\w]return\s*$/)
2074 $found_return_type = 1;
2079 if ($found_bool == 0
2080 && /(?<![^\w]bool)(\s+|\w+::|>\s*::)operator\s*(?:!|<|<=|>|>=|==|!=|&&|\|\|)\s*\(/
2081 && !/\(.*operator\s*(?:!|<|<=|>|>=|==|!=|&&|\|\|)\s*\(/
2082 && !/^\s*return\s+/) {
2083 print_error
("$file:$.: non-bool return type for operator");
2086 $found_return_type = 0;
2092 print STDERR
"Error: Could not open $file\n";
2097 # This test verifies that all filenames are short enough
2098 sub check_for_long_file_names
()
2100 return if is_suppressed
();
2102 my $max_filename = 50;
2103 my $max_mpc_projectname = $max_filename - 12; ## GNUmakefile.[project_name]
2104 print "Running file names check\n";
2106 foreach $file (@files_cpp, @files_inl, @files_h, @files_html,
2107 @files_dsp, @files_dsw, @files_gnu, @files_idl,
2108 @files_pl, @files_changelog, @files_makefile,
2109 @files_bor, @files_mpc, @files_generic) {
2110 if ( length( basename
($file) ) >= $max_filename )
2112 print_error
("File name $file meets or exceeds $max_filename chars.");
2115 foreach $file (grep(/\.mpc$/, @files_mpc)) {
2116 if (open(FH
, $file)) {
2117 my($blen) = length(basename
($file)) - 4; ## .mpc
2119 if (/project\s*(:.*)\s*{/) {
2120 if ($blen >= $max_mpc_projectname) {
2121 print_warning
("File name $file meets or exceeds $max_mpc_projectname chars.");
2124 elsif (/project\s*\(([^\)]+)\)/) {
2126 if ($name =~ /\*/) {
2127 my($length) = length($name) + (($name =~ tr/*//) * $blen);
2128 if ($length >= $max_mpc_projectname) {
2129 print_warning
("Project name ($name) from $file will meet or exceed $max_mpc_projectname chars when expanded by MPC.");
2133 if (length($name) >= $max_mpc_projectname) {
2134 print_warning
("Project name ($name) from $file meets or exceeds $max_mpc_projectname chars.");
2144 sub check_for_refcountservantbase
()
2146 return if is_suppressed
();
2148 print "Running PortableServer::RefCountServantBase derivation check\n";
2150 foreach $file (@files_h, @files_cpp, @files_inl) {
2151 if (open (FILE
, $file)) {
2152 print "Looking at file $file\n" if $opt_d;
2155 if (/PortableServer::RefCountServantBase/) {
2156 print_error
("$file:$.: reference to deprecated PortableServer::RefCountServantBase");
2162 print STDERR
"Error: Could not open $file\n";
2167 sub check_for_old_documentation_style
()
2169 return if is_suppressed
();
2171 print "Running documentation style check\n";
2173 foreach $file (@files_h, @files_cpp, @files_inl) {
2174 if (open (FILE
, $file)) {
2175 print "Looking at file $file\n" if $opt_d;
2178 if (/\/\
/\s*\= TITLE/) {
2179 print_error
("$file:$.: found old documentation style // = TITLE");
2185 print STDERR
"Error: Could not open $file\n";
2190 sub check_for_TAO_Local_RefCounted_Object
()
2192 return if is_suppressed
();
2194 print "Running TAO_Local_RefCounted_Object check\n";
2196 ITERATION
: foreach $file (@files_h, @files_cpp, @files_inl) {
2197 if (open (FILE
, $file)) {
2199 print "Looking at file $file\n" if $opt_d;
2201 if (/FUZZ\: disable check_for_TAO_Local_RefCounted_Object/) {
2204 if (/FUZZ\: enable check_for_TAO_Local_RefCounted_Object/) {
2208 if ($disable == 0 and /TAO_Local_RefCounted_Object/) {
2209 print_error
("$file:$.: TAO_Local_RefCounted_Object is deprecated, use CORBA::LocalObject instead");
2215 print STDERR
"Error: Could not open $file\n";
2220 # This test checks for the correct use of ORB_init() so as
2221 # to be compatible with wide character builds.
2222 sub check_for_ORB_init
()
2224 return if is_suppressed
();
2226 print "Running the ORB_init() wide character incompatibility check\n";
2227 foreach $file (@files_cpp, @files_inl) {
2228 if (open (FILE
, $file)) {
2231 my $not_found_end_line_count= 0;
2232 print "Looking at file $file\n" if $opt_d;
2234 if (!defined $multi_line) {
2235 if (/FUZZ\: disable check_for_ORB_init/) {
2239 elsif (/FUZZ\: enable check_for_ORB_init/) {
2243 elsif ($disable == 0) {
2244 s/^\s+//; ## Remove leading space
2245 s/\s*(\/\/.*)?
$//; ## Remove trailling space and line comments
2246 if (s/^([^=]*=)?\s*(CORBA\s*::\s*)?ORB_init\s*//) {
2247 $multi_line = $_; ## Rest of the line
2255 $_ =~ s/^\s+//; ## Remove leading space
2256 $_ =~ s/\s*(\/\/.*)?
$//; ## Remove trailling space and line comments
2257 if ($multi_line eq "") { ## Append this line to existing statement.
2261 $multi_line .= ' ' . $_;
2264 my $testing = $multi_line;
2265 if ($testing =~ s/^\(([^\"\/\)]*(\"([^\"\\]*(\\.)*)\")?(\/+\
*.*?\
*\
/\s*)*)*\)//) {
2266 # $testing has thrown away what we actually want, i.e.
2267 # we want to ignore what's left in $testing.
2269 $multi_line = substr ($multi_line, 0, -length ($testing));
2270 $multi_line =~ s!/\*.*?\*/! !g; ## Remove any internal /* ... */ comments
2271 $multi_line =~ s!\s{2,}! !g; ## collapse multi spaces
2272 $multi_line =~ s/^\(\s*//; ## Trim leading ( and space
2273 $multi_line =~ s/\s*\)$//; ## Trim trailing space and )
2275 if ($multi_line =~ s/^[^,]*,\s*//) { # If this fails there is only 1 parameter (which we will ignore)
2276 # 1st parameter has been removed by the above, split up remaining 2 & 3
2277 $multi_line =~ s/^([^,]*),?\s*//;
2279 $param2 =~ s/\s+$//; # Trim trailing spaces
2281 print_error
("$file:$.: ORB_init() 2nd parameter requires static_cast<ACE_TCHAR **>(0)") if ($param2 eq '0');
2282 print_error
("$file:$.: ORB_init() 3rd parameter is redundant (default orbID or give as string)") if ($multi_line eq '0');
2283 print_error
("$file:$.: ORB_init() 3rd parameter is redundant (default orbID already \"\")") if ($multi_line eq '""');
2287 $not_found_end_line_count = 0;
2289 elsif ($not_found_end_line_count < 10) { # Limit the search for ( ... ) following ORB_init to ten lines
2290 ++$not_found_end_line_count;
2294 $not_found_end_line_count = 0;
2300 print STDERR
"Error: Could not open $file\n";
2305 # This test checks for the presence of an include for ace/OS.h
2306 # which should never occur. Only user code is allowed to include OS.h.
2307 sub check_for_include_OS_h
()
2309 return if is_suppressed
();
2311 print "Running the OS.h inclusion check\n";
2312 foreach $file (@files_h, @files_cpp, @files_inl) {
2313 if (open (FILE
, $file)) {
2315 print "Looking at file $file\n" if $opt_d;
2317 if (/FUZZ\: disable check_for_include_OS_h/) {
2321 elsif (/FUZZ\: enable check_for_include_OS_h/) {
2325 elsif ($disable == 0 and /^\s*#\s*include\s*<[(ace)|(TAO)|(CIAO)]\/.*>/) {
2326 print_error
("$file:$.: include <ace\/..> used");
2329 if ($disable == 0 and /^\s*#\s*include\s*"ace\/OS
.h
"/) {
2330 print_error ("$file:$.: include ace
/OS
.h used
");
2337 print STDERR "Error
: Could
not open $file\n";
2342 sub check_for_ace_log_categories ()
2344 return if is_suppressed ();
2346 print "Running the ACE
log categories check
\n";
2348 my @macros = qw/HEX_DUMP ERROR ERROR_RETURN ERROR_BREAK DEBUG/;
2349 my $macros = join ('|', @macros);
2351 for my $f (@files_h, @files_cpp, @files_inl) {
2354 if ($f =~ /\bace\/(\w+)/) {
2355 next if $1 eq 'Log_Msg' || $` =~ /\/protocols\/$/;
2358 elsif ($f =~ /tao\// && $f !~ /interop-tests\//) {
2361 elsif ($f =~ /\/orbsvcs\// && $f !~ /tests|examples/i) {
2364 elsif ($f =~ /CIAO\// || $f =~ /DAnCE\//) {
2367 elsif ($f =~ /tests\/Log_Msg_Test\.cpp/) {
2371 if (open (IN, $f)) {
2372 print "Looking at file
$f for category
$cat\n" if $opt_d;
2375 if (/FUZZ: disable check_for_ace_log_categories/) {
2379 elsif (/FUZZ: enable check_for_ace_log_categories/) {
2383 elsif ($disable == 0
2384 && /\b(ACE|ACELIB|TAOLIB|ORBSVCS)_($macros)\b/g
2386 print_error ("$f:$.: found
log macro
$1_$2, "
2387 . "expecting
${cat
}_
$2");
2393 print STDERR "Error
: Could
not open $f\n";
2399 ##############################################################################
2401 use vars qw/$opt_c $opt_d $opt_x $opt_h $opt_l $opt_t $opt_s $opt_m/;
2403 if (!getopts ('cdx:hl:t:s:mv') || $opt_h) {
2404 print "fuzz
.pl
[-cdhm
] [-l level
] [-t test_names
] [file1
, file2
, ...]\n";
2406 print " -c only look at the files passed
in\n";
2407 print " -d turn on debugging
\n";
2408 print " -x specify comma
-separated list of path masks
\n";
2409 " (regex
) to exclude
\n";
2410 print " -h display this help
\n";
2411 print " -l level set detection level
(default = 5)\n";
2412 print " -t test_names specify comma
-separated list of tests to run
\n".
2413 " this will disable the run level setting
\n";
2414 print " -s test_names specify comma
-separated list of tests to suppress
\n".
2415 " this will supplement the run level setting
\n";
2416 print " -m only check locally modified files
(uses svn
)\n";
2417 print "======================================================\n";
2418 print "list of the tests that could be run
or suppressed
:\n";
2420 check_for_noncvs_files
2421 check_for_generated_headers
2422 check_for_synch_include
2423 check_for_streams_include
2424 check_for_dependency_file
2425 check_for_makefile_variable
2426 check_for_inline_in_cpp
2429 check_for_ACE_SYNCH_MUTEX
2430 check_for_ACE_Thread_Mutex
2432 check_for_exception_spec
2434 check_for_improper_main_declaration
2435 check_for_lack_ACE_OS
2437 check_for_math_include
2438 check_for_line_length
2439 check_for_preprocessor_comments
2441 check_for_pre_and_post
2442 check_for_push_and_pop
2443 check_for_versioned_namespace_begin_end
2444 check_for_mismatched_filename
2445 check_for_bad_run_test
2446 check_for_absolute_ace_wrappers
2447 check_for_bad_ace_trace
2448 check_for_changelog_errors
2449 check_for_ptr_arith_t
2450 check_for_include (disabled by default)
2451 check_for_non_bool_operators
2452 check_for_long_file_names
2453 check_for_refcountservantbase
2454 check_for_TAO_Local_RefCounted_Object
2456 check_for_trailing_whitespace
2457 check_for_include_OS_h
2458 check_for_numeric_log
2460 check_for_old_documentation_style
2461 check_for_ace_log_categories
2470 # Before opt_m is read!
2472 my @excludes = split '\s*,\s*', $opt_x;
2473 for my $exclude (@excludes) {
2474 push (@excluded_dirs, $exclude);
2479 foreach $file (@ARGV) {
2491 my @tests = split '\s*,\s*', $opt_t;
2492 for my $test (@tests) {
2495 print "\nfuzz.pl - $errors error(s), $warnings warning(s)\n";
2496 exit ($errors > 0) ?
1 : 0;
2500 my @tests = split '\s*,\s*', $opt_s;
2501 for my $test (@tests) {
2502 $suppressed_tests{$test} = 1;
2506 print "--------------------Configuration: Fuzz - Level ",$opt_l,
2507 "--------------------\n";
2509 check_for_export_file
() if ($opt_l >= 4);
2510 check_for_trailing_whitespace
() if ($opt_l >= 4);
2511 check_for_lack_ACE_OS
() if ($opt_l >= 6);
2512 check_for_ACE_Guard
() if ($opt_l >= 1);
2513 check_for_generated_headers
() if ($opt_l >= 6);
2514 check_for_bad_run_test
() if ($opt_l >= 5);
2515 check_for_deprecated_macros
() if ($opt_l >= 1);
2516 check_for_refcountservantbase
() if ($opt_l >= 1);
2517 check_for_msc_ver_string
() if ($opt_l >= 3);
2518 check_for_empty_files
() if ($opt_l >= 1);
2519 check_for_noncvs_files
() if ($opt_l >= 1);
2520 check_for_streams_include
() if ($opt_l >= 6);
2521 check_for_dependency_file
() if ($opt_l >= 1);
2522 check_for_makefile_variable
() if ($opt_l >= 1);
2523 check_for_inline_in_cpp
() if ($opt_l >= 2);
2524 check_for_id_string
() if ($opt_l >= 1);
2525 check_for_newline
() if ($opt_l >= 1);
2526 check_for_ACE_Thread_Mutex
() if ($opt_l >= 1);
2527 check_for_ACE_SYNCH_MUTEX
() if ($opt_l >= 1);
2528 check_for_tab
() if ($opt_l >= 1);
2529 check_for_exception_spec
() if ($opt_l >= 1);
2530 check_for_NULL
() if ($opt_l >= 1);
2531 check_for_inline
() if ($opt_l >= 2);
2532 check_for_math_include
() if ($opt_l >= 3);
2533 check_for_synch_include
() if ($opt_l >= 6);
2534 check_for_line_length
() if ($opt_l >= 8);
2535 check_for_preprocessor_comments
() if ($opt_l >= 7);
2536 check_for_tchar
() if ($opt_l >= 4);
2537 check_for_pre_and_post
() if ($opt_l >= 4);
2538 check_for_push_and_pop
() if ($opt_l >= 4);
2539 check_for_versioned_namespace_begin_end
() if ($opt_l >= 4);
2540 check_for_mismatched_filename
() if ($opt_l >= 2);
2541 check_for_absolute_ace_wrappers
() if ($opt_l >= 3);
2542 check_for_bad_ace_trace
() if ($opt_l >= 4);
2543 check_for_changelog_errors
() if ($opt_l >= 4);
2544 check_for_ptr_arith_t
() if ($opt_l >= 4);
2545 check_for_non_bool_operators
() if ($opt_l > 2);
2546 check_for_long_file_names
() if ($opt_l >= 1);
2547 check_for_improper_main_declaration
() if ($opt_l >= 1);
2548 check_for_TAO_Local_RefCounted_Object
() if ($opt_l >= 1);
2549 check_for_include_OS_h
() if ($opt_l >= 1);
2550 check_for_numeric_log
() if ($opt_l >= 3);
2551 check_for_ORB_init
() if ($opt_l >= 1);
2552 check_for_old_documentation_style
() if ($opt_l >= 6);
2553 check_for_ace_log_categories
() if ($opt_l >= 5);
2555 print "\nfuzz.pl - $errors error(s), $warnings warning(s)\n";
2557 exit (1) if $errors > 0;