⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apache::testutil.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
.Vb 1\&  t_write_file($filename, @lines);.Ve.Sp\&\fIt_write_file()\fR creates a new file at \fI\f(CI$filename\fI\fR or overwrites theexisting file with the content passed in \fI\f(CI@lines\fI\fR. If only the\&\fI\f(CI$filename\fI\fR is passed, an empty file will be created..SpIf parent directories of \f(CW$filename\fR don't exist they will beautomagically created..SpThe generated file will be automatically deleted at the end of theprogram's execution..SpThis function is exported by default..IP "\fIt_append_file()\fR" 4.IX Item "t_append_file()".Vb 1\&  t_append_file($filename, @lines);.Ve.Sp\&\fIt_append_file()\fR is similar to \fIt_write_file()\fR, but it doesn't clobberexisting files and appends \f(CW@lines\fR to the end of the file. If thefile doesn't exist it will create it..SpIf parent directories of \f(CW$filename\fR don't exist they will beautomagically created..SpThe generated file will be registered to be automatically deleted atthe end of the program's execution, only if the file was created by\&\fIt_append_file()\fR..SpThis function is exported by default..IP "\fIt_write_shell_script()\fR" 4.IX Item "t_write_shell_script()".Vb 1\&  Apache::TestUtil::t_write_shell_script($filename, @lines);.Ve.SpSimilar to \fIt_write_file()\fR but creates a portable shell/batchscript. The created filename is constructed from \f(CW$filename\fR and anappropriate extension automatically selected according to the platformthe code is running under..SpIt returns the extension of the created file..IP "\fIt_write_perl_script()\fR" 4.IX Item "t_write_perl_script()".Vb 1\&  Apache::TestUtil::t_write_perl_script($filename, @lines);.Ve.SpSimilar to \fIt_write_file()\fR but creates a executable Perl script withcorrectly set shebang line..IP "\fIt_open_file()\fR" 4.IX Item "t_open_file()".Vb 1\&  my $fh = t_open_file($filename);.Ve.Sp\&\fIt_open_file()\fR opens a file \fI\f(CI$filename\fI\fR for writing and returns thefile handle to the opened file..SpIf parent directories of \f(CW$filename\fR don't exist they will beautomagically created..SpThe generated file will be automatically deleted at the end of theprogram's execution..SpThis function is exported by default..IP "\fIt_mkdir()\fR" 4.IX Item "t_mkdir()".Vb 1\&  t_mkdir($dirname);.Ve.Sp\&\fIt_mkdir()\fR creates a directory \fI\f(CI$dirname\fI\fR. The operation will fail ifthe parent directory doesn't exist..SpIf parent directories of \f(CW$dirname\fR don't exist they will beautomagically created..SpThe generated directory will be automatically deleted at the end ofthe program's execution..SpThis function is exported by default..IP "\fIt_rmtree()\fR" 4.IX Item "t_rmtree()".Vb 1\&  t_rmtree(@dirs);.Ve.Sp\&\fIt_rmtree()\fR deletes the whole directories trees passed in \fI\f(CI@dirs\fI\fR..SpThis function is exported by default..IP "\fIt_chown()\fR" 4.IX Item "t_chown()".Vb 1\&  Apache::TestUtil::t_chown($file);.Ve.SpChange ownership of \f(CW$file\fR to the test's \fIUser\fR/\fIGroup\fR.  Thisfunction is noop on platforms where \fIchown\fR\|(2) is unsupported(e.g. Win32)..IP "\fIt_is_equal()\fR" 4.IX Item "t_is_equal()".Vb 1\&  t_is_equal($a, $b);.Ve.Sp\&\fIt_is_equal()\fR compares any two datastructures and returns 1 if they areexactly the same, otherwise 0. The datastructures can be nestedhashes, arrays, scalars, undefs or a combination of any of these.  See\&\fIt_cmp()\fR for an example..SpIf \f(CW$b\fR is a regex reference, the regex comparison \f(CW\*(C`$a =~ $b\*(C'\fR isperformed. For example:.Sp.Vb 1\&  t_is_equal($server_version, qr{^Apache});.Ve.SpIf comparing non-scalars make sure to pass the references to thedatastructures..SpThis function is exported by default..IP "\fIt_server_log_error_is_expected()\fR" 4.IX Item "t_server_log_error_is_expected()"If the handler's execution results in an error or a warning logged tothe \fIerror_log\fR file which is expected, it's a good idea to have adisclaimer printed before the error itself, so one can tell realproblems with tests from expected errors. For example when testing howthe package behaves under error conditions the \fIerror_log\fR file mightbe loaded with errors, most of which are expected..SpFor example if a handler is about to generate a run-time error, thisfunction can be used as:.Sp.Vb 8\&  use Apache::TestUtil;\&  ...\&  sub handler {\&      my $r = shift;\&      ...\&      t_server_log_error_is_expected();\&      die "failed because ...";\&  }.Ve.SpAfter running this handler the \fIerror_log\fR file will include:.Sp.Vb 2\&  *** The following error entry is expected and harmless ***\&  [Tue Apr 01 14:00:21 2003] [error] failed because ....Ve.SpWhen more than one entry is expected, an optional numerical argument,indicating how many entries to expect, can be passed. For example:.Sp.Vb 1\&  t_server_log_error_is_expected(2);.Ve.Spwill generate:.Sp.Vb 1\&  *** The following 2 error entries are expected and harmless ***.Ve.SpIf the error is generated at compile time, the logging must be done inthe \s-1BEGIN\s0 block at the very beginning of the file:.Sp.Vb 5\&  BEGIN {\&      use Apache::TestUtil;\&      t_server_log_error_is_expected();\&  }\&  use DOES_NOT_exist;.Ve.SpAfter attempting to run this handler the \fIerror_log\fR file willinclude:.Sp.Vb 3\&  *** The following error entry is expected and harmless ***\&  [Tue Apr 01 14:04:49 2003] [error] Can\*(Aqt locate "DOES_NOT_exist.pm"\&  in @INC (@INC contains: ....Ve.SpAlso see \f(CW\*(C`t_server_log_warn_is_expected()\*(C'\fR which is similar but usedfor warnings..SpThis function is exported by default..IP "\fIt_server_log_warn_is_expected()\fR" 4.IX Item "t_server_log_warn_is_expected()"\&\f(CW\*(C`t_server_log_warn_is_expected()\*(C'\fR generates a disclaimer for expectedwarnings..SpSee the explanation for \f(CW\*(C`t_server_log_error_is_expected()\*(C'\fR for moredetails..SpThis function is exported by default..IP "\fIt_client_log_error_is_expected()\fR" 4.IX Item "t_client_log_error_is_expected()"\&\f(CW\*(C`t_client_log_error_is_expected()\*(C'\fR generates a disclaimer forexpected errors. But in contrast to\&\f(CW\*(C`t_server_log_error_is_expected()\*(C'\fR called by the client side of thescript..SpSee the explanation for \f(CW\*(C`t_server_log_error_is_expected()\*(C'\fR for moredetails..SpFor example the following client script fails to find the handler:.Sp.Vb 3\&  use Apache::Test;\&  use Apache::TestUtil;\&  use Apache::TestRequest qw(GET);\&  \&  plan tests => 1;\&  \&  t_client_log_error_is_expected();\&  my $url = "/error_document/cannot_be_found";\&  my $res = GET($url);\&  ok t_cmp(404, $res\->code, "test 404");.Ve.SpAfter running this test the \fIerror_log\fR file will include an entrysimilar to the following snippet:.Sp.Vb 3\&  *** The following error entry is expected and harmless ***\&  [Tue Apr 01 14:02:55 2003] [error] [client 127.0.0.1] \&  File does not exist: /tmp/test/t/htdocs/error.Ve.SpWhen more than one entry is expected, an optional numerical argument,indicating how many entries to expect, can be passed. For example:.Sp.Vb 1\&  t_client_log_error_is_expected(2);.Ve.Spwill generate:.Sp.Vb 1\&  *** The following 2 error entries are expected and harmless ***.Ve.SpThis function is exported by default..IP "\fIt_client_log_warn_is_expected()\fR" 4.IX Item "t_client_log_warn_is_expected()"\&\f(CW\*(C`t_client_log_warn_is_expected()\*(C'\fR generates a disclaimer for expectedwarnings on the client side..SpSee the explanation for \f(CW\*(C`t_client_log_error_is_expected()\*(C'\fR for moredetails..SpThis function is exported by default..IP "t_catfile('a', 'b', 'c')" 4.IX Item "t_catfile('a', 'b', 'c')"This function is essentially \f(CW\*(C`File::Spec\->catfile\*(C'\fR, buton Win32 will use \f(CW\*(C`Win32::GetLongpathName()\*(C'\fR to convert theresult to a long path name (if the result is an absolute file).The function is not exported by default..IP "t_catfile_apache('a', 'b', 'c')" 4.IX Item "t_catfile_apache('a', 'b', 'c')"This function is essentially \f(CW\*(C`File::Spec::Unix\->catfile\*(C'\fR, buton Win32 will use \f(CW\*(C`Win32::GetLongpathName()\*(C'\fR to convert theresult to a long path name (if the result is an absolute file).It is useful when comparing something to that returned by Apache,which uses a Unix-style specification with forward slashes fordirectory separators. The function is not exported by default..SH "AUTHOR".IX Header "AUTHOR"Stas Bekman <stas@stason.org>.SH "SEE ALSO".IX Header "SEE ALSO"\&\fIperl\fR\|(1)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -