diff options
594 files changed, 50342 insertions, 11787 deletions
diff --git a/Makefile.in b/Makefile.in index 107bf80bb5..7596a82720 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1998-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1998-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # Toplevel makefile for building the Erlang system @@ -441,6 +441,8 @@ fourth_bootstrap_copy: if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/wx ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/wx ; fi if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/wx/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/wx/ebin ; fi if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/wx/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/wx/include ; fi + if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/test_server ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/test_server ; fi + if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/test_server/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/test_server/include ; fi for x in lib/ic/ebin/*.beam; do \ BN=`basename $$x`; \ TF=$(BOOTSTRAP_ROOT)/bootstrap/lib/ic/ebin/$$BN; \ @@ -506,6 +508,16 @@ fourth_bootstrap_copy: cp $$x $$TF; \ true; \ done + for x in lib/test_server/include/*.hrl; do \ + BN=`basename $$x`; \ + TF=$(BOOTSTRAP_ROOT)/bootstrap/lib/test_server/include/$$BN; \ + test -f $$TF && \ + test '!' -z "`find $$x -newer $$TF -print`" && \ + cp $$x $$TF; \ + test '!' -f $$TF && \ + cp $$x $$TF; \ + true; \ + done # cp lib/syntax_tools/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/syntax_tools/ebin diff --git a/erts/configure.in b/erts/configure.in index faccf5f102..48d236351b 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -1,20 +1,20 @@ dnl Process this file with autoconf to produce a configure script. -*-m4-*- dnl %CopyrightBegin% -dnl -dnl Copyright Ericsson AB 1997-2009. All Rights Reserved. -dnl +dnl +dnl Copyright Ericsson AB 1997-2010. All Rights Reserved. +dnl dnl The contents of this file are subject to the Erlang Public License, dnl Version 1.1, (the "License"); you may not use this file except in dnl compliance with the License. You should have received a copy of the dnl Erlang Public License along with this software. If not, it can be dnl retrieved online at http://www.erlang.org/. -dnl +dnl dnl Software distributed under the License is distributed on an "AS IS" dnl basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See dnl the License for the specific language governing rights and limitations dnl under the License. -dnl +dnl dnl %CopyrightEnd% dnl The string "FIXME convbreak" means that there is a break of @@ -325,6 +325,7 @@ dnl Checks for programs. dnl ---------------------------------------------------------------------- AC_PROG_CC +AC_SUBST(GCC) dnl --------------------------------------------------------------------- dnl Special stuff regarding CFLAGS and details in the environment... @@ -344,6 +345,9 @@ case $host_os in AC_MSG_WARN([Reverting to 32-bit time_t]) CPPFLAGS="$CPPFLAGS -D_USE_32BIT_TIME_T" ;; + darwin*) + CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE" + ;; *) ;; esac @@ -2098,6 +2102,44 @@ if test X${enable_hipe} != Xno; then esac fi fi + +case $ARCH-$OPSYS in + amd64-darwin*|x86-darwin*) + AC_MSG_CHECKING([For modern (leopard) style mcontext_t]) + AC_TRY_COMPILE([ + #include <stdlib.h> + #include <sys/types.h> + #include <unistd.h> + #include <mach/mach.h> + #include <pthread.h> + #include <machine/signal.h> + #include <ucontext.h> + ],[ + #if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__) + #define __DARWIN__ 1 + #endif + + #ifndef __DARWIN__ + #error inpossible + #else + + mcontext_t mc = NULL; + int x = mc->__fs.__fpu_mxcsr; + + #endif + ],darwin_mcontext_leopard=yes, + darwin_mcontext_leopard=no) + if test X"$darwin_mcontext_leopard" = X"yes"; then + AC_DEFINE(DARWIN_MODERN_MCONTEXT,[],[Modern style mcontext_t in MacOSX]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + ;; + *) + darwin_mcontext_leopard=no + ;; +esac if test X${enable_fp_exceptions} = Xauto ; then if test X${enable_hipe} = Xyes; then enable_fp_exceptions=yes @@ -2487,6 +2529,7 @@ static void fpe_sig_action(int sig, siginfo_t *si, void *puc) regs[PT_FPSCR] = 0x80|0x40|0x10; /* VE, OE, ZE; not UE or XE */ #endif #elif defined(__DARWIN__) +#if defined(DARWIN_MODERN_MCONTEXT) #if defined(__x86_64__) mcontext_t mc = uc->uc_mcontext; struct __darwin_x86_float_state64 *fpstate = &mc->__fs; @@ -2502,6 +2545,23 @@ static void fpe_sig_action(int sig, siginfo_t *si, void *puc) mc->ss.srr0 += 4; mc->fs.fpscr = 0x80|0x40|0x10; #endif +#else +#if defined(__x86_64__) + mcontext_t mc = uc->uc_mcontext; + struct x86_float_state64_t *fpstate = &mc->fs; + fpstate->fpu_mxcsr = 0x1F80; + *(unsigned short *)&fpstate->fpu_fsw &= ~0xFF; +#elif defined(__i386__) + mcontext_t mc = uc->uc_mcontext; + x86_float_state32_t *fpstate = &mc->fs; + fpstate->fpu_mxcsr = 0x1F80; + *(unsigned short *)&fpstate->fpu_fsw &= ~0xFF; +#elif defined(__ppc__) + mcontext_t mc = uc->uc_mcontext; + mc->ss.srr0 += 4; + mc->fs.fpscr = 0x80|0x40|0x10; +#endif +#endif #elif defined(__FreeBSD__) && defined(__x86_64__) mcontext_t *mc = &uc->uc_mcontext; struct savefpu *savefpu = (struct savefpu*)&mc->mc_fpstate; @@ -2615,43 +2675,6 @@ fi) fi fi -case $ARCH-$OPSYS in - amd64-darwin*|x86-darwin*) - AC_MSG_CHECKING([For modern (leopard) style mcontext_t]) - AC_TRY_COMPILE([ - #include <stdlib.h> - #include <sys/types.h> - #include <unistd.h> - #include <mach/mach.h> - #include <pthread.h> - #include <machine/signal.h> - #include <ucontext.h> - ],[ - #if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__) - #define __DARWIN__ 1 - #endif - - #ifndef __DARWIN__ - #error inpossible - #else - - mcontext_t mc = NULL; - int x = mc->__fs.__fpu_mxcsr; - - #endif - ],darwin_mcontext_leopard=yes, - darwin_mcontext_leopard=no) - if test X"$darwin_mcontext_leopard" = X"yes"; then - AC_DEFINE(DARWIN_MODERN_MCONTEXT,[],[Modern style mcontext_t in MacOSX]) - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - ;; - *) - darwin_mcontext_leopard=no - ;; -esac diff --git a/erts/doc/src/erl.xml b/erts/doc/src/erl.xml index 90a3c53a37..6f5dd248ce 100644 --- a/erts/doc/src/erl.xml +++ b/erts/doc/src/erl.xml @@ -4,7 +4,7 @@ <comref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>erl</title> @@ -527,11 +527,16 @@ <p>Calling <c>erlang:halt/1</c> with a string argument will still produce a crash dump.</p> </item> - <tag><c><![CDATA[+h Size]]></c></tag> + <tag><c><![CDATA[+hms Size]]></c></tag> <item> <p>Sets the default heap size of processes to the size <c><![CDATA[Size]]></c>.</p> </item> + <tag><c><![CDATA[+hmbs Size]]></c></tag> + <item> + <p>Sets the default binary virtual heap size of processes to the size + <c><![CDATA[Size]]></c>.</p> + </item> <tag><c><![CDATA[+K true | false]]></c></tag> <item> <p>Enables or disables the kernel poll functionality if diff --git a/erts/doc/src/erl_dist_protocol.xml b/erts/doc/src/erl_dist_protocol.xml index 9a203289e9..5978af178a 100644 --- a/erts/doc/src/erl_dist_protocol.xml +++ b/erts/doc/src/erl_dist_protocol.xml @@ -129,8 +129,8 @@ By default EPMD listens on port 4369. <cell align="center">PortNo</cell> <cell align="center">NodeType</cell> <cell align="center">Protocol</cell> - <cell align="center">LowestVersion</cell> <cell align="center">HighestVersion</cell> + <cell align="center">LowestVersion</cell> <cell align="center">Nlen</cell> <cell align="center">NodeName</cell> <cell align="center">Elen</cell> @@ -150,16 +150,16 @@ By default EPMD listens on port 4369. <item> 0 = tcp/ip-v4, ... </item> - <tag><c>LowestVersion</c></tag> - <item> - The lowest distribution version that this node can handle. - See the next field for possible values. - </item> <tag><c>HighestVersion</c></tag> <item> The highest distribution version that this node can handle. The value in R6B and later is 5. </item> + <tag><c>LowestVersion</c></tag> + <item> + The lowest distribution version that this node can handle. + The value in R6B and later is 5. + </item> <tag><c>Nlen</c></tag> <item> The length of the <c>NodeName</c>. diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index 871fc0fd63..28b040a441 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>erlang</title> @@ -342,8 +342,50 @@ iolist() = [char() | binary() | iolist()] <desc> <p>Returns an Erlang term which is the result of decoding the binary object <c>Binary</c>, which must be encoded - according to the Erlang external term format. See also - <seealso marker="#term_to_binary/1">term_to_binary/1</seealso>.</p> + according to the Erlang external term format.</p> + <warning> + <p>When decoding binaries from untrusted sources, consider using + <c>binary_to_term/2</c> to prevent denial of service attacks.</p> + </warning> + <p>See also + <seealso marker="#term_to_binary/1">term_to_binary/1</seealso> + and + <seealso marker="#binary_to_term/2">binary_to_term/2</seealso>.</p> + </desc> + </func> + <func> + <name>erlang:binary_to_term(Binary, Opts) -> term()</name> + <fsummary>Decode an Erlang external term format binary</fsummary> + <type> + <v>Opts = [safe]</v> + <v>Binary = ext_binary()</v> + </type> + <desc> + <p>As <c>binary_to_term/1</c>, but takes options that affect decoding + of the binary.</p> + <taglist> + <tag><c>safe</c></tag> + <item> + <p>Use this option when receiving binaries from an untrusted + source.</p> + <p>When enabled, it prevents decoding data that may be used to + attack the Erlang system. In the event of receiving unsafe + data, decoding fails with a badarg error.</p> + <p>Currently, this prevents creation of new atoms directly, + creation of new atoms indirectly (as they are embedded in + certain structures like pids, refs, funs, etc.), and creation of + new external function references. None of those resources are + currently garbage collected, so unchecked creation of them can + exhaust available memory.</p> + </item> + </taglist> + <p>Failure: <c>badarg</c> if <c>safe</c> is specified and unsafe data + is decoded.</p> + <p>See also + <seealso marker="#term_to_binary/1">term_to_binary/1</seealso>, + <seealso marker="#binary_to_term/1">binary_to_term/1</seealso>, + and <seealso marker="#list_to_existing_atom/1"> + list_to_existing_atom/1</seealso>.</p> </desc> </func> <func> @@ -3427,6 +3469,11 @@ os_prompt%</pre> <p>This changes the minimum heap size for the calling process.</p> </item> + <tag><c>process_flag(min_bin_vheap_size, MinBinVHeapSize)</c></tag> + <item> + <p>This changes the minimum binary virtual heap size for the calling + process.</p> + </item> <tag><c>process_flag(priority, Level)</c></tag> <item> <marker id="process_flag_priority"></marker> @@ -3758,6 +3805,14 @@ os_prompt%</pre> <p><c>MessageQueue</c> is a list of the messages to the process, which have not yet been processed.</p> </item> + <tag><c>{min_heap_size, MinHeapSize}</c></tag> + <item> + <p><c>MinHeapSize</c> is the minimum heap size for the process.</p> + </item> + <tag><c>{min_bin_vheap_size, MinBinVHeapSize}</c></tag> + <item> + <p><c>MinBinVHeapSize</c> is the minimum binary virtual heap size for the process.</p> + </item> <tag><c>{monitored_by, Pids}</c></tag> <item> <p>A list of pids that are monitoring the process (with @@ -4491,10 +4546,11 @@ true</pre> <fsummary>Create a new process with a fun as entry point</fsummary> <type> <v>Fun = fun()</v> - <v>Option = link | monitor | {priority, Level} | {fullsweep_after, Number} | {min_heap_size, Size}</v> + <v>Option = link | monitor | {priority, Level} | {fullsweep_after, Number} | {min_heap_size, Size} | {min_bin_vheap_size, VSize}</v> <v> Level = low | normal | high</v> <v> Number = int()</v> <v> Size = int()</v> + <v> VSize = int()</v> </type> <desc> <p>Returns the pid of a new process started by the application @@ -4512,10 +4568,11 @@ true</pre> <type> <v>Node = node()</v> <v>Fun = fun()</v> - <v>Option = link | {priority, Level} | {fullsweep_after, Number} | {min_heap_size, Size}</v> + <v>Option = link | {priority, Level} | {fullsweep_after, Number} | {min_heap_size, Size} | {min_bin_vheap_size, VSize}</v> <v> Level = low | normal | high</v> <v> Number = int()</v> <v> Size = int()</v> + <v> VSize = int()</v> </type> <desc> <p>Returns the pid of a new process started by the application @@ -4531,10 +4588,11 @@ true</pre> <type> <v>Module = Function = atom()</v> <v>Args = [term()]</v> - <v>Option = link | monitor | {priority, Level} | {fullsweep_after, Number} | {min_heap_size, Size}</v> + <v>Option = link | monitor | {priority, Level} | {fullsweep_after, Number} | {min_heap_size, Size} | {min_bin_vheap_size, VSize}</v> <v> Level = low | normal | high</v> <v> Number = int()</v> <v> Size = int()</v> + <v> VSize = int()</v> </type> <desc> <p>Works exactly like @@ -4614,6 +4672,23 @@ true</pre> fine-tuning an application and to measure the execution time with various <c>Size</c> values.</p> </item> + <tag><c>{min_bin_vheap_size, VSize}</c></tag> + <item> + <p>This option is only useful for performance tuning. + In general, you should not use this option unless you + know that there is problem with execution times and/or + memory consumption, and you should measure to make sure + that the option improved matters. + </p> + <p>Gives a minimum binary virtual heap size in words. Setting this value + higher than the system default might speed up some + processes because less garbage collection is done. + Setting too high value, however, might waste memory. + Therefore, it is recommended to use this option only for + fine-tuning an application and to measure the execution + time with various <c>VSize</c> values.</p> + </item> + </taglist> </desc> </func> @@ -4624,10 +4699,11 @@ true</pre> <v>Node = node()</v> <v>Module = Function = atom()</v> <v>Args = [term()]</v> - <v>Option = link | {priority, Level} | {fullsweep_after, Number} | {min_heap_size, Size}</v> + <v>Option = link | {priority, Level} | {fullsweep_after, Number} | {min_heap_size, Size} | {min_bin_vheap_size, VSize}</v> <v> Level = low | normal | high</v> <v> Number = int()</v> <v> Size = int()</v> + <v> VSize = int()</v> </type> <desc> <p>Returns the pid of a new process started by the application @@ -4960,6 +5036,17 @@ true</pre> <seealso marker="#spawn_opt/4">spawn_opt/N</seealso> or <seealso marker="#process_flag/2">process_flag/2</seealso>. </p> </item> + <tag><c>erlang:system_flag(min_bin_vheap_size, MinBinVHeapSize)</c></tag> + <item> + <p>Sets the default minimum binary virtual heap size for processes. The + size is given in words. The new <c>min_bin_vhheap_size</c> only + effects processes spawned after the change of + <c>min_bin_vhheap_size</c> has been made. + The <c>min_bin_vheap_size</c> can be set for individual + processes by use of + <seealso marker="#spawn_opt/4">spawn_opt/N</seealso> or + <seealso marker="#process_flag/2">process_flag/2</seealso>. </p> + </item> <tag><c>erlang:system_flag(multi_scheduling, BlockState)</c></tag> <item> <marker id="system_flag_multi_scheduling"></marker> @@ -5571,6 +5658,16 @@ true</pre> <item> <p>Returns a string containing the Erlang machine name.</p> </item> + <tag><c>min_heap_size</c></tag> + <item> + <p>Returns <c>{min_heap_size, MinHeapSize}</c> where <c>MinHeapSize</c> is the current system wide + minimum heap size for spawned processes.</p> + </item> + <tag><c>min_bin_vheap_size</c></tag> + <item> + <p>Returns <c>{min_bin_vheap_size, MinBinVHeapSize}</c> where <c>MinBinVHeapSize</c> is the current system wide + minimum binary virtual heap size for spawned processes.</p> + </item> <tag><c>modified_timing_level</c></tag> <item> <p>Returns the modified timing level (an integer) if @@ -6407,6 +6504,19 @@ true</pre> <tag><c>mbuf_size</c></tag> <item>The combined size of message buffers associated with the process.</item> + + <tag><c>bin_vheap_size</c></tag> + <item>The total size of unique off-heap binaries referenced from the process heap.</item> + <tag><c>bin_vheap_block_size</c></tag> + <item>The total size of binaries, in words, allowed in the virtual + heap in the process before doing a garbage collection. </item> + <tag><c>bin_old_vheap_size</c></tag> + <item>The total size of unique off-heap binaries referenced from the process old heap.</item> + <tag><c>bin_vheap_block_size</c></tag> + <item>The total size of binaries, in words, allowed in the virtual + old heap in the process before doing a garbage collection. </item> + + </taglist> <p>All sizes are in words.</p> </item> diff --git a/erts/doc/src/erlc.xml b/erts/doc/src/erlc.xml index 3859ac8365..1e8960c22c 100644 --- a/erts/doc/src/erlc.xml +++ b/erts/doc/src/erlc.xml @@ -4,7 +4,7 @@ <comref> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>erlc</title> @@ -104,6 +104,10 @@ must be quoted. Terms which contain spaces must be quoted on all platforms.</p> </item> + <tag>-W<em>error</em></tag> + <item> + <p>Makes all warnings into errors.</p> + </item> <tag>-W<em>number</em></tag> <item> <p>Sets warning level to <em>number</em>. Default is <c><![CDATA[1]]></c>. diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in index 903e1e96ba..bc846d1e3d 100644 --- a/erts/emulator/Makefile.in +++ b/erts/emulator/Makefile.in @@ -1,24 +1,25 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1996-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1996-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # include $(ERL_TOP)/make/target.mk include ../vsn.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk ENABLE_ALLOC_TYPE_VARS = @ENABLE_ALLOC_TYPE_VARS@ HIPE_ENABLED=@HIPE_ENABLED@ @@ -213,7 +214,7 @@ else OPT_LEVEL = -O3 endif -ifeq ($(CC), gcc) +ifeq ($(GCC),yes) ifeq ($(NO_INLINE_FUNCTIONS),true) GEN_OPT_FLGS = $(OPT_LEVEL) -fno-inline-functions else @@ -252,7 +253,7 @@ CS_TYPE_FLAGS = $(subst QUANTIFY,FAKE_QUANTIFY, \ $(subst PURIFY,FAKE_PURIFY, $(TYPE_FLAGS))) endif CS_CFLAGS_ = $(CS_TYPE_FLAGS) @DEFS@ $(WFLAGS) -ifeq ($(CC), gcc) +ifeq ($(GCC),yes) CS_CFLAGS = $(subst -O2, $(GEN_OPT_FLGS) $(UNROLL_FLG), $(CS_CFLAGS_)) else CS_CFLAGS = $(CS_CFLAGS_) @@ -351,7 +352,6 @@ endif CS_EXECUTABLE = child_setup$(TYPEMARKER) # ---------------------------------------------------------------------- -include $(ERL_TOP)/make/$(TARGET)/otp.mk ifeq ($(ERLANG_OSTYPE), unix) UNIX_ONLY_BUILDS = $(BINDIR)/$(CS_EXECUTABLE) @@ -692,7 +692,7 @@ $(OBJDIR)/%.kp.o: sys/common/%.c $(OBJDIR)/%.nkp.o: sys/common/%.c $(CC) -DERTS_NO_KERNEL_POLL_VERSION $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@ -ifeq ($(CC), gcc) +ifeq ($(GCC),yes) $(OBJDIR)/erl_obsolete.o: beam/erl_obsolete.c $(CC) $(subst -Wstrict-prototypes, , $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS))) $(INCLUDES) -c $< -o $@ diff --git a/erts/emulator/beam/atom.names b/erts/emulator/beam/atom.names index 04eac2d807..57c8b08223 100644 --- a/erts/emulator/beam/atom.names +++ b/erts/emulator/beam/atom.names @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1996-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1996-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # @@ -303,6 +303,7 @@ atom messages atom meta atom meta_match_spec atom min_heap_size +atom min_bin_vheap_size atom minor_version atom Minus='-' atom module @@ -446,6 +447,7 @@ atom running atom running_ports atom running_procs atom runtime +atom safe atom save_calls atom scheduler atom scheduler_id diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 4ebb8853be..13757b7d1c 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -286,6 +286,15 @@ extern int count_instructions; #endif +#ifdef FORCE_HEAP_FRAGS +# define HEAP_SPACE_VERIFIED(Words) do { \ + c_p->space_verified = (Words); \ + c_p->space_verified_from = HTOP; \ + }while(0) +#else +# define HEAP_SPACE_VERIFIED(Words) ((void)0) +#endif + #define PRE_BIF_SWAPOUT(P) \ HEAP_TOP((P)) = HTOP; \ (P)->stop = E; \ @@ -411,6 +420,7 @@ extern int count_instructions; r(0) = reg[0]; \ SWAPIN; \ } \ + HEAP_SPACE_VERIFIED(need); \ } while (0) @@ -432,6 +442,7 @@ extern int count_instructions; r(0) = reg[0]; \ SWAPIN; \ } \ + HEAP_SPACE_VERIFIED(need); \ } while (0) /* @@ -456,6 +467,7 @@ extern int count_instructions; Extra = reg[Live]; \ SWAPIN; \ } \ + HEAP_SPACE_VERIFIED(need); \ } while (0) #ifdef HYBRID @@ -832,6 +844,7 @@ extern int count_instructions; LIGHT_SWAPOUT; \ _result = erts_bs_get_float_2(c_p, _size, (Flags), _mb); \ LIGHT_SWAPIN; \ + HEAP_SPACE_VERIFIED(0); \ if (is_non_value(_result)) { Fail; } \ else { Store(_result, Dst); } \ } while (0) @@ -845,6 +858,7 @@ extern int count_instructions; LIGHT_SWAPOUT; \ _result = erts_bs_get_binary_2(c_p, (Sz), (Flags), _mb); \ LIGHT_SWAPIN; \ + HEAP_SPACE_VERIFIED(0); \ if (is_non_value(_result)) { Fail; } \ else { Store(_result, Dst); } \ } while (0) @@ -859,6 +873,7 @@ extern int count_instructions; LIGHT_SWAPOUT; \ _result = erts_bs_get_binary_2(c_p, _size, (Flags), _mb); \ LIGHT_SWAPIN; \ + HEAP_SPACE_VERIFIED(0); \ if (is_non_value(_result)) { Fail; } \ else { Store(_result, Dst); } \ } while (0) @@ -873,9 +888,12 @@ extern int count_instructions; LIGHT_SWAPOUT; \ _result = erts_bs_get_binary_all_2(c_p, _mb); \ LIGHT_SWAPIN; \ + HEAP_SPACE_VERIFIED(0); \ ASSERT(is_value(_result)); \ Store(_result, Dst); \ - } else { Fail; } \ + } else { \ + HEAP_SPACE_VERIFIED(0); \ + Fail; } \ } while (0) #define BsSkipBits2(Ms, Bits, Unit, Fail) \ @@ -1360,6 +1378,7 @@ void process_main(void) */ c_p->cp = 0; CHECK_TERM(r(0)); + HEAP_SPACE_VERIFIED(0); Goto(*I); } @@ -2379,6 +2398,7 @@ void process_main(void) if (is_big(tmp_arg1)) { HTOP += bignum_header_arity(*HTOP) + 1; } + HEAP_SPACE_VERIFIED(0); if (is_nil(tmp_arg1)) { /* * This result must have been only slight larger @@ -3225,6 +3245,7 @@ apply_bif_or_nif_epilogue: sb->orig = new_binary; new_binary = make_binary(sb); } + HEAP_SPACE_VERIFIED(0); StoreBifResult(2, new_binary); } else { Binary* bptr; @@ -3712,6 +3733,7 @@ apply_bif_or_nif_epilogue: *dst = *ms; *HTOP = HEADER_BIN_MATCHSTATE(slots); HTOP += wordsneeded; + HEAP_SPACE_VERIFIED(0); StoreResult(make_matchstate(dst), Arg(3)); } } else if (is_binary_header(header)) { @@ -3725,6 +3747,7 @@ apply_bif_or_nif_epilogue: #endif result = erts_bs_start_match_2(c_p, tmp_arg1, slots); HTOP = HEAP_TOP(c_p); + HEAP_SPACE_VERIFIED(0); if (is_non_value(result)) { ClauseFail(); } else { @@ -3917,6 +3940,7 @@ apply_bif_or_nif_epilogue: TestHeap(BIG_UINT_HEAP_SIZE, Arg(1)); _result = uint_to_big((Uint) _integer, HTOP); HTOP += BIG_UINT_HEAP_SIZE; + HEAP_SPACE_VERIFIED(0); } #endif StoreBifResult(2, _result); @@ -3982,6 +4006,7 @@ apply_bif_or_nif_epilogue: LIGHT_SWAPOUT; result = erts_bs_get_integer_2(c_p, tmp_arg2, Arg(1), mb); LIGHT_SWAPIN; + HEAP_SPACE_VERIFIED(0); if (is_non_value(result)) { ClauseFail(); } @@ -4009,6 +4034,7 @@ apply_bif_or_nif_epilogue: LIGHT_SWAPOUT; result = erts_bs_get_integer_2(c_p, size, flags, mb); LIGHT_SWAPIN; + HEAP_SPACE_VERIFIED(0); if (is_non_value(result)) { ClauseFail(); } diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index 74b231d56d..9c8c0df9f0 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -807,11 +807,12 @@ BIF_RETTYPE spawn_opt_1(BIF_ALIST_1) /* * Store default values for options. */ - so.flags = SPO_USE_ARGS; - so.min_heap_size = H_MIN_SIZE; - so.priority = PRIORITY_NORMAL; - so.max_gen_gcs = (Uint16) erts_smp_atomic_read(&erts_max_gen_gcs); - so.scheduler = 0; + so.flags = SPO_USE_ARGS; + so.min_heap_size = H_MIN_SIZE; + so.min_vheap_size = BIN_VH_MIN_SIZE; + so.priority = PRIORITY_NORMAL; + so.max_gen_gcs = (Uint16) erts_smp_atomic_read(&erts_max_gen_gcs); + so.scheduler = 0; /* * Walk through the option list. @@ -850,6 +851,15 @@ BIF_RETTYPE spawn_opt_1(BIF_ALIST_1) } else { so.min_heap_size = erts_next_heap_size(min_heap_size, 0); } + } else if (arg == am_min_bin_vheap_size && is_small(val)) { + Sint min_vheap_size = signed_val(val); + if (min_vheap_size < 0) { + goto error; + } else if (min_vheap_size < BIN_VH_MIN_SIZE) { + so.min_vheap_size = BIN_VH_MIN_SIZE; + } else { + so.min_vheap_size = erts_next_heap_size(min_vheap_size, 0); + } } else if (arg == am_fullsweep_after && is_small(val)) { Sint max_gen_gcs = signed_val(val); if (max_gen_gcs < 0) { @@ -1485,6 +1495,23 @@ BIF_RETTYPE process_flag_2(BIF_ALIST_2) } BIF_RET(old_value); } + else if (BIF_ARG_1 == am_min_bin_vheap_size) { + Sint i; + if (!is_small(BIF_ARG_2)) { + goto error; + } + i = signed_val(BIF_ARG_2); + if (i < 0) { + goto error; + } + old_value = make_small(BIF_P->min_vheap_size); + if (i < BIN_VH_MIN_SIZE) { + BIF_P->min_vheap_size = BIN_VH_MIN_SIZE; + } else { + BIF_P->min_vheap_size = erts_next_heap_size(i, 0); + } + BIF_RET(old_value); + } else if (BIF_ARG_1 == am_sensitive) { Uint is_sensitive; if (BIF_ARG_2 == am_true) { @@ -3736,10 +3763,35 @@ BIF_RETTYPE system_flag_2(BIF_ALIST_2) BIF_RET(make_small(oval)); } else if (BIF_ARG_1 == am_min_heap_size) { int oval = H_MIN_SIZE; + if (!is_small(BIF_ARG_2) || (n = signed_val(BIF_ARG_2)) < 0) { goto error; } + + erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN); + erts_smp_block_system(0); + H_MIN_SIZE = erts_next_heap_size(n, 0); + + erts_smp_release_system(); + erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN); + + BIF_RET(make_small(oval)); + } else if (BIF_ARG_1 == am_min_bin_vheap_size) { + int oval = BIN_VH_MIN_SIZE; + + if (!is_small(BIF_ARG_2) || (n = signed_val(BIF_ARG_2)) < 0) { + goto error; + } + + erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN); + erts_smp_block_system(0); + + BIN_VH_MIN_SIZE = erts_next_heap_size(n, 0); + + erts_smp_release_system(); + erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN); + BIF_RET(make_small(oval)); } else if (BIF_ARG_1 == am_display_items) { int oval = display_items; diff --git a/erts/emulator/beam/bif.tab b/erts/emulator/beam/bif.tab index 85a729208f..b6fa06354a 100644 --- a/erts/emulator/beam/bif.tab +++ b/erts/emulator/beam/bif.tab @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1996-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1996-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # @@ -755,6 +755,11 @@ bif erlang:call_on_load_function/1 bif erlang:finish_after_on_load/2 # +# New Bifs in R13B4 +# +bif erlang:binary_to_term/2 + +# # Obsolete # diff --git a/erts/emulator/beam/erl_arith.c b/erts/emulator/beam/erl_arith.c index b692832677..126ec7cc73 100644 --- a/erts/emulator/beam/erl_arith.c +++ b/erts/emulator/beam/erl_arith.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1999-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -50,18 +50,16 @@ static ERTS_INLINE void maybe_shrink(Process* p, Eterm* hp, Eterm res, Uint allo if (is_immed(res)) { if (p->heap <= hp && hp < p->htop) { p->htop = hp; -#if defined(CHECK_FOR_HOLES) - } else { - erts_arith_shrink(p, hp); -#endif + } + else { + erts_heap_frag_shrink(p, hp); } } else if ((actual = bignum_header_arity(*hp)+1) < alloc) { if (p->heap <= hp && hp < p->htop) { p->htop = hp+actual; -#if defined(CHECK_FOR_HOLES) - } else { - erts_arith_shrink(p, hp+actual); -#endif + } + else { + erts_heap_frag_shrink(p, hp+actual); } } } @@ -397,12 +395,11 @@ erts_mixed_plus(Process* p, Eterm arg1, Eterm arg2) need_heap = BIG_NEED_SIZE(sz); hp = HAlloc(p, need_heap); res = big_plus(arg1, arg2, hp); + maybe_shrink(p, hp, res, need_heap); if (is_nil(res)) { - erts_arith_shrink(p, hp); p->freason = SYSTEM_LIMIT; return THE_NON_VALUE; } - maybe_shrink(p, hp, res, need_heap); return res; case (_TAG_HEADER_FLOAT >> _TAG_PRIMARY_SIZE): if (big_to_double(arg1, &f1.fd) < 0) { @@ -533,12 +530,11 @@ erts_mixed_minus(Process* p, Eterm arg1, Eterm arg2) need_heap = BIG_NEED_SIZE(sz); hp = HAlloc(p, need_heap); res = big_minus(arg1, arg2, hp); + maybe_shrink(p, hp, res, need_heap); if (is_nil(res)) { - erts_arith_shrink(p, hp); p->freason = SYSTEM_LIMIT; return THE_NON_VALUE; } - maybe_shrink(p, hp, res, need_heap); return res; default: goto badarith; @@ -731,12 +727,11 @@ erts_mixed_times(Process* p, Eterm arg1, Eterm arg2) * the absolute value of the other is > 1. */ + maybe_shrink(p, hp, res, need_heap); if (is_nil(res)) { - erts_arith_shrink(p, hp); p->freason = SYSTEM_LIMIT; return THE_NON_VALUE; - } - maybe_shrink(p, hp, res, need_heap); + } return res; case (_TAG_HEADER_FLOAT >> _TAG_PRIMARY_SIZE): if (big_to_double(arg1, &f1.fd) < 0) { @@ -956,12 +951,11 @@ erts_int_div(Process* p, Eterm arg1, Eterm arg2) need = BIG_NEED_SIZE(i-ires+1) + BIG_NEED_SIZE(i); hp = HAlloc(p, need); arg1 = big_div(arg1, arg2, hp); + maybe_shrink(p, hp, arg1, need); if (is_nil(arg1)) { - erts_arith_shrink(p, hp); p->freason = SYSTEM_LIMIT; return THE_NON_VALUE; } - maybe_shrink(p, hp, arg1, need); } return arg1; default: @@ -1004,12 +998,11 @@ erts_int_rem(Process* p, Eterm arg1, Eterm arg2) Eterm* hp = HAlloc(p, need); arg1 = big_rem(arg1, arg2, hp); + maybe_shrink(p, hp, arg1, need); if (is_nil(arg1)) { - erts_arith_shrink(p, hp); p->freason = SYSTEM_LIMIT; return THE_NON_VALUE; } - maybe_shrink(p, hp, arg1, need); } return arg1; default: @@ -1147,7 +1140,7 @@ trim_heap(Process* p, Eterm* hp, Eterm res) * a garbage collection if there is insufficient heap space. */ -#define erts_arith_shrink horrible error +#define erts_heap_frag_shrink horrible error #define maybe_shrink horrible error Eterm diff --git a/erts/emulator/beam/erl_bif_guard.c b/erts/emulator/beam/erl_bif_guard.c index 8b47db10dd..440b0b4f14 100644 --- a/erts/emulator/beam/erl_bif_guard.c +++ b/erts/emulator/beam/erl_bif_guard.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2006-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2006-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -318,6 +318,10 @@ double_to_integer(Process* p, double x) * The following code is used when a guard that may build on the * heap is called directly. They must not use HAlloc(), but must * do a garbage collection if there is insufficient heap space. + * + * Important note: All error checking MUST be done before doing + * a garbage collection. The compiler assumes that all registers + * are still valid if a guard BIF generates an exception. */ #define ERTS_NEED_GC(p, need) ((HEAP_LIMIT((p)) - HEAP_TOP((p))) <= (need)) diff --git a/erts/emulator/beam/erl_bif_info.c b/erts/emulator/beam/erl_bif_info.c index 60216aa8e4..5ff1f794df 100644 --- a/erts/emulator/beam/erl_bif_info.c +++ b/erts/emulator/beam/erl_bif_info.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1999-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -543,6 +543,8 @@ static Eterm pi_args[] = { am_last_calls, am_total_heap_size, am_suspending, + am_min_heap_size, + am_min_bin_vheap_size, #ifdef HYBRID am_message_binary #endif @@ -589,8 +591,10 @@ pi_arg2ix(Eterm arg) case am_last_calls: return 24; case am_total_heap_size: return 25; case am_suspending: return 26; + case am_min_heap_size: return 27; + case am_min_bin_vheap_size: return 28; #ifdef HYBRID - case am_message_binary: return 27; + case am_message_binary: return 29; #endif default: return -1; } @@ -1355,6 +1359,30 @@ process_info_aux(Process *BIF_P, break; } + case am_fullsweep_after: { + Uint hsz = 3; + (void) erts_bld_uint(NULL, &hsz, MAX_GEN_GCS(rp)); + hp = HAlloc(BIF_P, hsz); + res = erts_bld_uint(&hp, NULL, MAX_GEN_GCS(rp)); + break; + } + + case am_min_heap_size: { + Uint hsz = 3; + (void) erts_bld_uint(NULL, &hsz, MIN_HEAP_SIZE(rp)); + hp = HAlloc(BIF_P, hsz); + res = erts_bld_uint(&hp, NULL, MIN_HEAP_SIZE(rp)); + break; + } + + case am_min_bin_vheap_size: { + Uint hsz = 3; + (void) erts_bld_uint(NULL, &hsz, MIN_VHEAP_SIZE(rp)); + hp = HAlloc(BIF_P, hsz); + res = erts_bld_uint(&hp, NULL, MIN_VHEAP_SIZE(rp)); + break; + } + case am_total_heap_size: { ErlMessage *mp; Uint total_heap_size; @@ -1433,15 +1461,17 @@ process_info_aux(Process *BIF_P, DECL_AM(minor_gcs); Eterm t; - hp = HAlloc(BIF_P, 3+2+3+2+3); - t = TUPLE2(hp, AM_minor_gcs, make_small(GEN_GCS(rp))); - hp += 3; - res = CONS(hp, t, NIL); - hp += 2; - t = TUPLE2(hp, am_fullsweep_after, make_small(MAX_GEN_GCS(rp))); - hp += 3; - res = CONS(hp, t, res); - hp += 2; + hp = HAlloc(BIF_P, 3+2 + 3+2 + 3+2 + 3+2 + 3); /* last "3" is for outside tuple */ + + t = TUPLE2(hp, AM_minor_gcs, make_small(GEN_GCS(rp))); hp += 3; + res = CONS(hp, t, NIL); hp += 2; + t = TUPLE2(hp, am_fullsweep_after, make_small(MAX_GEN_GCS(rp))); hp += 3; + res = CONS(hp, t, res); hp += 2; + + t = TUPLE2(hp, am_min_heap_size, make_small(MIN_HEAP_SIZE(rp))); hp += 3; + res = CONS(hp, t, res); hp += 2; + t = TUPLE2(hp, am_min_bin_vheap_size, make_small(MIN_VHEAP_SIZE(rp))); hp += 3; + res = CONS(hp, t, res); hp += 2; break; } @@ -1897,16 +1927,32 @@ BIF_RETTYPE system_info_1(BIF_ALIST_1) BIF_RET(res); } else if (BIF_ARG_1 == am_garbage_collection){ Uint val = (Uint) erts_smp_atomic_read(&erts_max_gen_gcs); - hp = HAlloc(BIF_P, 3+2); - res = TUPLE2(hp, am_fullsweep_after, make_small(val)); - hp += 3; - res = CONS(hp, res, NIL); + Eterm tup; + hp = HAlloc(BIF_P, 3+2 + 3+2 + 3+2); + + tup = TUPLE2(hp, am_fullsweep_after, make_small(val)); hp += 3; + res = CONS(hp, tup, NIL); hp += 2; + + tup = TUPLE2(hp, am_min_heap_size, make_small(H_MIN_SIZE)); hp += 3; + res = CONS(hp, tup, res); hp += 2; + + tup = TUPLE2(hp, am_min_bin_vheap_size, make_small(BIN_VH_MIN_SIZE)); hp += 3; + res = CONS(hp, tup, res); hp += 2; + BIF_RET(res); } else if (BIF_ARG_1 == am_fullsweep_after){ Uint val = (Uint) erts_smp_atomic_read(&erts_max_gen_gcs); hp = HAlloc(BIF_P, 3); res = TUPLE2(hp, am_fullsweep_after, make_small(val)); BIF_RET(res); + } else if (BIF_ARG_1 == am_min_heap_size) { + hp = HAlloc(BIF_P, 3); + res = TUPLE2(hp, am_min_heap_size,make_small(H_MIN_SIZE)); + BIF_RET(res); + } else if (BIF_ARG_1 == am_min_bin_vheap_size) { + hp = HAlloc(BIF_P, 3); + res = TUPLE2(hp, am_min_bin_vheap_size,make_small(BIN_VH_MIN_SIZE)); + BIF_RET(res); } else if (BIF_ARG_1 == am_process_count) { BIF_RET(make_small(erts_process_count())); } else if (BIF_ARG_1 == am_process_limit) { @@ -3131,6 +3177,13 @@ BIF_RETTYPE erts_debug_get_internal_state_1(BIF_ALIST_1) else if (ERTS_IS_ATOM_STR("available_internal_state", BIF_ARG_1)) { BIF_RET(am_true); } + else if (ERTS_IS_ATOM_STR("force_heap_frags", BIF_ARG_1)) { +#ifdef FORCE_HEAP_FRAGS + BIF_RET(am_true); +#else + BIF_RET(am_false); +#endif + } } else if (is_tuple(BIF_ARG_1)) { Eterm* tp = tuple_val(BIF_ARG_1); diff --git a/erts/emulator/beam/erl_debug.c b/erts/emulator/beam/erl_debug.c index 34ce87bc5d..e5c3c76fdd 100644 --- a/erts/emulator/beam/erl_debug.c +++ b/erts/emulator/beam/erl_debug.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1998-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -344,7 +344,7 @@ void erts_check_for_holes(Process* p) if (hf == p->last_mbuf) { break; } - check_memory(hf->mem, hf->mem+hf->size); + check_memory(hf->mem, hf->mem+hf->used_size); } p->last_mbuf = MBUF(p); } @@ -386,7 +386,7 @@ void erts_check_heap(Process *p) } while (bp) { - erts_check_memory(p,bp->mem,bp->mem + bp->size); + erts_check_memory(p,bp->mem,bp->mem + bp->used_size); bp = bp->next; } } diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c index 6945317e65..e9bf37a173 100644 --- a/erts/emulator/beam/erl_gc.c +++ b/erts/emulator/beam/erl_gc.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2002-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2002-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ #ifdef HAVE_CONFIG_H @@ -961,12 +961,13 @@ do_minor(Process *p, int new_sz, Eterm* objv, int nobj) n_htop = sweep_one_area(n_heap, n_htop, heap, heap_size); } else { Eterm* n_hp = n_heap; + Eterm* ptr; + Eterm val; + Eterm gval; while (n_hp != n_htop) { - Eterm* ptr; - Eterm val; - Eterm gval = *n_hp; - + ASSERT(n_hp < n_htop); + gval = *n_hp; switch (primary_tag(gval)) { case TAG_PRIMARY_BOXED: { ptr = boxed_val(gval); @@ -1402,68 +1403,6 @@ remove_message_buffers(Process* p) } } -/* - * Go through one root set array, move everything that it is one of the - * heap fragments to our new heap. - */ -static Eterm* -collect_root_array(Process* p, Eterm* n_htop, Eterm* objv, int nobj) -{ - ErlHeapFragment* qb; - Eterm gval; - Eterm* ptr; - Eterm val; - - ASSERT(p->htop != NULL); - while (nobj--) { - gval = *objv; - - switch (primary_tag(gval)) { - - case TAG_PRIMARY_BOXED: { - ptr = boxed_val(gval); - val = *ptr; - if (IS_MOVED(val)) { - ASSERT(is_boxed(val)); - *objv++ = val; - } else { - for (qb = MBUF(p); qb != NULL; qb = qb->next) { - if (in_area(ptr, qb->mem, qb->size*sizeof(Eterm))) { - MOVE_BOXED(ptr,val,n_htop,objv); - break; - } - } - objv++; - } - break; - } - - case TAG_PRIMARY_LIST: { - ptr = list_val(gval); - val = *ptr; - if (is_non_value(val)) { - *objv++ = ptr[1]; - } else { - for (qb = MBUF(p); qb != NULL; qb = qb->next) { - if (in_area(ptr, qb->mem, qb->size*sizeof(Eterm))) { - MOVE_CONS(ptr,val,n_htop,objv); - break; - } - } - objv++; - } - break; - } - - default: { - objv++; - break; - } - } - } - return n_htop; -} - #ifdef HARDDEBUG /* @@ -1707,11 +1646,13 @@ sweep_rootset(Rootset* rootset, Eterm* htop, char* src, Uint src_size) static Eterm* sweep_one_area(Eterm* n_hp, Eterm* n_htop, char* src, Uint src_size) { - while (n_hp != n_htop) { - Eterm* ptr; - Eterm val; - Eterm gval = *n_hp; + Eterm* ptr; + Eterm val; + Eterm gval; + while (n_hp != n_htop) { + ASSERT(n_hp < n_htop); + gval = *n_hp; switch (primary_tag(gval)) { case TAG_PRIMARY_BOXED: { ptr = boxed_val(gval); @@ -1820,6 +1761,35 @@ sweep_one_heap(Eterm* heap_ptr, Eterm* heap_end, Eterm* htop, char* src, Uint sr } /* + * Move an area (heap fragment) by sweeping over it and set move markers. + */ +static Eterm* +move_one_area(Eterm* n_htop, char* src, Uint src_size) +{ + Eterm* ptr = (Eterm*) src; + Eterm* end = ptr + src_size/sizeof(Eterm); + Eterm dummy_ref; + + while (ptr != end) { + Eterm val; + ASSERT(ptr < end); + val = *ptr; + ASSERT(val != ERTS_HOLE_MARKER); + if (is_header(val)) { + ASSERT(ptr + header_arity(val) < end); + MOVE_BOXED(ptr, val, n_htop, &dummy_ref); + } + else { /* must be a cons cell */ + ASSERT(ptr+1 < end); + MOVE_CONS(ptr, val, n_htop, &dummy_ref); + ptr += 2; + } + } + + return n_htop; +} + +/* * Collect heap fragments and check that they point in the correct direction. */ @@ -1830,7 +1800,6 @@ collect_heap_frags(Process* p, Eterm* n_hstart, Eterm* n_htop, ErlHeapFragment* qb; char* frag_begin; Uint frag_size; - ErlMessage* mp; /* * We don't allow references to a heap fragments from the stack, heap, @@ -1845,65 +1814,44 @@ collect_heap_frags(Process* p, Eterm* n_hstart, Eterm* n_htop, #endif /* - * Go through the subset of the root set that is allowed to - * reference data in heap fragments and move data from heap fragments - * to our new heap. - */ - - if (nobj != 0) { - n_htop = collect_root_array(p, n_htop, objv, nobj); - } - if (is_not_immed(p->fvalue)) { - n_htop = collect_root_array(p, n_htop, &p->fvalue, 1); - } - if (is_not_immed(p->ftrace)) { - n_htop = collect_root_array(p, n_htop, &p->ftrace, 1); - } - if (is_not_immed(p->seq_trace_token)) { - n_htop = collect_root_array(p, n_htop, &p->seq_trace_token, 1); - } - if (is_not_immed(p->group_leader)) { - n_htop = collect_root_array(p, n_htop, &p->group_leader, 1); - } - - /* - * Go through the message queue, move everything that is in one of the - * heap fragments to our new heap. - */ - - for (mp = p->msg.first; mp != NULL; mp = mp->next) { - /* - * In most cases, mp->data.attached points to a heap fragment which is - * self-contained and we will copy it to the heap at the - * end of the GC to avoid scanning it. - * - * In a few cases, however, such as in process_info(Pid, messages) - * and trace_delivered/1, a new message points to a term that has - * been allocated by HAlloc() and mp->data.attached is NULL. Therefore - * we need this loop. - */ - if (mp->data.attached == NULL) { - n_htop = collect_root_array(p, n_htop, mp->m, 2); - } - } - - /* - * Now all references in the root set point to the new heap. However, - * many references on the new heap point to heap fragments. - */ - + * Move the heap fragments to the new heap. Note that no GC is done on + * the heap fragments. Any garbage will thus be moved as well and survive + * until next GC. + */ qb = MBUF(p); - while (qb != NULL) { - frag_begin = (char *) qb->mem; - frag_size = qb->size * sizeof(Eterm); + while (qb != NULL) { + frag_size = qb->used_size * sizeof(Eterm); if (frag_size != 0) { - n_htop = sweep_one_area(n_hstart, n_htop, frag_begin, frag_size); + frag_begin = (char *) qb->mem; + n_htop = move_one_area(n_htop, frag_begin, frag_size); } qb = qb->next; } return n_htop; } +#ifdef DEBUG +static Eterm follow_moved(Eterm term) +{ + Eterm* ptr; + switch (primary_tag(term)) { + case TAG_PRIMARY_IMMED1: + break; + case TAG_PRIMARY_BOXED: + ptr = boxed_val(term); + if (IS_MOVED(*ptr)) term = *ptr; + break; + case TAG_PRIMARY_LIST: + ptr = list_val(term); + if (is_non_value(ptr[0])) term = ptr[1]; + break; + default: + abort(); + } + return term; +} +#endif + static Uint setup_rootset(Process *p, Eterm *objv, int nobj, Rootset *rootset) { @@ -1932,7 +1880,7 @@ setup_rootset(Process *p, Eterm *objv, int nobj, Rootset *rootset) } ASSERT((is_nil(p->seq_trace_token) || - is_tuple(p->seq_trace_token) || + is_tuple(follow_moved(p->seq_trace_token)) || is_atom(p->seq_trace_token))); if (is_not_immed(p->seq_trace_token)) { roots[n].v = &p->seq_trace_token; @@ -1944,7 +1892,7 @@ setup_rootset(Process *p, Eterm *objv, int nobj, Rootset *rootset) is_internal_pid(p->tracer_proc) || is_internal_port(p->tracer_proc)); - ASSERT(is_pid(p->group_leader)); + ASSERT(is_pid(follow_moved(p->group_leader))); if (is_not_immed(p->group_leader)) { roots[n].v = &p->group_leader; roots[n].sz = 1; @@ -2083,23 +2031,45 @@ shrink_new_heap(Process *p, Uint new_sz, Eterm *objv, int nobj) } static Uint -next_vheap_size(Uint vheap, Uint vheap_sz) { - if (vheap < H_MIN_SIZE) { - return H_MIN_SIZE; - } +do_next_vheap_size(Uint vheap, Uint vheap_sz) { + + /* grow + * + * vheap_sz ====================== + * + * vheap 75% + grow + * ---------------------- + * + * vheap 25 - 75% same + * ---------------------- + * + * vheap ~ - 25% shrink + * + * ---------------------- + */ + + if (vheap > (Uint) (vheap_sz*3/4)) { + + while(vheap > (Uint) (vheap_sz*3/4)) { + vheap_sz = vheap_sz*2; + } - /* grow */ - if (vheap > vheap_sz) { - return erts_next_heap_size(2*vheap, 0); + return erts_next_heap_size(vheap_sz, 0); } - /* shrink */ - if ( vheap < vheap_sz/2) { - return (Uint)vheap_sz*3/4; + + if (vheap < (Uint) (vheap_sz/4)) { + return erts_next_heap_size((Uint) (vheap_sz / 2), 0); } return vheap_sz; + } +static Uint +next_vheap_size(Process* p, Uint vheap, Uint vheap_sz) { + vheap_sz = do_next_vheap_size(vheap, vheap_sz); + return vheap_sz < p->min_vheap_size ? p->min_vheap_size : vheap_sz; +} static void sweep_proc_externals(Process *p, int fullsweep) @@ -2302,8 +2272,8 @@ sweep_proc_bins(Process *p, int fullsweep) FLAGS(p) |= F_NEED_FULLSWEEP; } - BIN_VHEAP_SZ(p) = next_vheap_size(bin_vheap, BIN_VHEAP_SZ(p)); - BIN_OLD_VHEAP_SZ(p) = next_vheap_size(BIN_OLD_VHEAP(p), BIN_OLD_VHEAP_SZ(p)); + BIN_VHEAP_SZ(p) = next_vheap_size(p, bin_vheap, BIN_VHEAP_SZ(p)); + BIN_OLD_VHEAP_SZ(p) = next_vheap_size(p, BIN_OLD_VHEAP(p), BIN_OLD_VHEAP_SZ(p)); MSO(p).overhead = bin_vheap; /* diff --git a/erts/emulator/beam/erl_init.c b/erts/emulator/beam/erl_init.c index 8afd349b85..bdf888eaff 100644 --- a/erts/emulator/beam/erl_init.c +++ b/erts/emulator/beam/erl_init.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1997-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -84,9 +84,10 @@ int erts_use_sender_punish; * Configurable parameters. */ -Uint display_items; /* no of items to display in traces etc */ +Uint display_items; /* no of items to display in traces etc */ Uint display_loads; /* print info about loaded modules */ int H_MIN_SIZE; /* The minimum heap grain */ +int BIN_VH_MIN_SIZE; /* The minimum binary virtual*/ Uint32 erts_debug_flags; /* Debug flags. */ #ifdef ERTS_OPCODE_COUNTER_SUPPORT @@ -252,7 +253,8 @@ erl_init(void) no_schedulers, no_schedulers_online); - H_MIN_SIZE = erts_next_heap_size(H_MIN_SIZE, 0); + H_MIN_SIZE = erts_next_heap_size(H_MIN_SIZE, 0); + BIN_VH_MIN_SIZE = erts_next_heap_size(BIN_VH_MIN_SIZE, 0); erts_init_trace(); erts_init_binary(); @@ -513,67 +515,69 @@ void erts_usage(void) /* erts_fprintf(stderr, "-# number set the number of items to be used in traces etc\n"); */ - erts_fprintf(stderr, "-a size suggested stack size in kilo words for threads\n"); - erts_fprintf(stderr, " in the async-thread pool, valid range is [%d-%d]\n", + erts_fprintf(stderr, "-a size suggested stack size in kilo words for threads\n"); + erts_fprintf(stderr, " in the async-thread pool, valid range is [%d-%d]\n", ERTS_ASYNC_THREAD_MIN_STACK_SIZE, ERTS_ASYNC_THREAD_MAX_STACK_SIZE); - erts_fprintf(stderr, "-A number set number of threads in async thread pool,\n"); - erts_fprintf(stderr, " valid range is [0-%d]\n", + erts_fprintf(stderr, "-A number set number of threads in async thread pool,\n"); + erts_fprintf(stderr, " valid range is [0-%d]\n", ERTS_MAX_NO_OF_ASYNC_THREADS); - erts_fprintf(stderr, "-B[c|d|i] c to have Ctrl-c interrupt the Erlang shell,\n"); - erts_fprintf(stderr, " d (or no extra option) to disable the break\n"); - erts_fprintf(stderr, " handler, i to ignore break signals\n"); + erts_fprintf(stderr, "-B[c|d|i] c to have Ctrl-c interrupt the Erlang shell,\n"); + erts_fprintf(stderr, " d (or no extra option) to disable the break\n"); + erts_fprintf(stderr, " handler, i to ignore break signals\n"); /* erts_fprintf(stderr, "-b func set the boot function (default boot)\n"); */ - erts_fprintf(stderr, "-c disable continuous date/time correction with\n"); - erts_fprintf(stderr, " respect to uptime\n"); + erts_fprintf(stderr, "-c disable continuous date/time correction with\n"); + erts_fprintf(stderr, " respect to uptime\n"); - erts_fprintf(stderr, "-d don't write a crash dump for internally detected errors\n"); - erts_fprintf(stderr, " (halt(String) will still produce a crash dump)\n"); + erts_fprintf(stderr, "-d don't write a crash dump for internally detected errors\n"); + erts_fprintf(stderr, " (halt(String) will still produce a crash dump)\n"); - erts_fprintf(stderr, "-h number set minimum heap size in words (default %d)\n", + erts_fprintf(stderr, "-hms size set minimum heap size in words (default %d)\n", H_DEFAULT_SIZE); + erts_fprintf(stderr, "-hmbs size set minimum binary virtual heap size in words (default %d)\n", + VH_DEFAULT_SIZE); /* erts_fprintf(stderr, "-i module set the boot module (default init)\n"); */ - erts_fprintf(stderr, "-K boolean enable or disable kernel poll\n"); + erts_fprintf(stderr, "-K boolean enable or disable kernel poll\n"); - erts_fprintf(stderr, "-l turn on auto load tracing\n"); + erts_fprintf(stderr, "-l turn on auto load tracing\n"); - erts_fprintf(stderr, "-M<X> <Y> memory allocator switches,\n"); - erts_fprintf(stderr, " see the erts_alloc(3) documentation for more info.\n"); + erts_fprintf(stderr, "-M<X> <Y> memory allocator switches,\n"); + erts_fprintf(stderr, " see the erts_alloc(3) documentation for more info.\n"); - erts_fprintf(stderr, "-P number set maximum number of processes on this node,\n"); - erts_fprintf(stderr, " valid range is [%d-%d]\n", + erts_fprintf(stderr, "-P number set maximum number of processes on this node,\n"); + erts_fprintf(stderr, " valid range is [%d-%d]\n", ERTS_MIN_PROCESSES, ERTS_MAX_PROCESSES); - erts_fprintf(stderr, "-R number set compatibility release number,\n"); - erts_fprintf(stderr, " valid range [%d-%d]\n", + erts_fprintf(stderr, "-R number set compatibility release number,\n"); + erts_fprintf(stderr, " valid range [%d-%d]\n", ERTS_MIN_COMPAT_REL, this_rel_num()); - erts_fprintf(stderr, "-r force ets memory block to be moved on realloc\n"); - erts_fprintf(stderr, "-sbt type set scheduler bind type, valid types are:\n"); - erts_fprintf(stderr, " u|ns|ts|ps|s|nnts|nnps|tnnps|db\n"); - erts_fprintf(stderr, "-sct cput set cpu topology,\n"); - erts_fprintf(stderr, " see the erl(1) documentation for more info.\n"); - erts_fprintf(stderr, "-sss size suggested stack size in kilo words for scheduler threads,\n"); - erts_fprintf(stderr, " valid range is [%d-%d]\n", + erts_fprintf(stderr, "-r force ets memory block to be moved on realloc\n"); + erts_fprintf(stderr, "-sbt type set scheduler bind type, valid types are:\n"); + erts_fprintf(stderr, " u|ns|ts|ps|s|nnts|nnps|tnnps|db\n"); + erts_fprintf(stderr, "-sct cput set cpu topology,\n"); + erts_fprintf(stderr, " see the erl(1) documentation for more info.\n"); + erts_fprintf(stderr, "-sss size suggested stack size in kilo words for scheduler threads,\n"); + erts_fprintf(stderr, " valid range is [%d-%d]\n", ERTS_SCHED_THREAD_MIN_STACK_SIZE, ERTS_SCHED_THREAD_MAX_STACK_SIZE); - erts_fprintf(stderr, "-S n1:n2 set number of schedulers (n1), and number of\n"); - erts_fprintf(stderr, " schedulers online (n2), valid range for both\n"); - erts_fprintf(stderr, " numbers are [1-%d]\n", + erts_fprintf(stderr, "-S n1:n2 set number of schedulers (n1), and number of\n"); + erts_fprintf(stderr, " schedulers online (n2), valid range for both\n"); + erts_fprintf(stderr, " numbers are [1-%d]\n", ERTS_MAX_NO_OF_SCHEDULERS); - erts_fprintf(stderr, "-T number set modified timing level,\n"); - erts_fprintf(stderr, " valid range is [0-%d]\n", + erts_fprintf(stderr, "-T number set modified timing level,\n"); + erts_fprintf(stderr, " valid range is [0-%d]\n", ERTS_MODIFIED_TIMING_LEVELS-1); - erts_fprintf(stderr, "-V print Erlang version\n"); + erts_fprintf(stderr, "-V print Erlang version\n"); - erts_fprintf(stderr, "-v turn on chatty mode (GCs will be reported etc)\n"); + erts_fprintf(stderr, "-v turn on chatty mode (GCs will be reported etc)\n"); - erts_fprintf(stderr, "-W<i|w> set error logger warnings mapping,\n"); - erts_fprintf(stderr, " see error_logger documentation for details\n"); + erts_fprintf(stderr, "-W<i|w> set error logger warnings mapping,\n"); + erts_fprintf(stderr, " see error_logger documentation for details\n"); erts_fprintf(stderr, "\n"); erts_fprintf(stderr, "Note that if the emulator is started with erlexec (typically\n"); @@ -604,6 +608,7 @@ early_init(int *argc, char **argv) /* erts_async_max_threads = 0; erts_async_thread_suggested_stack_size = ERTS_ASYNC_THREAD_MIN_STACK_SIZE; H_MIN_SIZE = H_DEFAULT_SIZE; + BIN_VH_MIN_SIZE = VH_DEFAULT_SIZE; erts_initialized = 0; @@ -922,17 +927,40 @@ erl_start(int argc, char **argv) fprintf(stderr, "The undocumented +H option has been removed (R10B-6).\n\n"); break; - case 'h': - /* set default heap size */ - arg = get_arg(argv[i]+2, argv[i+1], &i); - if ((H_MIN_SIZE = atoi(arg)) <= 0) { - erts_fprintf(stderr, "bad heap size %s\n", arg); - erts_usage(); + case 'h': { + char *sub_param = argv[i]+2; + /* set default heap size + * + * h|ms - min_heap_size + * h|mbs - min_bin_vheap_size + * + */ + if (has_prefix("mbs", sub_param)) { + arg = get_arg(sub_param+3, argv[i+1], &i); + if ((BIN_VH_MIN_SIZE = atoi(arg)) <= 0) { + erts_fprintf(stderr, "bad heap size %s\n", arg); + erts_usage(); + } + VERBOSE(DEBUG_SYSTEM, ("using minimum binary virtual heap size %d\n", BIN_VH_MIN_SIZE)); + + } else if (has_prefix("ms", sub_param)) { + arg = get_arg(sub_param+2, argv[i+1], &i); + if ((H_MIN_SIZE = atoi(arg)) <= 0) { + erts_fprintf(stderr, "bad heap size %s\n", arg); + erts_usage(); + } + VERBOSE(DEBUG_SYSTEM, ("using minimum heap size %d\n", H_MIN_SIZE)); + } else { + /* backward compatibility */ + arg = get_arg(argv[i]+2, argv[i+1], &i); + if ((H_MIN_SIZE = atoi(arg)) <= 0) { + erts_fprintf(stderr, "bad heap size %s\n", arg); + erts_usage(); + } + VERBOSE(DEBUG_SYSTEM, ("using minimum heap size %d\n", H_MIN_SIZE)); } - VERBOSE(DEBUG_SYSTEM, - ("using minimum heap size %d\n",H_MIN_SIZE)); break; - + } case 'd': /* * Never produce crash dumps for internally detected diff --git a/erts/emulator/beam/erl_message.c b/erts/emulator/beam/erl_message.c index 81fbdfbd5a..a056fce0c5 100644 --- a/erts/emulator/beam/erl_message.c +++ b/erts/emulator/beam/erl_message.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1997-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ /* @@ -114,12 +114,8 @@ erts_resize_message_buffer(ErlHeapFragment *bp, Uint size, nbp = (ErlHeapFragment*) ERTS_HEAP_REALLOC(ERTS_ALC_T_HEAP_FRAG, (void *) bp, - (sizeof(ErlHeapFragment) - - sizeof(Eterm) - + bp->size*sizeof(Eterm)), - (sizeof(ErlHeapFragment) - - sizeof(Eterm) - + size*sizeof(Eterm))); + ERTS_HEAP_FRAG_SIZE(bp->size), + ERTS_HEAP_FRAG_SIZE(size)); if (bp != nbp) { Uint off_sz = size < nbp->size ? size : nbp->size; Eterm *sp = &bp->mem[0]; @@ -140,7 +136,7 @@ erts_resize_message_buffer(ErlHeapFragment *bp, Uint size, #endif } nbp->size = size; - + nbp->used_size = size; #ifdef HARD_DEBUG for (i = 0; i < brefs_size; i++) @@ -175,9 +171,7 @@ free_message_buffer(ErlHeapFragment* bp) erts_cleanup_offheap(&bp->off_heap); ERTS_HEAP_FREE(ERTS_ALC_T_HEAP_FRAG, (void *) bp, - (sizeof(ErlHeapFragment) - - sizeof(Eterm) - + bp->size*sizeof(Eterm))); + ERTS_HEAP_FRAG_SIZE(bp->size)); } static ERTS_INLINE void diff --git a/erts/emulator/beam/erl_message.h b/erts/emulator/beam/erl_message.h index f14f14a586..5cf7c209bd 100644 --- a/erts/emulator/beam/erl_message.h +++ b/erts/emulator/beam/erl_message.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1997-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -50,19 +50,10 @@ struct erl_heap_fragment { ErlHeapFragment* next; /* Next heap fragment */ ErlOffHeap off_heap; /* Offset heap data. */ unsigned size; /* Size in words of mem */ + unsigned used_size; /* With terms to be moved to heap by GC */ Eterm mem[1]; /* Data */ }; -#define ERTS_SET_MBUF_HEAP_END(BP, HENDP) \ -do { \ - unsigned real_size__ = (BP)->size; \ - ASSERT((BP)->mem <= (HENDP) && (HENDP) <= (BP)->mem + real_size__); \ - (BP)->size = (HENDP) - (BP)->mem; \ - /* We do not reallocate since buffer *might* be moved. */ \ - /* FIXME: Memory count is wrong, but at least it's almost */ \ - /* right... */ \ -} while (0) - typedef struct erl_mesg { struct erl_mesg* next; /* Next message */ union { @@ -196,10 +187,12 @@ do { \ #define ERTS_HEAP_FRAG_SIZE(DATA_WORDS) \ (sizeof(ErlHeapFragment) - sizeof(Eterm) + (DATA_WORDS)*sizeof(Eterm)) + #define ERTS_INIT_HEAP_FRAG(HEAP_FRAG_P, DATA_WORDS) \ do { \ (HEAP_FRAG_P)->next = NULL; \ (HEAP_FRAG_P)->size = (DATA_WORDS); \ + (HEAP_FRAG_P)->used_size = (DATA_WORDS); \ (HEAP_FRAG_P)->off_heap.mso = NULL; \ (HEAP_FRAG_P)->off_heap.funs = NULL; \ (HEAP_FRAG_P)->off_heap.externals = NULL; \ diff --git a/erts/emulator/beam/erl_port_task.c b/erts/emulator/beam/erl_port_task.c index 0fb264a53c..3cb5a966ac 100644 --- a/erts/emulator/beam/erl_port_task.c +++ b/erts/emulator/beam/erl_port_task.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2006-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2006-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -902,25 +902,45 @@ erts_port_task_execute(ErtsRunQueue *runq, Port **curr_port_pp) *curr_port_pp = NULL; - if (pp->sched.taskq) { +#ifdef ERTS_SMP + ASSERT(runq == (ErtsRunQueue *) erts_smp_atomic_read(&pp->run_queue)); +#endif + + if (!pp->sched.taskq) { + ASSERT(pp->sched.exe_taskq); + pp->sched.exe_taskq = NULL; + } + else { +#ifdef ERTS_SMP + ErtsRunQueue *xrunq; +#endif + ASSERT(!(pp->status & ERTS_PORT_SFLGS_DEAD)); ASSERT(pp->sched.taskq->first); - enqueue_port(runq, pp); - port_was_enqueued = 1; - - /* - erts_smp_notify_inc_runq(); - * No need to notify schedulers about the increase in run - * queue length since at least this thread, which is a - * scheduler, will discover that the port run queue isn't - * empty before trying to go to sleep. - */ +#ifdef ERTS_SMP + xrunq = erts_check_emigration_need(runq, ERTS_PORT_PRIO_LEVEL); + if (!xrunq) { +#endif + enqueue_port(runq, pp); + ASSERT(pp->sched.exe_taskq); + pp->sched.exe_taskq = NULL; + /* No need to notify ourselves about inc in runq. */ +#ifdef ERTS_SMP + } + else { + /* Port emigrated ... */ + erts_smp_atomic_set(&pp->run_queue, (long) xrunq); + enqueue_port(xrunq, pp); + ASSERT(pp->sched.exe_taskq); + pp->sched.exe_taskq = NULL; + erts_smp_notify_inc_runq(xrunq); + erts_smp_runq_unlock(xrunq); + } +#endif + port_was_enqueued = 1; } - ASSERT(pp->sched.exe_taskq); - pp->sched.exe_taskq = NULL; - res = erts_smp_atomic_read(&erts_port_task_outstanding_io_tasks) != (long) 0; ERTS_PT_CHK_PRES_PORTQ(runq, pp); diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index a4afe0574f..476e29d96f 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -5517,6 +5517,8 @@ erts_proc_migrate(Process *p, ErtsProcLocks *plcks, p->run_queue = to_rq; enqueue_process(to_rq, p); + smp_notify_inc_runq(to_rq); + return ERTS_MIGRATE_SUCCESS; } #endif /* ERTS_SMP */ @@ -6272,7 +6274,7 @@ Process *schedule(Process *p, int calls) erts_check_my_tracer_proc(p); #endif - if ((FLAGS(p) & F_FORCE_GC) || (MSO(p).overhead >= BIN_VHEAP_SZ(p))) { + if ((FLAGS(p) & F_FORCE_GC) || (MSO(p).overhead > BIN_VHEAP_SZ(p))) { reds -= erts_garbage_collect(p, 0, p->arg_reg, p->arity); if (reds < 0) { reds = 1; @@ -6683,13 +6685,15 @@ erl_create_process(Process* parent, /* Parent of process (default group leader). * noone except us has access to the process. */ if (so->flags & SPO_USE_ARGS) { - p->min_heap_size = so->min_heap_size; - p->prio = so->priority; - p->max_gen_gcs = so->max_gen_gcs; + p->min_heap_size = so->min_heap_size; + p->min_vheap_size = so->min_vheap_size; + p->prio = so->priority; + p->max_gen_gcs = so->max_gen_gcs; } else { - p->min_heap_size = H_MIN_SIZE; - p->prio = PRIORITY_NORMAL; - p->max_gen_gcs = (Uint16) erts_smp_atomic_read(&erts_max_gen_gcs); + p->min_heap_size = H_MIN_SIZE; + p->min_vheap_size = BIN_VH_MIN_SIZE; + p->prio = PRIORITY_NORMAL; + p->max_gen_gcs = (Uint16) erts_smp_atomic_read(&erts_max_gen_gcs); } p->skipped = 0; ASSERT(p->min_heap_size == erts_next_heap_size(p->min_heap_size, 0)); @@ -6736,9 +6740,9 @@ erl_create_process(Process* parent, /* Parent of process (default group leader). p->heap_sz = sz; p->catches = 0; - p->bin_vheap_sz = H_MIN_SIZE; - p->bin_old_vheap_sz = H_MIN_SIZE; - p->bin_old_vheap = 0; + p->bin_vheap_sz = p->min_vheap_size; + p->bin_old_vheap_sz = p->min_vheap_size; + p->bin_old_vheap = 0; /* No need to initialize p->fcalls. */ @@ -6969,6 +6973,7 @@ void erts_init_empty_process(Process *p) p->gen_gcs = 0; p->max_gen_gcs = 0; p->min_heap_size = 0; + p->min_vheap_size = 0; p->status = P_RUNABLE; p->gcstatus = P_RUNABLE; p->rstatus = P_RUNABLE; @@ -6985,8 +6990,8 @@ void erts_init_empty_process(Process *p) p->ftrace = NIL; p->fcalls = 0; - p->bin_vheap_sz=H_MIN_SIZE; - p->bin_old_vheap_sz=H_MIN_SIZE; + p->bin_vheap_sz = BIN_VH_MIN_SIZE; + p->bin_old_vheap_sz = BIN_VH_MIN_SIZE; p->bin_old_vheap = 0; #ifdef ERTS_SMP p->u.ptimer = NULL; diff --git a/erts/emulator/beam/erl_process.h b/erts/emulator/beam/erl_process.h index 7597eb5e31..f58b6932b3 100644 --- a/erts/emulator/beam/erl_process.h +++ b/erts/emulator/beam/erl_process.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -477,6 +477,7 @@ struct ErtsPendingSuspend_ { # define MSO(p) (p)->off_heap # define MIN_HEAP_SIZE(p) (p)->min_heap_size +# define MIN_VHEAP_SIZE(p) (p)->min_vheap_size # define BIN_VHEAP_SZ(p) (p)->bin_vheap_sz # define BIN_OLD_VHEAP_SZ(p) (p)->bin_old_vheap_sz # define BIN_OLD_VHEAP(p) (p)->bin_old_vheap @@ -495,6 +496,7 @@ struct process { Eterm* hend; /* Heap end */ Uint heap_sz; /* Size of heap in words */ Uint min_heap_size; /* Minimum size of heap (in words). */ + Uint min_vheap_size; /* Minimum size of virtual heap (in words). */ #if !defined(NO_FPE_SIGNALS) volatile unsigned long fp_exception; @@ -654,6 +656,11 @@ struct process { * heap fragments. */ #endif + +#ifdef FORCE_HEAP_FRAGS + Uint space_verified; /* Avoid HAlloc forcing heap fragments when */ + Eterm* space_verified_from; /* we rely on available heap space (TestHeap) */ +#endif }; #ifdef CHECK_FOR_HOLES @@ -725,8 +732,8 @@ typedef struct { * The following items are only initialized if the SPO_USE_ARGS flag is set. */ Uint min_heap_size; /* Minimum heap size (must be a valued returned - * from next_heap_size()). - */ + * from next_heap_size()). */ + Uint min_vheap_size; /* Minimum virtual heap size */ int priority; /* Priority for process. */ Uint16 max_gen_gcs; /* Maximum number of gen GCs before fullsweep. */ int scheduler; @@ -738,7 +745,20 @@ typedef struct { #define KILL_CATCHES(p) (p)->catches = -1 -void erts_arith_shrink(Process* p, Eterm* hp); +/* Shrink heap fragment from _last_ HAlloc. +*/ +ERTS_GLB_INLINE void erts_heap_frag_shrink(Process* p, Eterm* hp); +#if ERTS_GLB_INLINE_INCL_FUNC_DEF +ERTS_GLB_INLINE void erts_heap_frag_shrink(Process* p, Eterm* hp) +{ + ErlHeapFragment* hf = MBUF(p); + + ASSERT(hf!=NULL && (hp - hf->mem < (unsigned long)hf->size)); + + hf->used_size = hp - hf->mem; +} +#endif /* inline */ + Eterm* erts_heap_alloc(Process* p, Uint need); #ifdef CHECK_FOR_HOLES Eterm* erts_set_hole_marker(Eterm* ptr, Uint sz); diff --git a/erts/emulator/beam/erl_trace.c b/erts/emulator/beam/erl_trace.c index 2afb16fc52..2842c2361a 100644 --- a/erts/emulator/beam/erl_trace.c +++ b/erts/emulator/beam/erl_trace.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1999-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -2171,6 +2171,11 @@ erts_bif_trace(int bif_index, Process* p, void trace_gc(Process *p, Eterm what) { + ERTS_DECL_AM(bin_vheap_size); + ERTS_DECL_AM(bin_vheap_block_size); + ERTS_DECL_AM(bin_old_vheap_size); + ERTS_DECL_AM(bin_old_vheap_block_size); + ErlHeapFragment *bp = NULL; ErlOffHeap *off_heap; ERTS_TRACER_REF_TYPE tracer_ref = ERTS_NULL_TRACER_REF; /* Initialized @@ -2180,6 +2185,7 @@ trace_gc(Process *p, Eterm what) Eterm* hp; Eterm msg = NIL; Uint size; + Eterm tags[] = { am_old_heap_block_size, am_heap_block_size, @@ -2187,8 +2193,13 @@ trace_gc(Process *p, Eterm what) am_recent_size, am_stack_size, am_old_heap_size, - am_heap_size + am_heap_size, + AM_bin_vheap_size, + AM_bin_vheap_block_size, + AM_bin_old_vheap_size, + AM_bin_old_vheap_block_size }; + Uint values[] = { OLD_HEAP(p) ? OLD_HEND(p) - OLD_HEAP(p) : 0, HEAP_SIZE(p), @@ -2196,7 +2207,11 @@ trace_gc(Process *p, Eterm what) HIGH_WATER(p) - HEAP_START(p), STACK_START(p) - p->stop, OLD_HEAP(p) ? OLD_HTOP(p) - OLD_HEAP(p) : 0, - HEAP_TOP(p) - HEAP_START(p) + HEAP_TOP(p) - HEAP_START(p), + MSO(p).overhead, + BIN_VHEAP_SZ(p), + BIN_OLD_VHEAP(p), + BIN_OLD_VHEAP_SZ(p) }; Eterm local_heap[(sizeof(values)/sizeof(Uint)) *(2/*cons*/ + 3/*2-tuple*/ + BIG_UINT_HEAP_SIZE) diff --git a/erts/emulator/beam/erl_vm.h b/erts/emulator/beam/erl_vm.h index 4d8315ab95..5b0d3c2bfa 100644 --- a/erts/emulator/beam/erl_vm.h +++ b/erts/emulator/beam/erl_vm.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -22,6 +22,13 @@ /* #define ERTS_OPCODE_COUNTER_SUPPORT */ +/* FORCE_HEAP_FRAGS: + * Debug provocation to make HAlloc always create heap fragments (if allowed) + * even if there is room on heap. + */ +/* #define FORCE_HEAP_FRAGS */ + + #if defined(HYBRID) /* # define CHECK_FOR_HOLES */ #endif @@ -50,7 +57,8 @@ #define INPUT_REDUCTIONS (2 * CONTEXT_REDS) -#define H_DEFAULT_SIZE 233 /* default (heap + stack) min size */ +#define H_DEFAULT_SIZE 233 /* default (heap + stack) min size */ +#define VH_DEFAULT_SIZE 32768 /* default virtual (bin) heap min size (words) */ #ifdef HYBRID # define SH_DEFAULT_SIZE 2629425 /* default message area min size */ @@ -70,6 +78,7 @@ && (P) == (P)->scheduler_data->match_pseudo_process) \ || erts_is_system_blocked(0)) + #ifdef DEBUG /* * Debug HAlloc that initialize all memory to bad things. @@ -80,55 +89,43 @@ VERBOSE(DEBUG_ALLOCATION,("HAlloc @ 0x%08lx (%d) %s:%d\n", \ (unsigned long)HEAP_TOP(p),(sz),__FILE__,__LINE__)), \ */ -#ifdef CHECK_FOR_HOLES -#define HAlloc(p, sz) \ - (ASSERT_EXPR((sz) >= 0), \ - ErtsHAllocLockCheck(p), \ - ((((HEAP_LIMIT(p) - HEAP_TOP(p)) < (sz))) \ - ? erts_heap_alloc((p),(sz)) \ - : (erts_set_hole_marker(HEAP_TOP(p), (sz)), \ - HEAP_TOP(p) = HEAP_TOP(p) + (sz), HEAP_TOP(p) - (sz)))) +# ifdef CHECK_FOR_HOLES +# define INIT_HEAP_MEM(p,sz) erts_set_hole_marker(HEAP_TOP(p), (sz)) +# else +# define INIT_HEAP_MEM(p,sz) memset(HEAP_TOP(p),DEBUG_BAD_BYTE,(sz)*sizeof(Eterm*)) +# endif #else -#define HAlloc(p, sz) \ - (ASSERT_EXPR((sz) >= 0), \ - ErtsHAllocLockCheck(p), \ - ((((HEAP_LIMIT(p) - HEAP_TOP(p)) < (sz))) \ - ? erts_heap_alloc((p),(sz)) \ - : (memset(HEAP_TOP(p),DEBUG_BAD_BYTE,(sz)*sizeof(Eterm*)), \ - HEAP_TOP(p) = HEAP_TOP(p) + (sz), HEAP_TOP(p) - (sz)))) -#endif +# define INIT_HEAP_MEM(p,sz) ((void)0) +#endif /* DEBUG */ + + +#ifdef FORCE_HEAP_FRAGS +# define IS_FORCE_HEAP_FRAGS 1 #else +# define IS_FORCE_HEAP_FRAGS 0 +#endif /* * Allocate heap memory, first on the ordinary heap; * failing that, in a heap fragment. */ -#define HAlloc(p, sz) \ - (ASSERT_EXPR((sz) >= 0), \ - ErtsHAllocLockCheck(p), \ - ((((HEAP_LIMIT(p) - HEAP_TOP(p)) < (sz))) \ - ? erts_heap_alloc((p),(sz)) \ - : (HEAP_TOP(p) = HEAP_TOP(p) + (sz), HEAP_TOP(p) - (sz)))) +#define HAlloc(p, sz) \ + (ASSERT_EXPR((sz) >= 0), \ + ErtsHAllocLockCheck(p), \ + (IS_FORCE_HEAP_FRAGS || (((HEAP_LIMIT(p) - HEAP_TOP(p)) < (sz))) \ + ? erts_heap_alloc((p),(sz)) \ + : (INIT_HEAP_MEM(p,sz), \ + HEAP_TOP(p) = HEAP_TOP(p) + (sz), HEAP_TOP(p) - (sz)))) -#endif /* DEBUG */ -#if defined(CHECK_FOR_HOLES) -# define HRelease(p, endp, ptr) \ +#define HRelease(p, endp, ptr) \ if ((ptr) == (endp)) { \ ; \ } else if (HEAP_START(p) <= (ptr) && (ptr) < HEAP_TOP(p)) { \ HEAP_TOP(p) = (ptr); \ } else { \ - erts_arith_shrink(p, ptr); \ + erts_heap_frag_shrink(p, ptr); \ } -#else -# define HRelease(p, endp, ptr) \ - if ((ptr) == (endp)) { \ - ; \ - } else if (HEAP_START(p) <= (ptr) && (ptr) < HEAP_TOP(p)) { \ - HEAP_TOP(p) = (ptr); \ - } -#endif #define HeapWordsLeft(p) (HEAP_LIMIT(p) - HEAP_TOP(p)) @@ -182,6 +179,7 @@ extern int num_instructions; /* Number of instruction in opc[]. */ #define MAX_PORT_LINK 8 /* Maximum number of links to a port */ extern int H_MIN_SIZE; /* minimum (heap + stack) */ +extern int BIN_VH_MIN_SIZE; /* minimum virtual (bin) heap */ #define ORIG_CREATION 0 diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c index f856cce18f..24887b3dea 100644 --- a/erts/emulator/beam/external.c +++ b/erts/emulator/beam/external.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -1013,6 +1013,34 @@ term_to_binary_2(Process* p, Eterm Term, Eterm Flags) return erts_term_to_binary(p, Term, level, flags); } +static uLongf binary2term_uncomp_size(byte* data, Sint size) +{ + z_stream stream; + int err; + const uInt chunk_size = 64*1024; /* Ask tmp-alloc about a suitable size? */ + void* tmp_buf = erts_alloc(ERTS_ALC_T_TMP, chunk_size); + uLongf uncomp_size = 0; + + stream.next_in = (Bytef*)data; + stream.avail_in = (uInt)size; + stream.next_out = tmp_buf; + stream.avail_out = (uInt)chunk_size; + + erl_zlib_alloc_init(&stream); + + err = inflateInit(&stream); + if (err == Z_OK) { + while ((err = inflate(&stream, Z_NO_FLUSH)) == Z_OK) { + uncomp_size += chunk_size - stream.avail_out; + stream.next_out = tmp_buf; + stream.avail_out = chunk_size; + } + inflateEnd(&stream); + } + erts_free(ERTS_ALC_T_TMP, tmp_buf); + return err == Z_STREAM_END ? uncomp_size : 0; +} + static ERTS_INLINE Sint binary2term_prepare(ErtsBinary2TermState *state, byte *data, Sint data_size) { @@ -1036,10 +1064,18 @@ binary2term_prepare(ErtsBinary2TermState *state, byte *data, Sint data_size) state->extp = bytes; } else { - uLongf dest_len = get_int32(bytes+1); - state->extp = erts_alloc(ERTS_ALC_T_TMP, dest_len); + uLongf dest_len = (Uint32) get_int32(bytes+1); + bytes += 5; + size -= 5; + if (dest_len > 32*1024*1024 + || (state->extp = erts_alloc_fnf(ERTS_ALC_T_TMP, dest_len)) == NULL) { + if (dest_len != binary2term_uncomp_size(bytes, size)) { + goto error; + } + state->extp = erts_alloc(ERTS_ALC_T_TMP, dest_len); + } state->exttmp = 1; - if (erl_zlib_uncompress(state->extp, &dest_len, bytes+5, size-5) != Z_OK) + if (erl_zlib_uncompress(state->extp, &dest_len, bytes, size) != Z_OK) goto error; size = (Sint) dest_len; } @@ -1059,10 +1095,10 @@ binary2term_abort(ErtsBinary2TermState *state) } static ERTS_INLINE Eterm -binary2term_create(ErtsBinary2TermState *state, Eterm **hpp, ErlOffHeap *ohp) +binary2term_create(ErtsDistExternal *edep, ErtsBinary2TermState *state, Eterm **hpp, ErlOffHeap *ohp) { Eterm res; - if (!dec_term(NULL, hpp, state->extp, ohp, &res)) + if (!dec_term(edep, hpp, state->extp, ohp, &res)) res = THE_NON_VALUE; if (state->exttmp) { state->exttmp = 0; @@ -1086,7 +1122,7 @@ erts_binary2term_abort(ErtsBinary2TermState *state) Eterm erts_binary2term_create(ErtsBinary2TermState *state, Eterm **hpp, ErlOffHeap *ohp) { - return binary2term_create(state, hpp, ohp); + return binary2term_create(NULL,state, hpp, ohp); } BIF_RETTYPE binary_to_term_1(BIF_ALIST_1) @@ -1114,7 +1150,67 @@ BIF_RETTYPE binary_to_term_1(BIF_ALIST_1) hp = HAlloc(BIF_P, heap_size); endp = hp + heap_size; - res = binary2term_create(&b2ts, &hp, &MSO(BIF_P)); + res = binary2term_create(NULL, &b2ts, &hp, &MSO(BIF_P)); + + erts_free_aligned_binary_bytes(temp_alloc); + + if (hp > endp) { + erl_exit(1, ":%s, line %d: heap overrun by %d words(s)\n", + __FILE__, __LINE__, hp-endp); + } + + HRelease(BIF_P, endp, hp); + + if (res == THE_NON_VALUE) + goto error; + + return res; +} + +BIF_RETTYPE binary_to_term_2(BIF_ALIST_2) +{ + Sint heap_size; + Eterm res; + Eterm opts; + Eterm opt; + Eterm* hp; + Eterm* endp; + Sint size; + byte* bytes; + byte* temp_alloc = NULL; + ErtsBinary2TermState b2ts; + ErtsDistExternal fakedep; + + fakedep.flags = 0; + opts = BIF_ARG_2; + while (is_list(opts)) { + opt = CAR(list_val(opts)); + if (opt == am_safe) { + fakedep.flags |= ERTS_DIST_EXT_BTT_SAFE; + } else { + goto error; + } + opts = CDR(list_val(opts)); + } + + if (is_not_nil(opts)) + goto error; + + if ((bytes = erts_get_aligned_binary_bytes(BIF_ARG_1, &temp_alloc)) == NULL) { + error: + erts_free_aligned_binary_bytes(temp_alloc); + BIF_ERROR(BIF_P, BADARG); + } + size = binary_size(BIF_ARG_1); + + heap_size = binary2term_prepare(&b2ts, bytes, size); + if (heap_size < 0) + goto error; + + hp = HAlloc(BIF_P, heap_size); + endp = hp + heap_size; + + res = binary2term_create(&fakedep, &b2ts, &hp, &MSO(BIF_P)); erts_free_aligned_binary_bytes(temp_alloc); @@ -1300,7 +1396,7 @@ dec_atom(ErtsDistExternal *edep, byte* ep, Eterm* objp) switch (*ep++) { case ATOM_CACHE_REF: - if (!(edep->flags & ERTS_DIST_EXT_ATOM_TRANS_TAB)) + if (!(edep && (edep->flags & ERTS_DIST_EXT_ATOM_TRANS_TAB))) goto error; n = get_int8(ep); ep++; @@ -1312,13 +1408,18 @@ dec_atom(ErtsDistExternal *edep, byte* ep, Eterm* objp) case ATOM_EXT: len = get_int16(ep), ep += 2; - *objp = am_atom_put((char*)ep, len); - ep += len; - break; + goto dec_atom_common; case SMALL_ATOM_EXT: len = get_int8(ep); ep++; - *objp = am_atom_put((char*)ep, len); + dec_atom_common: + if (edep && (edep->flags & ERTS_DIST_EXT_BTT_SAFE)) { + if (!erts_atom_get((char*)ep, len, objp)) { + goto error; + } + } else { + *objp = am_atom_put((char*)ep, len); + } ep += len; break; default: @@ -1775,9 +1876,80 @@ is_external_string(Eterm list, int* p_is_string) return len; } +/* Assumes that the ones to undo are preluding the lists. */ +static void +undo_offheap_in_area(ErlOffHeap* off_heap, Eterm* start, Eterm* end) +{ + const Uint area_sz = (end - start) * sizeof(Eterm); + struct proc_bin* mso; + struct proc_bin** mso_nextp = NULL; +#ifndef HYBRID /* FIND ME! */ + struct erl_fun_thing* funs; + struct erl_fun_thing** funs_nextp = NULL; +#endif + struct external_thing_* ext; + struct external_thing_** ext_nextp = NULL; + + for (mso = off_heap->mso; ; mso=mso->next) { + if (!in_area(mso, start, area_sz)) { + if (mso_nextp != NULL) { + *mso_nextp = NULL; + erts_cleanup_mso(off_heap->mso); + off_heap->mso = mso; + } + break; + } + mso_nextp = &mso->next; + } + +#ifndef HYBRID /* FIND ME! */ + for (funs = off_heap->funs; ; funs=funs->next) { + if (!in_area(funs, start, area_sz)) { + if (funs_nextp != NULL) { + *funs_nextp = NULL; + erts_cleanup_funs(off_heap->funs); + off_heap->funs = funs; + } + break; + } + funs_nextp = &funs->next; + } +#endif + for (ext = off_heap->externals; ; ext=ext->next) { + if (!in_area(ext, start, area_sz)) { + if (ext_nextp != NULL) { + *ext_nextp = NULL; + erts_cleanup_externals(off_heap->externals); + off_heap->externals = ext; + } + break; + } + ext_nextp = &ext->next; + } + + /* Assert that the ones to undo were indeed preluding the lists. */ +#ifdef DEBUG + for (mso = off_heap->mso; mso != NULL; mso=mso->next) { + ASSERT(!in_area(mso, start, area_sz)); + } +# ifndef HYBRID /* FIND ME! */ + for (funs = off_heap->funs; funs != NULL; funs=funs->next) { + ASSERT(!in_area(funs, start, area_sz)); + } +# endif + for (ext = off_heap->externals; ext != NULL; ext=ext->next) { + ASSERT(!in_area(ext, start, area_sz)); + } +#endif /* DEBUG */ +} + +/* Decode term from external format into *objp. +** On failure return NULL and (R13B04) *hpp will be unchanged. +*/ static byte* dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Eterm* objp) { + Eterm* hp_saved = *hpp; int n; register Eterm* hp = *hpp; /* Please don't take the address of hp */ Eterm* next = objp; @@ -1864,13 +2036,18 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et case ATOM_EXT: n = get_int16(ep); ep += 2; - *objp = am_atom_put((char*)ep, n); - ep += n; - break; + goto dec_term_atom_common; case SMALL_ATOM_EXT: n = get_int8(ep); ep++; - *objp = am_atom_put((char*)ep, n); +dec_term_atom_common: + if (edep && (edep->flags & ERTS_DIST_EXT_BTT_SAFE)) { + if (!erts_atom_get((char*)ep, n, objp)) { + goto error; + } + } else { + *objp = am_atom_put((char*)ep, n); + } ep += n; break; case LARGE_TUPLE_EXT: @@ -1973,7 +2150,7 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et ep = dec_pid(edep, hpp, ep, off_heap, objp); hp = *hpp; if (ep == NULL) { - return NULL; + goto error; } break; case PORT_EXT: @@ -2039,7 +2216,6 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et goto ref_ext_common; case NEW_REFERENCE_EXT: - ref_words = get_int16(ep); ep += 2; @@ -2209,7 +2385,7 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et ep = dec_term(edep, hpp, ep, off_heap, &temp); hp = *hpp; if (ep == NULL) { - return NULL; + goto error; } if (!is_small(temp)) { goto error; @@ -2218,6 +2394,10 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et if (arity < 0) { goto error; } + if (edep && (edep->flags & ERTS_DIST_EXT_BTT_SAFE)) { + if (!erts_find_export_entry(mod, name, arity)) + goto error; + } *objp = make_export(hp); *hp++ = HEADER_EXPORT; *hp++ = (Eterm) erts_export_get_or_make_stub(mod, name, arity); @@ -2235,8 +2415,6 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et Sint old_index; unsigned num_free; int i; - Eterm* temp_hp; - Eterm** hpp = &temp_hp; Eterm temp; ep += 4; /* Skip total size in bytes */ @@ -2248,23 +2426,16 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et num_free = get_int32(ep); ep += 4; hp += ERL_FUN_SIZE; - if (num_free > 0) { - /* Don't leave a hole in case we fail */ - *hp = make_pos_bignum_header(num_free-1); - } hp += num_free; - *hpp = hp; funp->thing_word = HEADER_FUN; funp->num_free = num_free; - funp->creator = NIL; /* Don't leave a hole in case we fail */ *objp = make_fun(funp); /* Module */ - if ((ep = dec_atom(edep, ep, &temp)) == NULL) { + if ((ep = dec_atom(edep, ep, &module)) == NULL) { goto error; } - module = temp; - + *hpp = hp; /* Index */ if ((ep = dec_term(edep, hpp, ep, off_heap, &temp)) == NULL) { goto error; @@ -2321,17 +2492,11 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et Sint old_index; unsigned num_free; int i; - Eterm* temp_hp; - Eterm** hpp = &temp_hp; Eterm temp; num_free = get_int32(ep); ep += 4; hp += ERL_FUN_SIZE; - if (num_free > 0) { - /* Don't leave a hole in the heap in case we fail. */ - *hp = make_pos_bignum_header(num_free-1); - } hp += num_free; *hpp = hp; funp->thing_word = HEADER_FUN; @@ -2339,23 +2504,16 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et *objp = make_fun(funp); /* Creator pid */ - switch(*ep) { - case PID_EXT: - ep = dec_pid(edep, hpp, ++ep, off_heap, &funp->creator); - if (ep == NULL) { - funp->creator = NIL; /* Don't leave a hole in the heap */ - goto error; - } - break; - default: + if (*ep != PID_EXT + || (ep = dec_pid(edep, hpp, ++ep, off_heap, + &funp->creator))==NULL) { goto error; } /* Module */ - if ((ep = dec_atom(edep, ep, &temp)) == NULL) { + if ((ep = dec_atom(edep, ep, &module)) == NULL) { goto error; } - module = temp; /* Index */ if ((ep = dec_term(edep, hpp, ep, off_heap, &temp)) == NULL) { @@ -2382,7 +2540,6 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et funp->next = off_heap->funs; off_heap->funs = funp; #endif - old_uniq = unsigned_val(temp); funp->fe = erts_put_fun_entry(module, old_uniq, old_index); @@ -2401,12 +2558,15 @@ dec_term(ErtsDistExternal *edep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Et } default: error: - /* - * Be careful to return the updated heap pointer, to avoid - * that the caller wipes out binaries or other off-heap objects - * that may have been linked into the process. + /* UNDO: + * Must unlink all off-heap objects that may have been + * linked into the process. */ - *hpp = hp; + if (hp < *hpp) { /* Sometimes we used hp and sometimes *hpp */ + hp = *hpp; /* the largest must be the freshest */ + } + undo_offheap_in_area(off_heap, hp_saved, hp); + *hpp = hp_saved; return NULL; } } diff --git a/erts/emulator/beam/external.h b/erts/emulator/beam/external.h index f308680f89..eada6d4f27 100644 --- a/erts/emulator/beam/external.h +++ b/erts/emulator/beam/external.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -98,9 +98,19 @@ typedef struct { Eterm atom[ERTS_ATOM_CACHE_SIZE]; } ErtsAtomTranslationTable; -#define ERTS_DIST_EXT_DFLAG_HDR (((Uint32) 1) << 31) -#define ERTS_DIST_EXT_ATOM_TRANS_TAB (((Uint32) 1) << 30) -#define ERTS_DIST_EXT_CON_ID_MASK ((Uint32) 0x3fffffff) +/* + * These flags are tagged onto the high bits of a connection ID and stored in + * the ErtsDistExternal structure's flags field. They are used to indicate + * various bits of state necessary to decode binaries in a variety of + * scenarios. The mask ERTS_DIST_EXT_CON_ID_MASK is used later to separate the + * connection ID from the flags. Be careful to ensure that the mask does not + * overlap any of the bits used for flags, or ERTS will leak flags bits into + * connection IDs and leak connection ID bits into the flags. + */ +#define ERTS_DIST_EXT_DFLAG_HDR ((Uint32) 0x80000000) +#define ERTS_DIST_EXT_ATOM_TRANS_TAB ((Uint32) 0x40000000) +#define ERTS_DIST_EXT_BTT_SAFE ((Uint32) 0x20000000) +#define ERTS_DIST_EXT_CON_ID_MASK ((Uint32) 0x1fffffff) #define ERTS_DIST_EXT_CON_ID(DIST_EXTP) \ ((DIST_EXTP)->flags & ERTS_DIST_EXT_CON_ID_MASK) diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h index 62a788cbff..df0ab40074 100644 --- a/erts/emulator/beam/global.h +++ b/erts/emulator/beam/global.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -1658,7 +1658,6 @@ void erts_bif_trace_init(void); /* ** Call_trace uses this API for the parameter matching functions */ - struct erl_heap_fragment* saved_program_buf; #define MatchSetRef(MPSP) \ do { \ diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index be442fa480..c162395159 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -95,6 +95,7 @@ dispatch_profile_msg_q(profile_sched_msg_q *psmq) #endif + Eterm* erts_heap_alloc(Process* p, Uint need) { @@ -105,13 +106,29 @@ erts_heap_alloc(Process* p, Uint need) Uint i; #endif +#ifdef FORCE_HEAP_FRAGS + if (p->space_verified && p->space_verified_from!=NULL + && HEAP_TOP(p) >= p->space_verified_from + && HEAP_TOP(p) + need <= p->space_verified_from + p->space_verified + && HEAP_LIMIT(p) - HEAP_TOP(p) >= need) { + + Uint consumed = need + (HEAP_TOP(p) - p->space_verified_from); + ASSERT(consumed <= p->space_verified); + p->space_verified -= consumed; + p->space_verified_from += consumed; + HEAP_TOP(p) = p->space_verified_from; + return HEAP_TOP(p) - need; + } + p->space_verified = 0; + p->space_verified_from = NULL; +#endif /* FORCE_HEAP_FRAGS */ + n = need; #ifdef DEBUG n++; #endif bp = (ErlHeapFragment*) - ERTS_HEAP_ALLOC(ERTS_ALC_T_HEAP_FRAG, - sizeof(ErlHeapFragment) + ((n-1)*sizeof(Eterm))); + ERTS_HEAP_ALLOC(ERTS_ALC_T_HEAP_FRAG, ERTS_HEAP_FRAG_SIZE(n)); #ifdef DEBUG n--; @@ -140,6 +157,7 @@ erts_heap_alloc(Process* p, Uint need) bp->next = MBUF(p); MBUF(p) = bp; bp->size = n; + bp->used_size = n; MBUF_SIZE(p) += n; bp->off_heap.mso = NULL; #ifndef HYBRID /* FIND ME! */ @@ -151,34 +169,6 @@ erts_heap_alloc(Process* p, Uint need) return bp->mem; } -void erts_arith_shrink(Process* p, Eterm* hp) -{ -#if defined(CHECK_FOR_HOLES) - ErlHeapFragment* hf; - - /* - * We must find the heap fragment that hp points into. - * If we are unlucky, we might have to search through - * a large part of the list. We'll hope that will not - * happen too often. - */ - for (hf = MBUF(p); hf != 0; hf = hf->next) { - if (hp - hf->mem < (unsigned long)hf->size) { - /* - * We are not allowed to changed hf->size (because the - * size must be correct when deallocating). Therefore, - * clear out the uninitialized part of the heap fragment. - */ - Eterm* to = hf->mem + hf->size; - while (hp < to) { - *hp++ = NIL; - } - break; - } - } -#endif -} - #ifdef CHECK_FOR_HOLES Eterm* erts_set_hole_marker(Eterm* ptr, Uint sz) diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl index e47dfa18f7..db2b3e10db 100644 --- a/erts/emulator/test/binary_SUITE.erl +++ b/erts/emulator/test/binary_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -27,6 +27,7 @@ %% binary_to_list/1 %% binary_to_list/3 %% binary_to_term/1 +%% binary_to_term/2 %% bitstr_to_list/1 %% term_to_binary/1 %% erlang:external_size/1 @@ -49,7 +50,7 @@ t_hash/1, bad_size/1, bad_term_to_binary/1, - bad_binary_to_term_2/1, + bad_binary_to_term_2/1,safe_binary_to_term2/1, bad_binary_to_term/1, bad_terms/1, more_bad_terms/1, otp_5484/1,otp_5933/1, ordering/1,unaligned_order/1,gc_test/1, @@ -66,7 +67,7 @@ all(suite) -> t_split_binary, bad_split, t_concat_binary, bad_list_to_binary, bad_binary_to_list, terms, terms_float, external_size, t_iolist_size, - bad_binary_to_term_2, + bad_binary_to_term_2,safe_binary_to_term2, bad_binary_to_term, bad_terms, t_hash, bad_size, bad_term_to_binary, more_bad_terms, otp_5484, otp_5933, ordering, unaligned_order, gc_test, bit_sized_binary_sizes, bitlevel_roundtrip, otp_6817, otp_8117, @@ -438,8 +439,11 @@ terms(Config) when is_list(Config) -> ok end, Term = binary_to_term(Bin), + Term = erlang:binary_to_term(Bin, [safe]), Unaligned = make_unaligned_sub_binary(Bin), Term = binary_to_term(Unaligned), + Term = erlang:binary_to_term(Unaligned, []), + Term = erlang:binary_to_term(Bin, [safe]), BinC = erlang:term_to_binary(Term, [compressed]), Term = binary_to_term(BinC), true = size(BinC) =< size(Bin), @@ -538,6 +542,23 @@ bad_binary_to_term(Config) when is_list(Config) -> bad_bin_to_term(BadBin) -> {'EXIT',{badarg,_}} = (catch binary_to_term(BadBin)). +bad_bin_to_term(BadBin,Opts) -> + {'EXIT',{badarg,_}} = (catch erlang:binary_to_term(BadBin,Opts)). + +safe_binary_to_term2(doc) -> "Test safety options for binary_to_term/2"; +safe_binary_to_term2(Config) when is_list(Config) -> + ?line bad_bin_to_term(<<131,100,0,14,"undefined_atom">>, [safe]), + ?line bad_bin_to_term(<<131,100,0,14,"other_bad_atom">>, [safe]), + BadHostAtom = <<100,0,14,"badguy@badhost">>, + Empty = <<0,0,0,0>>, + BadRef = <<131,114,0,3,BadHostAtom/binary,0,<<0,0,0,255>>/binary, + Empty/binary,Empty/binary>>, + ?line bad_bin_to_term(BadRef, [safe]), % good ref, with a bad atom + ?line fullsweep_after = erlang:binary_to_term(<<131,100,0,15,"fullsweep_after">>, [safe]), % should be a good atom + BadExtFun = <<131,113,100,0,4,98,108,117,101,100,0,4,109,111,111,110,97,3>>, + ?line bad_bin_to_term(BadExtFun, [safe]), + ok. + %% Tests bad input to binary_to_term/1. bad_terms(suite) -> []; @@ -559,11 +580,18 @@ corrupter(Term) -> ?line corrupter(CompressedBin, size(CompressedBin)-1). corrupter(Bin, Pos) when Pos >= 0 -> - ?line {ShorterBin, _} = split_binary(Bin, Pos), + ?line {ShorterBin, Rest} = split_binary(Bin, Pos), ?line catch binary_to_term(ShorterBin), %% emulator shouldn't crash ?line MovedBin = list_to_binary([ShorterBin]), ?line catch binary_to_term(MovedBin), %% emulator shouldn't crash - ?line corrupter(MovedBin, Pos-1); + + %% Bit faults, shouldn't crash + <<Byte,Tail/binary>> = Rest, + Fun = fun(M) -> FaultyByte = Byte bxor M, + catch binary_to_term(<<ShorterBin/binary, + FaultyByte, Tail/binary>>) end, + ?line lists:foreach(Fun,[1,2,4,8,16,32,64,128,255]), + ?line corrupter(Bin, Pos-1); corrupter(_Bin, _) -> ok. diff --git a/erts/emulator/test/fun_SUITE.erl b/erts/emulator/test/fun_SUITE.erl index 716ee3707d..a7889dfe90 100644 --- a/erts/emulator/test/fun_SUITE.erl +++ b/erts/emulator/test/fun_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -627,7 +627,13 @@ refc_dist_1() -> %% Fun is passed in an exit signal. Wait until it is gone. ?line wait_until(fun () -> 4 =/= fun_refc(F2) end), ?line 3 = fun_refc(F2), - ?line 3 = fun_refc(F), + erts_debug:set_internal_state(available_internal_state, true), + ?line F_refc = case erts_debug:get_internal_state(force_heap_frags) of + false -> 3; + true -> 2 % GC after bif already decreased it + end, + ?line F_refc = fun_refc(F), + erts_debug:set_internal_state(available_internal_state, false), refc_dist_send(Node, F). refc_dist_send(Node, F) -> diff --git a/erts/emulator/test/process_SUITE.erl b/erts/emulator/test/process_SUITE.erl index fdedf30e78..77f850d0fb 100644 --- a/erts/emulator/test/process_SUITE.erl +++ b/erts/emulator/test/process_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -41,7 +41,8 @@ bump_reductions/1, low_prio/1, binary_owner/1, yield/1, yield2/1, process_status_exiting/1, otp_4725/1, bad_register/1, garbage_collect/1, otp_6237/1, - process_info_messages/1, process_flag_badarg/1, + process_info_messages/1, process_flag_badarg/1, process_flag_heap_size/1, + spawn_opt_heap_size/1, processes_large_tab/1, processes_default_tab/1, processes_small_tab/1, processes_this_tab/1, processes_apply_trap/1, processes_last_call_trap/1, processes_gc_trap/1, @@ -63,9 +64,8 @@ all(suite) -> process_info_lock_reschedule, process_info_lock_reschedule2, process_status_exiting, bump_reductions, low_prio, yield, yield2, otp_4725, bad_register, - garbage_collect, process_info_messages, process_flag_badarg, otp_6237, - processes_bif, - otp_7738]. + garbage_collect, process_info_messages, process_flag_badarg, process_flag_heap_size, + spawn_opt_heap_size, otp_6237, processes_bif, otp_7738]. init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) -> Dog=?t:timetrap(?t:minutes(10)), @@ -388,6 +388,8 @@ t_process_info(Config) when is_list(Config) -> ?line register(my_name, self()), ?line {registered_name, my_name} = process_info(self(), registered_name), ?line {status, running} = process_info(self(), status), + ?line {min_heap_size, 233} = process_info(self(), min_heap_size), + ?line {min_bin_vheap_size, 46368} = process_info(self(), min_bin_vheap_size), ?line {current_function, {?MODULE, t_process_info, 1}} = process_info(self(), current_function), ?line Gleader = group_leader(), @@ -437,6 +439,10 @@ process_info_other_msg(Config) when is_list(Config) -> empty -> ok end, ?line {messages,[]} = process_info(Pid, messages), + + ?line {min_heap_size, 233} = process_info(Pid, min_heap_size), + ?line {min_bin_vheap_size, 46368} = process_info(Pid, min_bin_vheap_size), + ?line Pid ! stop, ok. @@ -1148,6 +1154,8 @@ process_flag_badarg(Config) when is_list(Config) -> ?line chk_badarg(fun () -> process_flag(trap_exit, gurka) end), ?line chk_badarg(fun () -> process_flag(error_handler, 1) end), ?line chk_badarg(fun () -> process_flag(min_heap_size, gurka) end), + ?line chk_badarg(fun () -> process_flag(min_bin_vheap_size, gurka) end), + ?line chk_badarg(fun () -> process_flag(min_bin_vheap_size, -1) end), ?line chk_badarg(fun () -> process_flag(priority, 4711) end), ?line chk_badarg(fun () -> process_flag(save_calls, hmmm) end), ?line P= spawn_link(fun () -> receive die -> ok end end), @@ -1774,6 +1782,34 @@ processes_gc_trap(Config) when is_list(Config) -> ?line exit(Suspendee, bang), ?line ok. +process_flag_heap_size(doc) -> + []; +process_flag_heap_size(suite) -> + []; +process_flag_heap_size(Config) when is_list(Config) -> + HSize = 2584, % must be gc fib number + VHSize = 317811, % must be gc fib number + ?line OldHmin = erlang:process_flag(min_heap_size, HSize), + ?line {min_heap_size, HSize} = erlang:process_info(self(), min_heap_size), + ?line OldVHmin = erlang:process_flag(min_bin_vheap_size, VHSize), + ?line {min_bin_vheap_size, VHSize} = erlang:process_info(self(), min_bin_vheap_size), + ?line HSize = erlang:process_flag(min_heap_size, OldHmin), + ?line VHSize = erlang:process_flag(min_bin_vheap_size, OldVHmin), + ?line ok. + +spawn_opt_heap_size(doc) -> + []; +spawn_opt_heap_size(suite) -> + []; +spawn_opt_heap_size(Config) when is_list(Config) -> + HSize = 987, % must be gc fib number + VHSize = 46368, % must be gc fib number + ?line Pid = spawn_opt(fun () -> receive stop -> ok end end, + [{min_heap_size, HSize},{ min_bin_vheap_size, VHSize}]), + ?line {min_heap_size, HSize} = process_info(Pid, min_heap_size), + ?line {min_bin_vheap_size, VHSize} = process_info(Pid, min_bin_vheap_size), + ?line Pid ! stop, + ?line ok. processes_term_proc_list(doc) -> []; diff --git a/erts/emulator/test/statistics_SUITE.erl b/erts/emulator/test/statistics_SUITE.erl index bc12821887..898908c40f 100644 --- a/erts/emulator/test/statistics_SUITE.erl +++ b/erts/emulator/test/statistics_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -25,7 +25,7 @@ init_per_testcase/2, fin_per_testcase/2, wall_clock/1, wall_clock_zero_diff/1, wall_clock_update/1, - runtime/1, runtime_zero_diff/1, runtime_zero_update/1, + runtime/1, runtime_zero_diff/1, runtime_update/1, runtime_diff/1, run_queue/1, run_queue_one/1, reductions/1, reductions_big/1, garbage_collection/1, io/1, @@ -99,8 +99,7 @@ wall_clock_update1(0) -> %%% Test statistics(runtime). -runtime(suite) -> [runtime_zero_diff, runtime_zero_update, runtime_update, - runtime_diff]. +runtime(suite) -> [runtime_zero_diff, runtime_update, runtime_diff]. runtime_zero_diff(doc) -> "Tests that the difference between the times returned from two consectuitive " @@ -117,55 +116,32 @@ runtime_zero_diff1(N) when N > 0 -> runtime_zero_diff1(0) -> ?line test_server:fail("statistics(runtime) never returned zero difference"). -runtime_zero_update(doc) -> - "Test that the time differences returned by two calls to " - "statistics(runtime) several seconds apart is zero."; -runtime_zero_update(Config) when is_list(Config) -> - case ?t:is_debug() of - false -> ?line runtime_zero_update1(6); - true -> {skip,"Unreliable in DEBUG build"} - end. - -runtime_zero_update1(N) when N > 0 -> - ?line {T1, _} = statistics(runtime), - ?line receive after 7000 -> ok end, - ?line case statistics(runtime) of - {T, Td} when Td =< 80 -> - test_server:format("ok, Runtime before: {~p, _} after: {~p, ~p}", - [T1, T, Td]), - ok; - {T, R} -> - test_server:format("nok, Runtime before: {~p, _} after: {~p, ~p}", - [T1, T, R]), - runtime_zero_update1(N-1) - end; -runtime_zero_update1(0) -> - ?line test_server:fail("statistics(runtime) never returned zero difference"). - runtime_update(doc) -> - "Test that the statistics(runtime) returns a substanstially updated difference " - "after running a process that takes all CPU power of the Erlang process " - "for a second."; + "Test that the statistics(runtime) returns a substanstially " + "updated difference after running a process that takes all CPU " + " power of the Erlang process for a second."; runtime_update(Config) when is_list(Config) -> case ?t:is_cover() of false -> ?line process_flag(priority, high), - ?line test_server:m_out_of_n(1, 10, fun runtime_update/0); + do_runtime_update(10); true -> {skip,"Cover-compiled"} end. -runtime_update() -> - ?line {T1,_} = statistics(runtime), +do_runtime_update(0) -> + {comment,"Never close enough"}; +do_runtime_update(N) -> + ?line {T1,Diff0} = statistics(runtime), ?line spawn_link(fun cpu_heavy/0), receive after 1000 -> ok end, ?line {T2,Diff} = statistics(runtime), - ?line Delta = abs(Diff-1000), - ?line test_server:format("T1 = ~p, T2 = ~p, Diff = ~p, abs(Diff-1000) = ~p", - [T1,T2,Diff,Delta]), + ?line true = is_integer(T1+T2+Diff0+Diff), + ?line test_server:format("T1 = ~p, T2 = ~p, Diff = ~p, T2-T1 = ~p", + [T1,T2,Diff,T2-T1]), ?line if - abs(Diff-1000) =:= Delta, Delta =< 100 -> - ok + T2 - T1 =:= Diff, 900 =< Diff, Diff =< 1500 -> ok; + true -> do_runtime_update(N-1) end. cpu_heavy() -> @@ -212,17 +188,18 @@ reductions(Config) when is_list(Config) -> %% 300 * 4 is more than CONTEXT_REDS (1000). Thus, there will be one or %% more context switches. - reductions(300, Reductions). + Mask = (1 bsl erlang:system_info(wordsize)*8) - 1, + reductions(300, Reductions, Mask). -reductions(N, Previous) when N > 0 -> +reductions(N, Previous, Mask) when N > 0 -> ?line {Reductions, Diff} = statistics(reductions), ?line build_some_garbage(), ?line if Reductions > 0 -> ok end, ?line if Diff >= 0 -> ok end, io:format("Previous = ~p, Reductions = ~p, Diff = ~p, DiffShouldBe = ~p", - [Previous, Reductions, Diff, Reductions-Previous]), - ?line if Reductions == Previous+Diff -> reductions(N-1, Reductions) end; -reductions(0, _) -> + [Previous, Reductions, Diff, (Reductions-Previous) band Mask]), + ?line if Reductions == ((Previous+Diff) band Mask) -> reductions(N-1, Reductions, Mask) end; +reductions(0, _, _) -> ok. build_some_garbage() -> diff --git a/erts/emulator/test/system_info_SUITE.erl b/erts/emulator/test/system_info_SUITE.erl index 2c7124839a..e782d2f293 100644 --- a/erts/emulator/test/system_info_SUITE.erl +++ b/erts/emulator/test/system_info_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -35,12 +35,12 @@ %-compile(export_all). -export([all/1, init_per_testcase/2, fin_per_testcase/2]). --export([process_count/1, system_version/1, misc_smoke_tests/1]). +-export([process_count/1, system_version/1, misc_smoke_tests/1, heap_size/1]). -define(DEFAULT_TIMEOUT, ?t:minutes(2)). all(doc) -> []; -all(suite) -> [process_count, system_version, misc_smoke_tests]. +all(suite) -> [process_count, system_version, misc_smoke_tests, heap_size]. init_per_testcase(_Case, Config) when is_list(Config) -> Dog = ?t:timetrap(?DEFAULT_TIMEOUT), @@ -135,8 +135,13 @@ misc_smoke_tests(Config) when is_list(Config) -> ?line ok. - - - - +heap_size(doc) -> []; +heap_size(suite) -> []; +heap_size(Config) when is_list(Config) -> + ?line {min_bin_vheap_size, VHmin} = erlang:system_info(min_bin_vheap_size), + ?line {min_heap_size, Hmin} = erlang:system_info(min_heap_size), + ?line GCinf = erlang:system_info(garbage_collection), + ?line VHmin = proplists:get_value(min_bin_vheap_size, GCinf), + ?line Hmin = proplists:get_value(min_heap_size, GCinf), + ok. diff --git a/erts/emulator/test/trace_SUITE.erl b/erts/emulator/test/trace_SUITE.erl index 2c60ba6838..e9713fcf0f 100644 --- a/erts/emulator/test/trace_SUITE.erl +++ b/erts/emulator/test/trace_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -498,19 +498,23 @@ system_monitor_long_gc_1(doc) -> ["Tests erlang:system_monitor(Pid, [{long_gc,Time}])"]; system_monitor_long_gc_1(Config) when is_list(Config) -> erts_debug:set_internal_state(available_internal_state, true), - try - %% Add ?LONG_GC_SLEEP ms to all gc - ?line erts_debug:set_internal_state(test_long_gc_sleep, - ?LONG_GC_SLEEP), - ?line LoadFun = - fun () -> - garbage_collect(), - self() - end, - ?line long_gc(LoadFun, false) + try + case erts_debug:get_internal_state(force_heap_frags) of + true -> + {skip,"emulator with FORCE_HEAP_FRAGS defined"}; + false -> + %% Add ?LONG_GC_SLEEP ms to all gc + ?line erts_debug:set_internal_state(test_long_gc_sleep, + ?LONG_GC_SLEEP), + ?line LoadFun = fun () -> + garbage_collect(), + self() + end, + ?line long_gc(LoadFun, false) + end after erts_debug:set_internal_state(test_long_gc_sleep, 0), - erts_debug:set_internal_state(available_internal_state, false) + erts_debug:set_internal_state(available_internal_state, false) end. system_monitor_long_gc_2(suite) -> @@ -520,24 +524,29 @@ system_monitor_long_gc_2(doc) -> system_monitor_long_gc_2(Config) when is_list(Config) -> erts_debug:set_internal_state(available_internal_state, true), try - %% Add ?LONG_GC_SLEEP ms to all gc - ?line erts_debug:set_internal_state(test_long_gc_sleep, - ?LONG_GC_SLEEP), - ?line Parent = self(), - ?line LoadFun = - fun () -> - Ref = make_ref(), - Pid = - spawn_link( - fun () -> - garbage_collect(), - Parent ! {Ref, self()} - end), - receive {Ref, Pid} -> Pid end - end, - ?line long_gc(LoadFun, true), - ?line long_gc(LoadFun, true), - ?line long_gc(LoadFun, true) + case erts_debug:get_internal_state(force_heap_frags) of + true -> + {skip,"emulator with FORCE_HEAP_FRAGS defined"}; + false -> + %% Add ?LONG_GC_SLEEP ms to all gc + ?line erts_debug:set_internal_state(test_long_gc_sleep, + ?LONG_GC_SLEEP), + ?line Parent = self(), + ?line LoadFun = + fun () -> + Ref = make_ref(), + Pid = + spawn_link( + fun () -> + garbage_collect(), + Parent ! {Ref, self()} + end), + receive {Ref, Pid} -> Pid end + end, + ?line long_gc(LoadFun, true), + ?line long_gc(LoadFun, true), + ?line long_gc(LoadFun, true) + end after erts_debug:set_internal_state(test_long_gc_sleep, 0), erts_debug:set_internal_state(available_internal_state, false) diff --git a/erts/epmd/src/epmd_int.h b/erts/epmd/src/epmd_int.h index b120b44579..65fcf9bacb 100644 --- a/erts/epmd/src/epmd_int.h +++ b/erts/epmd/src/epmd_int.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1998-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ /* @@ -294,6 +294,7 @@ struct enode { char protocol; /* 0 = tcp/ipv4 */ unsigned short highvsn; /* 0 = OTP-R3 erts-4.6.x, 1 = OTP-R4 erts-4.7.x*/ unsigned short lowvsn; + int extralen; char extra[MAXSYMLEN+1]; }; diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c index b71e27cffd..a033fab244 100644 --- a/erts/epmd/src/epmd_srv.c +++ b/erts/epmd/src/epmd_srv.c @@ -1,20 +1,20 @@ /* -*- c-indent-level: 2; c-continued-statement-offset: 2 -*- */ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1998-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -99,7 +99,7 @@ static int conn_close_fd(EpmdVars*,int); static void node_init(EpmdVars*); static Node *node_reg(EpmdVars*,char*,int,int); -static Node *node_reg2(EpmdVars*,char*, int, int, unsigned char, unsigned char, int, int, char*); +static Node *node_reg2(EpmdVars*,char*, int, int, unsigned char, unsigned char, int, int, int, char*); static int node_unreg(EpmdVars*,char*); static int node_unreg_sock(EpmdVars*,int); @@ -558,11 +558,11 @@ static void do_request(g, fd, s, buf, bsize) } name = &buf[11]; name[namelen]='\000'; - extra = &buf[11+namelen+1]; + extra = &buf[11+namelen+2]; extra[extralen]='\000'; wbuf[0] = EPMD_ALIVE2_RESP; if ((node = node_reg2(g, name, fd, eport, nodetype, protocol, - highvsn, lowvsn, extra)) == NULL) { + highvsn, lowvsn, extralen, extra)) == NULL) { wbuf[1] = 1; /* error */ put_int16(99, wbuf+2); } else { @@ -622,10 +622,10 @@ static void do_request(g, fd, s, buf, bsize) offset = 12; strcpy(wbuf + offset,node->symname); offset += strlen(node->symname); - put_int16(strlen(node->extra),wbuf + offset); + put_int16(node->extralen,wbuf + offset); offset += 2; - strcpy(wbuf + offset,node->extra); - offset += (strlen(node->extra)-1); + memcpy(wbuf + offset,node->extra,node->extralen); + offset += node->extralen; if (reply(g, fd, wbuf, offset) != offset) { dbg_tty_printf(g,1,"** failed to send PORT2_RESP (ok) for \"%s\"",name); @@ -994,7 +994,7 @@ static int node_unreg_sock(EpmdVars *g,int fd) static Node *node_reg(EpmdVars *g,char *name,int fd, int port) { - return node_reg2(g, name, fd, port, 0, 0, 0, 0, NULL); + return node_reg2(g, name, fd, port, 0, 0, 0, 0, 0, NULL); } static Node *node_reg2(EpmdVars *g, @@ -1005,6 +1005,7 @@ static Node *node_reg2(EpmdVars *g, unsigned char protocol, int highvsn, int lowvsn, + int extralen, char* extra) { Node *prev; /* Point to previous node or NULL */ @@ -1103,7 +1104,8 @@ static Node *node_reg2(EpmdVars *g, node->protocol = protocol; node->highvsn = highvsn; node->lowvsn = lowvsn; - strcpy(node->extra,extra); + node->extralen = extralen; + memcpy(node->extra,extra,extralen); strcpy(node->symname,name); FD_SET(fd,&g->orig_read_mask); diff --git a/erts/etc/common/erlc.c b/erts/etc/common/erlc.c index c958fed741..09aca19e6c 100644 --- a/erts/etc/common/erlc.c +++ b/erts/etc/common/erlc.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1997-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ /* @@ -310,6 +310,8 @@ main(int argc, char** argv) case 'W': /* Enable warnings. */ if (strcmp(argv[1]+2, "all") == 0) { PUSH2("@warn", "999"); + } else if (strcmp(argv[1]+2, "error") == 0) { + PUSH2("@option", "warnings_as_errors"); } else if (isdigit((int)argv[1][2])) { PUSH2("@warn", argv[1]+2); } else { @@ -566,6 +568,7 @@ usage(void) {"-pz path", "add path to the end of Erlang's code path"}, {"-smp", "compile using SMP emulator"}, {"-v", "verbose compiler output"}, + {"-Werror", "make all warnings into errors"}, {"-W0", "disable warnings"}, {"-Wnumber", "set warning level to number"}, {"-Wall", "enable all warnings"}, diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index 4325418e7c..0ad26aeea7 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1996-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1996-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -123,6 +123,14 @@ static char *pluss_val_switches[] = { "ss", NULL }; +/* +h arguments with values */ +static char *plush_val_switches[] = { + "ms", + "mbs", + "", + NULL +}; + /* * Define sleep(seconds) in terms of Sleep() on Windows. @@ -783,7 +791,6 @@ int main(int argc, char **argv) case 'a': case 'A': case 'b': - case 'h': case 'i': case 'P': case 'S': @@ -850,6 +857,20 @@ int main(int argc, char **argv) goto the_default; break; } + case 'h': + if (!is_one_of_strings(&argv[i][2], plush_val_switches)) { + goto the_default; + } else { + if (i+1 >= argc + || argv[i+1][0] == '-' + || argv[i+1][0] == '+') + usage(argv[i]); + argv[i][0] = '-'; + add_Eargs(argv[i]); + add_Eargs(argv[i+1]); + i++; + } + break; case 's': if (!is_one_of_strings(&argv[i][2], pluss_val_switches)) @@ -1048,7 +1069,7 @@ usage_aux(void) #endif "[-make] [-man [manopts] MANPAGE] [-x] [-emu_args] " "[-args_file FILENAME] " - "[+A THREADS] [+a SIZE] [+B[c|d|i]] [+c] [+h HEAP_SIZE] [+K BOOLEAN] " + "[+A THREADS] [+a SIZE] [+B[c|d|i]] [+c] [+h HEAP_SIZE_OPTION] [+K BOOLEAN] " "[+l] [+M<SUBSWITCH> <ARGUMENT>] [+P MAX_PROCS] [+R COMPAT_REL] " "[+r] [+s SCHEDULER_OPTION] [+S NO_SCHEDULERS:NO_SCHEDULERS_ONLINE] [+T LEVEL] [+V] [+v] [+W<i|w>] " "[args ...]\n"); diff --git a/erts/lib_src/Makefile.in b/erts/lib_src/Makefile.in index ce5c846677..1d2cc7cb0c 100644 --- a/erts/lib_src/Makefile.in +++ b/erts/lib_src/Makefile.in @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2004-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2004-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # @@ -24,6 +24,7 @@ OMIT_OMIT_FP=no CC=@CC@ +GCC=@GCC@ LD=@LD@ AR=@AR@ RANLIB=@RANLIB@ @@ -114,7 +115,7 @@ endif CREATE_DIRS= -ifeq ($(CC)-$(OMIT_FP), gcc-true) +ifeq ($(GCC)-$(OMIT_FP),yes-true) CFLAGS += -fomit-frame-pointer endif diff --git a/erts/preloaded/ebin/erl_prim_loader.beam b/erts/preloaded/ebin/erl_prim_loader.beam Binary files differindex a031c90188..d7134967bf 100644 --- a/erts/preloaded/ebin/erl_prim_loader.beam +++ b/erts/preloaded/ebin/erl_prim_loader.beam diff --git a/erts/preloaded/ebin/erlang.beam b/erts/preloaded/ebin/erlang.beam Binary files differindex 39452f53d6..f490fe7c3d 100644 --- a/erts/preloaded/ebin/erlang.beam +++ b/erts/preloaded/ebin/erlang.beam diff --git a/erts/preloaded/ebin/init.beam b/erts/preloaded/ebin/init.beam Binary files differindex be1f71e6c5..39118a0109 100644 --- a/erts/preloaded/ebin/init.beam +++ b/erts/preloaded/ebin/init.beam diff --git a/erts/preloaded/ebin/otp_ring0.beam b/erts/preloaded/ebin/otp_ring0.beam Binary files differindex af44a8c9b9..4680d645cb 100644 --- a/erts/preloaded/ebin/otp_ring0.beam +++ b/erts/preloaded/ebin/otp_ring0.beam diff --git a/erts/preloaded/ebin/prim_file.beam b/erts/preloaded/ebin/prim_file.beam Binary files differindex 9391aa45cd..2cacb6808c 100644 --- a/erts/preloaded/ebin/prim_file.beam +++ b/erts/preloaded/ebin/prim_file.beam diff --git a/erts/preloaded/ebin/prim_inet.beam b/erts/preloaded/ebin/prim_inet.beam Binary files differindex b7be06e6bc..aa9b255ebb 100644 --- a/erts/preloaded/ebin/prim_inet.beam +++ b/erts/preloaded/ebin/prim_inet.beam diff --git a/erts/preloaded/ebin/prim_zip.beam b/erts/preloaded/ebin/prim_zip.beam Binary files differindex 6e1230d649..0e7adad9e8 100644 --- a/erts/preloaded/ebin/prim_zip.beam +++ b/erts/preloaded/ebin/prim_zip.beam diff --git a/erts/preloaded/ebin/zlib.beam b/erts/preloaded/ebin/zlib.beam Binary files differindex 4d9996cc74..93b05172d8 100644 --- a/erts/preloaded/ebin/zlib.beam +++ b/erts/preloaded/ebin/zlib.beam diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index 6f92b319b7..552121d485 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -51,6 +51,7 @@ -export([await_proc_exit/3]). -deprecated([hash/2]). +-deprecated([concat_binary/1]). -compile(nowarn_bif_clash). diff --git a/erts/test/erlc_SUITE.erl b/erts/test/erlc_SUITE.erl index 1d944811aa..6b4484b31e 100644 --- a/erts/test/erlc_SUITE.erl +++ b/erts/test/erlc_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(erlc_SUITE). @@ -56,6 +56,13 @@ compile_erl(Config) when is_list(Config) -> ?line run(Config, Cmd, FileName, "-W0", ["_OK_"]), + %% Try treating warnings as errors. + + ?line run(Config, Cmd, FileName, "-Werror", + ["compile: warnings being treated as errors\$", + "Warning: function foo/0 is unused\$", + "_ERROR_"]), + %% Check a bad file. ?line BadFile = filename:join(SrcDir, "erl_test_bad.erl"), diff --git a/lib/common_test/doc/src/example_chapter.xml b/lib/common_test/doc/src/example_chapter.xml index 028cbf7c8d..f269dba2cd 100644 --- a/lib/common_test/doc/src/example_chapter.xml +++ b/lib/common_test/doc/src/example_chapter.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Examples and Templates</title> @@ -38,7 +38,7 @@ <code> -module(db_data_type_SUITE). --include("ct.hrl"). +-include_lib("common_test/include/ct.hrl"). %% Test server callbacks -export([suite/0, all/0, @@ -186,7 +186,7 @@ insert_and_lookup(Key, Value, Config) -> %% Note: This directive should only be used in test suites. -compile(export_all). --include("ct.hrl"). +-include_lib("common_test/include/ct.hrl"). %%-------------------------------------------------------------------- %% COMMON TEST CALLBACK FUNCTIONS @@ -394,7 +394,7 @@ my_test_case(_Config) -> -compile(export_all). --include("ct.hrl"). +-include_lib("common_test/include/ct.hrl"). %%-------------------------------------------------------------------- %% Function: suite() -> Info diff --git a/lib/common_test/include/ct.hrl b/lib/common_test/include/ct.hrl index ad3b3374c4..aa1cc832cf 100644 --- a/lib/common_test/include/ct.hrl +++ b/lib/common_test/include/ct.hrl @@ -1,22 +1,22 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2003-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% --include("test_server.hrl"). +-include_lib("test_server/include/test_server.hrl"). -compile({parse_transform,ct_line}). diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml index c39c9b25eb..daa686bc56 100644 --- a/lib/compiler/doc/src/compile.xml +++ b/lib/compiler/doc/src/compile.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>compile</title> @@ -212,6 +212,12 @@ success.</p> </item> + <tag><c>warnings_as_errors</c></tag> + <item> + <p>Causes warnings to be treated as errors. This option is supported + since R13B04.</p> + </item> + <tag><c>return</c></tag> <item> <p>This is a short form for both <c>return_errors</c> and diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index 08ba9c3ee4..1fd61831e0 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% -module(beam_validator). @@ -604,9 +604,9 @@ valfun_4({gc_bif,Op,{f,Fail},Live,Src,Dst}, #vst{current=St0}=Vst0) -> St = kill_heap_allocation(St0), Vst1 = Vst0#vst{current=St}, verify_live(Live, Vst1), - Vst2 = prune_x_regs(Live, Vst1), - validate_src(Src, Vst2), - Vst = branch_state(Fail, Vst2), + Vst2 = branch_state(Fail, Vst1), + Vst = prune_x_regs(Live, Vst2), + validate_src(Src, Vst), Type = bif_type(Op, Src, Vst), set_type_reg(Type, Dst, Vst); valfun_4(return, #vst{current=#st{numy=none}}=Vst) -> diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index e725083a9f..58e147d508 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% Purpose: Run the Erlang compiler. @@ -302,7 +302,7 @@ os_process_size() -> list_to_integer(lib:nonl(Size)); _ -> 0 - end. + end. run_tc({Name,Fun}, St) -> Before0 = statistics(runtime), @@ -318,17 +318,30 @@ run_tc({Name,Fun}, St) -> Val. comp_ret_ok(#compile{code=Code,warnings=Warn0,module=Mod,options=Opts}=St) -> - Warn = messages_per_file(Warn0), - report_warnings(St#compile{warnings = Warn}), - Ret1 = case member(binary, Opts) andalso not member(no_code_generation, Opts) of - true -> [Code]; - false -> [] - end, - Ret2 = case member(return_warnings, Opts) of - true -> Ret1 ++ [Warn]; - false -> Ret1 - end, - list_to_tuple([ok,Mod|Ret2]). + case member(warnings_as_errors, Opts) andalso length(Warn0) > 0 of + true -> + case member(report_warnings, Opts) of + true -> + io:format("~p: warnings being treated as errors\n", + [?MODULE]); + false -> + ok + end, + comp_ret_err(St); + false -> + Warn = messages_per_file(Warn0), + report_warnings(St#compile{warnings = Warn}), + Ret1 = case member(binary, Opts) andalso + not member(no_code_generation, Opts) of + true -> [Code]; + false -> [] + end, + Ret2 = case member(return_warnings, Opts) of + true -> Ret1 ++ [Warn]; + false -> Ret1 + end, + list_to_tuple([ok,Mod|Ret2]) + end. comp_ret_err(#compile{warnings=Warn0,errors=Err0,options=Opts}=St) -> Warn = messages_per_file(Warn0), @@ -344,18 +357,18 @@ comp_ret_err(#compile{warnings=Warn0,errors=Err0,options=Opts}=St) -> messages_per_file(Ms) -> T = lists:sort([{File,M} || {File,Messages} <- Ms, M <- Messages]), PrioMs = [erl_scan, epp, erl_parse], - {Prio0, Rest} = + {Prio0, Rest} = lists:mapfoldl(fun(M, A) -> lists:partition(fun({_,{_,Mod,_}}) -> Mod =:= M; (_) -> false end, A) end, T, PrioMs), - Prio = lists:sort(fun({_,{L1,_,_}}, {_,{L2,_,_}}) -> L1 =< L2 end, + Prio = lists:sort(fun({_,{L1,_,_}}, {_,{L2,_,_}}) -> L1 =< L2 end, lists:append(Prio0)), flatmap(fun mpf/1, [Prio, Rest]). mpf(Ms) -> - [{File,[M || {F,M} <- Ms, F =:= File]} || + [{File,[M || {F,M} <- Ms, F =:= File]} || File <- lists:usort([F || {F,_} <- Ms])]. %% passes(form|file, [Option]) -> [{Name,PassFun}] @@ -495,14 +508,14 @@ select_passes([List|Ps], Opts) when is_list(List) -> select_cond(Flag, ShouldBe, Pass, Ps, Opts) -> ShouldNotBe = not ShouldBe, - case member(Flag, Opts) of + case member(Flag, Opts) of ShouldBe -> select_passes([Pass|Ps], Opts); ShouldNotBe -> select_passes(Ps, Opts) end. %% select_list_passes([Pass], Opts) -> {done,[Pass]} | {not_done,[Pass]} %% Evaluate all conditions having to do with listings in the list of -%% passes. +%% passes. select_list_passes(Ps, Opts) -> select_list_passes_1(Ps, Opts, []). @@ -782,7 +795,7 @@ clean_parse_transforms_1([F|Fs], Acc) -> clean_parse_transforms_1(Fs, [F|Acc]); clean_parse_transforms_1([], Acc) -> reverse(Acc). -transforms(Os) -> [ M || {parse_transform,M} <- Os ]. +transforms(Os) -> [ M || {parse_transform,M} <- Os ]. transform_module(#compile{options=Opt,code=Code0}=St0) -> %% Extract compile options from code into options field. @@ -815,7 +828,7 @@ foldl_transform(St, [T|Ts]) -> end; foldl_transform(St, []) -> {ok,St}. -get_core_transforms(Opts) -> [M || {core_transform,M} <- Opts]. +get_core_transforms(Opts) -> [M || {core_transform,M} <- Opts]. core_transforms(St) -> %% The options field holds the complete list of options at this @@ -1264,7 +1277,7 @@ listing(Ext, St) -> listing(LFun, Ext, St) -> Lfile = outfile(St#compile.base, Ext, St#compile.options), case file:open(Lfile, [write,delayed_write]) of - {ok,Lf} -> + {ok,Lf} -> Code = restore_expanded_types(Ext, St#compile.code), LFun(Lf, Code), ok = file:close(Lf), diff --git a/lib/compiler/test/beam_validator_SUITE.erl b/lib/compiler/test/beam_validator_SUITE.erl index ef8feb8a27..74b5d7c7eb 100644 --- a/lib/compiler/test/beam_validator_SUITE.erl +++ b/lib/compiler/test/beam_validator_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(beam_validator_SUITE). @@ -28,7 +28,7 @@ freg_range/1,freg_uninit/1,freg_state/1, bin_match/1,bin_aligned/1,bad_dsetel/1, state_after_fault_in_catch/1,no_exception_in_catch/1, - undef_label/1,illegal_instruction/1]). + undef_label/1,illegal_instruction/1,failing_gc_guard_bif/1]). -include("test_server.hrl"). @@ -52,13 +52,13 @@ all(suite) -> freg_range,freg_uninit,freg_state, bin_match,bin_aligned, bad_dsetel,state_after_fault_in_catch,no_exception_in_catch, - undef_label,illegal_instruction]. + undef_label,illegal_instruction,failing_gc_guard_bif]. beam_files(Config) when is_list(Config) -> ?line {ok,Cwd} = file:get_cwd(), ?line Parent = filename:dirname(Cwd), ?line Wc = filename:join([Parent,"*","*.beam"]), - %% Must have at least two files here, or there will could be + %% Must have at least two files here, or there will be %% a grammatical error in the output of the io:format/2 call below. ;-) ?line [_,_|_] = Fs = filelib:wildcard(Wc), ?line io:format("~p files\n", [length(Fs)]), @@ -356,6 +356,36 @@ illegal_instruction(Config) when is_list(Config) -> {{'_',y,0},{[],0,illegal_instruction}}] = Errors, ok. +%% The beam_validator used to assume that a GC guard BIF could +%% do a garbage collection even if it failed. That assumption +%% is not correct, and will cause the beam_validator to reject +%% valid programs such as this test case. +%% +%% (Thanks to Kiran Khaladkar.) +%% +failing_gc_guard_bif(Config) when is_list(Config) -> + ?line ok = process_request(lists:seq(1, 36)), + ?line error = process_request([]), + ?line error = process_request(not_a_list), + ok. + +process_request(ConfId) -> + case process_request_foo(ConfId) of + false -> + if + length(ConfId) == 36 -> + Response = ok; + true -> + Response = error + end + end, + process_request_bar(self(), [Response]). + +process_request_foo(_) -> + false. + +process_request_bar(Pid, [Response]) when is_pid(Pid) -> + Response. %%%------------------------------------------------------------------------- diff --git a/lib/compiler/test/error_SUITE.erl b/lib/compiler/test/error_SUITE.erl index 477730c3ac..cdd2434b25 100644 --- a/lib/compiler/test/error_SUITE.erl +++ b/lib/compiler/test/error_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1998-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1998-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(error_SUITE). @@ -21,11 +21,11 @@ -include("test_server.hrl"). -export([all/1, - head_mismatch_line/1,r11b_binaries/1]). + head_mismatch_line/1,r11b_binaries/1,warnings_as_errors/1]). all(suite) -> test_lib:recompile(?MODULE), - [head_mismatch_line,r11b_binaries]. + [head_mismatch_line,r11b_binaries,warnings_as_errors]. %% Tests that a head mismatch is reported on the correct line (OTP-2125). head_mismatch_line(Config) when is_list(Config) -> @@ -73,6 +73,20 @@ r11b_binaries(Config) when is_list(Config) -> ?line [] = run(Config, Ts), ok. +warnings_as_errors(Config) when is_list(Config) -> + Ts = [{warnings_as_errors, + <<" + t() -> + A = unused, + ok. + ">>, + [warnings_as_errors], + {error, + [], + [{3,erl_lint,{unused_var,'A'}}]} }], + ?line [] = run(Config, Ts), + ok. + run(Config, Tests) -> F = fun({N,P,Ws,E}, BadL) -> @@ -104,6 +118,8 @@ run_test(Conf, Test0, Warnings) -> %% Test result of compilation. ?line Res = case compile:file(File, Opts) of {error,[{_File,Es}],Ws} -> + {error,Es,Ws}; + {error,Es,[{_File,Ws}]} -> {error,Es,Ws} end, file:delete(File), diff --git a/lib/compiler/vsn.mk b/lib/compiler/vsn.mk index 72abcdde10..a5e6de7b5f 100644 --- a/lib/compiler/vsn.mk +++ b/lib/compiler/vsn.mk @@ -1 +1 @@ -COMPILER_VSN = 4.6.4 +COMPILER_VSN = 4.6.5 diff --git a/lib/cosEvent/doc/src/Makefile b/lib/cosEvent/doc/src/Makefile index 5136c7cfb5..4b76a64b7d 100644 --- a/lib/cosEvent/doc/src/Makefile +++ b/lib/cosEvent/doc/src/Makefile @@ -65,6 +65,9 @@ XML_CHAPTER_FILES = \ BOOK_FILES = book.xml +XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ + $(XML_PART_FILES) $(XML_CHAPTER_FILES) + TECHNICAL_DESCR_FILES = GIF_FILES = \ diff --git a/lib/cosEvent/doc/src/notes.xml b/lib/cosEvent/doc/src/notes.xml index afd1247b42..8cd7b9dd48 100644 --- a/lib/cosEvent/doc/src/notes.xml +++ b/lib/cosEvent/doc/src/notes.xml @@ -33,6 +33,20 @@ </header> <section> + <title>cosEvent 2.1.8</title> + + <section> + <title>Fixed Bugs and Malfunctions</title> + <list type="bulleted"> + <item> + <p>The documentation EIX file was not generated.</p> + <p>Own id: OTP-8355 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosEvent 2.1.7</title> <section> diff --git a/lib/cosEvent/vsn.mk b/lib/cosEvent/vsn.mk index 953e5fc8c9..7c908d1c5d 100644 --- a/lib/cosEvent/vsn.mk +++ b/lib/cosEvent/vsn.mk @@ -1,7 +1,9 @@ -COSEVENT_VSN = 2.1.7 +COSEVENT_VSN = 2.1.8 -TICKETS = OTP-8201 +TICKETS = OTP-8355 + +TICKETS_2.1.7 = OTP-8201 TICKETS_2.1.6 = OTP-7987 diff --git a/lib/cosEventDomain/doc/src/Makefile b/lib/cosEventDomain/doc/src/Makefile index 465b726ad1..6a0d3c353a 100644 --- a/lib/cosEventDomain/doc/src/Makefile +++ b/lib/cosEventDomain/doc/src/Makefile @@ -62,6 +62,9 @@ XML_CHAPTER_FILES = \ BOOK_FILES = book.xml +XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ + $(XML_PART_FILES) $(XML_CHAPTER_FILES) + TECHNICAL_DESCR_FILES = GIF_FILES = \ diff --git a/lib/cosEventDomain/doc/src/ch_event_domain_service.xml b/lib/cosEventDomain/doc/src/ch_event_domain_service.xml index 62378cac91..39ac915b38 100644 --- a/lib/cosEventDomain/doc/src/ch_event_domain_service.xml +++ b/lib/cosEventDomain/doc/src/ch_event_domain_service.xml @@ -97,9 +97,9 @@ ID2 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch2), %% To connect them, we must first define a connection struct: C1 = #'CosEventDomainAdmin_Connection'{supplier_id=ID1, -\011\011\011\011 consumer_id=ID2, -\011\011\011\011 ctype='STRUCTURED_EVENT', -\011\011\011\011 notification_style='Pull'}, + consumer_id=ID2, + ctype='STRUCTURED_EVENT', + notification_style='Pull'}, %% Connect them: 'CosEventDomainAdmin_EventDomain':add_connection(ED, C1), diff --git a/lib/cosEventDomain/doc/src/notes.xml b/lib/cosEventDomain/doc/src/notes.xml index fdfb21c046..0ad42948af 100644 --- a/lib/cosEventDomain/doc/src/notes.xml +++ b/lib/cosEventDomain/doc/src/notes.xml @@ -32,6 +32,24 @@ </header> <section> + <title>cosEventDomain 1.1.8</title> + + <section> + <title>Fixed Bugs and Malfunctions</title> + <list type="bulleted"> + <item> + <p>Removed superfluous VT in the documentation.</p> + <p>Own id: OTP-8353 Aux Id:</p> + </item> + <item> + <p>The documentation EIX file was not generated.</p> + <p>Own id: OTP-8355 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosEventDomain 1.1.7</title> <section> diff --git a/lib/cosEventDomain/vsn.mk b/lib/cosEventDomain/vsn.mk index 81c0b49143..483b130819 100644 --- a/lib/cosEventDomain/vsn.mk +++ b/lib/cosEventDomain/vsn.mk @@ -1,7 +1,10 @@ -COSEVENTDOMAIN_VSN = 1.1.7 +COSEVENTDOMAIN_VSN = 1.1.8 -TICKETS = OTP-8201 +TICKETS = OTP-8353 \ + OTP-8355 + +TICKETS_1.1.7 = OTP-8201 TICKETS_1.1.6 = OTP-7987 diff --git a/lib/cosFileTransfer/doc/src/Makefile b/lib/cosFileTransfer/doc/src/Makefile index 7769d5ef8c..2286db43ff 100644 --- a/lib/cosFileTransfer/doc/src/Makefile +++ b/lib/cosFileTransfer/doc/src/Makefile @@ -65,6 +65,9 @@ XML_CHAPTER_FILES = \ BOOK_FILES = book.xml +XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ + $(XML_PART_FILES) $(XML_CHAPTER_FILES) + TECHNICAL_DESCR_FILES = GIF_FILES = \ diff --git a/lib/cosFileTransfer/doc/src/notes.xml b/lib/cosFileTransfer/doc/src/notes.xml index e3b7e4819a..48d0c04236 100644 --- a/lib/cosFileTransfer/doc/src/notes.xml +++ b/lib/cosFileTransfer/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>cosFileTransfer Release Notes</title> @@ -31,6 +31,32 @@ </header> <section> + <title>cosFileTransfer 1.1.10</title> + + <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Removed obsolete SSL dependency.</p> + <p> + Own Id: OTP-8374 Aux Id:</p> + </item> + </list> + </section> + + <section> + <title>Fixed Bugs and Malfunctions</title> + <list type="bulleted"> + <item> + <p>The documentation EIX file was not generated.</p> + <p>Own id: OTP-8355 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosFileTransfer 1.1.9</title> <section> diff --git a/lib/cosFileTransfer/vsn.mk b/lib/cosFileTransfer/vsn.mk index dd92b53904..2700ecb3e3 100644 --- a/lib/cosFileTransfer/vsn.mk +++ b/lib/cosFileTransfer/vsn.mk @@ -1,9 +1,12 @@ -COSFILETRANSFER_VSN = 1.1.9 +COSFILETRANSFER_VSN = 1.1.10 TICKETS = \ - OTP-8201 + OTP-8355 \ + OTP-8374 +TICKETS_1.1.9 = OTP-8201 + TICKETS_1.1.8 = OTP-7987 TICKETS_1.1.7 = OTP-7837 diff --git a/lib/cosNotification/doc/src/Makefile b/lib/cosNotification/doc/src/Makefile index 6abcf0ef1d..bfdd2f1f8c 100644 --- a/lib/cosNotification/doc/src/Makefile +++ b/lib/cosNotification/doc/src/Makefile @@ -91,6 +91,9 @@ XML_CHAPTER_FILES = \ BOOK_FILES = book.xml +XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ + $(XML_PART_FILES) $(XML_CHAPTER_FILES) + TECHNICAL_DESCR_FILES = GIF_FILES = \ diff --git a/lib/cosNotification/doc/src/ch_BNF.xml b/lib/cosNotification/doc/src/ch_BNF.xml index 545280a1f4..73e91e3cac 100644 --- a/lib/cosNotification/doc/src/ch_BNF.xml +++ b/lib/cosNotification/doc/src/ch_BNF.xml @@ -181,7 +181,7 @@ FilterID = 'CosNotifyChannelAdmin_ConsumerAdmin': /* Character set issues */ <Ident> :=<Leader> <FollowSeq> - | \\ < Leader> <FollowSeq> + | \ < Leader> <FollowSeq> <FollowSeq> := /* <empty> */ | <FollowSeq> <Follow> @@ -215,8 +215,8 @@ FilterID = 'CosNotifyChannelAdmin_ConsumerAdmin': | <Other> | <Special> -<Special> := \\\\ - | \\' +<Special> := \\ + | \' <Leader> := <Alpha> diff --git a/lib/cosNotification/doc/src/ch_example.xml b/lib/cosNotification/doc/src/ch_example.xml index 8cb12bd241..14c0e5c6fd 100644 --- a/lib/cosNotification/doc/src/ch_example.xml +++ b/lib/cosNotification/doc/src/ch_example.xml @@ -124,7 +124,7 @@ ChFac = cosNotificationApp:start_factory([]), {AdminSupplier, ASID}= 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch, 'OR_OP'), {AdminConsumer, ACID}= -\011'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'OR_OP'), + 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'OR_OP'), %% Use the corresponding Admin object to get access to wanted Proxies diff --git a/lib/cosNotification/doc/src/notes.xml b/lib/cosNotification/doc/src/notes.xml index c66be87c7c..29879e95fb 100644 --- a/lib/cosNotification/doc/src/notes.xml +++ b/lib/cosNotification/doc/src/notes.xml @@ -32,6 +32,28 @@ </header> <section> + <title>cosNotification 1.1.13</title> + + <section> + <title>Fixed Bugs and Malfunctions</title> + <list type="bulleted"> + <item> + <p>Removed superfluous VT in the documentation.</p> + <p>Own id: OTP-8353 Aux Id:</p> + </item> + <item> + <p>Removed superfluous backslash in the documentation.</p> + <p>Own id: OTP-8354 Aux Id:</p> + </item> + <item> + <p>The documentation EIX file was not generated.</p> + <p>Own id: OTP-8355 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosNotification 1.1.12</title> <section> diff --git a/lib/cosNotification/vsn.mk b/lib/cosNotification/vsn.mk index 65f9812f31..fed10ee195 100644 --- a/lib/cosNotification/vsn.mk +++ b/lib/cosNotification/vsn.mk @@ -1,6 +1,10 @@ -COSNOTIFICATION_VSN = 1.1.12 +COSNOTIFICATION_VSN = 1.1.13 -TICKETS = OTP-8201 +TICKETS = OTP-8353 \ + OTP-8354 \ + OTP-8355 + +TICKETS_1.1.12 = OTP-8201 TICKETS_1.1.11 = OTP-7987 diff --git a/lib/cosProperty/doc/src/Makefile b/lib/cosProperty/doc/src/Makefile index 126e05ef53..baf995d35e 100644 --- a/lib/cosProperty/doc/src/Makefile +++ b/lib/cosProperty/doc/src/Makefile @@ -67,6 +67,9 @@ XML_CHAPTER_FILES = \ BOOK_FILES = book.xml +XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ + $(XML_PART_FILES) $(XML_CHAPTER_FILES) + TECHNICAL_DESCR_FILES = GIF_FILES = \ diff --git a/lib/cosProperty/doc/src/notes.xml b/lib/cosProperty/doc/src/notes.xml index be3a8d0f5e..e80c90849f 100644 --- a/lib/cosProperty/doc/src/notes.xml +++ b/lib/cosProperty/doc/src/notes.xml @@ -32,6 +32,20 @@ </header> <section> + <title>cosProperty 1.1.11</title> + + <section> + <title>Fixed Bugs and Malfunctions</title> + <list type="bulleted"> + <item> + <p>The documentation EIX file was not generated.</p> + <p>Own id: OTP-8355 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosProperty 1.1.10</title> <section> diff --git a/lib/cosProperty/vsn.mk b/lib/cosProperty/vsn.mk index 0e55352e42..c221e6fa4a 100644 --- a/lib/cosProperty/vsn.mk +++ b/lib/cosProperty/vsn.mk @@ -1,6 +1,8 @@ -COSPROPERTY_VSN = 1.1.10 +COSPROPERTY_VSN = 1.1.11 -TICKETS = OTP-8201 +TICKETS = OTP-8355 + +TICKETS_1.1.10 = OTP-8201 TICKETS_1.1.9 = OTP-7987 diff --git a/lib/cosTime/doc/src/Makefile b/lib/cosTime/doc/src/Makefile index 568e2cd4cc..83abc5e7c2 100644 --- a/lib/cosTime/doc/src/Makefile +++ b/lib/cosTime/doc/src/Makefile @@ -64,6 +64,9 @@ XML_CHAPTER_FILES = \ BOOK_FILES = book.xml +XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ + $(XML_PART_FILES) $(XML_CHAPTER_FILES) + TECHNICAL_DESCR_FILES = GIF_FILES = \ diff --git a/lib/cosTime/doc/src/notes.xml b/lib/cosTime/doc/src/notes.xml index afa10980e8..9f23a8633c 100644 --- a/lib/cosTime/doc/src/notes.xml +++ b/lib/cosTime/doc/src/notes.xml @@ -33,6 +33,20 @@ </header> <section> + <title>cosTime 1.1.8</title> + + <section> + <title>Fixed Bugs and Malfunctions</title> + <list type="bulleted"> + <item> + <p>The documentation EIX file was not generated.</p> + <p>Own id: OTP-8355 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosTime 1.1.7</title> <section> diff --git a/lib/cosTime/vsn.mk b/lib/cosTime/vsn.mk index ac5e99a0f1..db51bf39b9 100644 --- a/lib/cosTime/vsn.mk +++ b/lib/cosTime/vsn.mk @@ -1,6 +1,8 @@ -COSTIME_VSN = 1.1.7 +COSTIME_VSN = 1.1.8 -TICKETS = OTP-8201 +TICKETS = OTP-8355 + +TICKETS_1.1.7 = OTP-8201 TICKETS_1.1.6 = OTP-7987 diff --git a/lib/cosTransactions/doc/src/Makefile b/lib/cosTransactions/doc/src/Makefile index eab52d3dc9..1af9ed24b7 100644 --- a/lib/cosTransactions/doc/src/Makefile +++ b/lib/cosTransactions/doc/src/Makefile @@ -68,6 +68,9 @@ XML_CHAPTER_FILES = \ BOOK_FILES = book.xml +XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ + $(XML_PART_FILES) $(XML_CHAPTER_FILES) + TECHNICAL_DESCR_FILES = GIF_FILES = \ diff --git a/lib/cosTransactions/doc/src/notes.xml b/lib/cosTransactions/doc/src/notes.xml index 953382ef87..41a754b034 100644 --- a/lib/cosTransactions/doc/src/notes.xml +++ b/lib/cosTransactions/doc/src/notes.xml @@ -33,6 +33,20 @@ </header> <section> + <title>cosTransactions 1.2.9</title> + + <section> + <title>Fixed Bugs and Malfunctions</title> + <list type="bulleted"> + <item> + <p>The documentation EIX file was not generated.</p> + <p>Own id: OTP-8355 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosTransactions 1.2.8</title> <section> diff --git a/lib/cosTransactions/vsn.mk b/lib/cosTransactions/vsn.mk index 404a9ed7af..81e360ac2f 100644 --- a/lib/cosTransactions/vsn.mk +++ b/lib/cosTransactions/vsn.mk @@ -1,6 +1,8 @@ -COSTRANSACTIONS_VSN = 1.2.8 +COSTRANSACTIONS_VSN = 1.2.9 -TICKETS = OTP-8201 +TICKETS = OTP-8355 + +TICKETS_1.2.8 = OTP-8201 TICKETS_1.2.7 = OTP-7987 diff --git a/lib/crypto/vsn.mk b/lib/crypto/vsn.mk index f2a9b4fe24..68eecfe759 100644 --- a/lib/crypto/vsn.mk +++ b/lib/crypto/vsn.mk @@ -1 +1 @@ -CRYPTO_VSN = 1.6.3 +CRYPTO_VSN = 1.6.4 diff --git a/lib/debugger/src/dbg_ui_mon.erl b/lib/debugger/src/dbg_ui_mon.erl index 63cc9b66d1..8888075124 100644 --- a/lib/debugger/src/dbg_ui_mon.erl +++ b/lib/debugger/src/dbg_ui_mon.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(dbg_ui_mon). @@ -429,8 +429,7 @@ gui_cmd('Back Trace Size...', State) -> %% Help Menu gui_cmd('Debugger', State) -> - HelpFile = filename:join([code:lib_dir(debugger), - "doc", "html", "part_frame.html"]), + HelpFile = filename:join([code:lib_dir(debugger), "doc", "html", "index.html"]), Window = dbg_ui_mon_win:get_window(State#state.win), tool_utils:open_help(Window, HelpFile), State; diff --git a/lib/debugger/src/dbg_wx_filedialog_win.erl b/lib/debugger/src/dbg_wx_filedialog_win.erl index d883438639..9687efa981 100644 --- a/lib/debugger/src/dbg_wx_filedialog_win.erl +++ b/lib/debugger/src/dbg_wx_filedialog_win.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(dbg_wx_filedialog_win). @@ -375,7 +375,8 @@ show_completion(Wanted, State = #state{text=TC, win=Win, list=LC, completion=Com Start = length(Wanted), wxTextCtrl:setValue(TC, Path++"/"), wxTextCtrl:setInsertionPoint(TC, Start), - wxTextCtrl:setSelection(TC, Start, -1), + Last = wxTextCtrl:getLastPosition(TC), + wxTextCtrl:setSelection(TC, Start, Last), destroy_completion(Comp), wxWindow:setFocus(TC), State#state{ptext=Path, completion=undefined}; @@ -399,7 +400,7 @@ show_completion(Wanted, State = #state{text=TC, win=Win, list=LC, completion=Com LB = wxListBox:new(Temp, ?COMPLETION_WIN, [{style, ?wxLB_SINGLE}, {choices, Files}, {size, Size}]), - wxListBox:connect(LB, command_listbox_doubleclicked), + %% wxListBox:connect(LB, command_listbox_doubleclicked), wxListBox:connect(LB, command_listbox_selected), wxWindow:show(Temp), wxWindow:setFocus(TC), diff --git a/lib/debugger/src/dbg_wx_mon.erl b/lib/debugger/src/dbg_wx_mon.erl index d81069ec90..3f55c38d35 100644 --- a/lib/debugger/src/dbg_wx_mon.erl +++ b/lib/debugger/src/dbg_wx_mon.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -144,7 +144,7 @@ init2(CallingPid, Mode, SFile, GS) -> win = Win, focus = undefined, - coords = {0,0}, + coords = {20,20}, intdir = element(2, file:get_cwd()), pinfos = [], @@ -442,8 +442,7 @@ gui_cmd('Back Trace Size...', State) -> %% Help Menu gui_cmd('Debugger', State) -> - HelpFile = filename:join([code:lib_dir(debugger), - "doc", "html", "part_frame.html"]), + HelpFile = filename:join([code:lib_dir(debugger), "doc", "html", "index.html"]), Window = dbg_wx_mon_win:get_window(State#state.win), dbg_wx_win:open_help(Window, HelpFile), State; diff --git a/lib/debugger/src/dbg_wx_mon_win.erl b/lib/debugger/src/dbg_wx_mon_win.erl index dfb327fa6a..8ad4f4213f 100644 --- a/lib/debugger/src/dbg_wx_mon_win.erl +++ b/lib/debugger/src/dbg_wx_mon_win.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -104,7 +104,7 @@ create_win_batch(Title, Menus) -> Hlb = 200, Listbox = wxListBox:new(Panel, ?wxID_ANY, [{size,{?Wf,Hlb}}, {style,?wxLB_SINGLE}]), - wxSizer:add(LeftSz,Listbox,[{border, 3}]), + wxSizer:add(LeftSz,Listbox,[{proportion,1}, {border,3}]), wxListBox:connect(Listbox, command_listbox_doubleclicked), wxListBox:connect(Listbox, right_down), diff --git a/lib/debugger/src/dbg_wx_trace_win.erl b/lib/debugger/src/dbg_wx_trace_win.erl index 6e7a291493..3799acdc1b 100755 --- a/lib/debugger/src/dbg_wx_trace_win.erl +++ b/lib/debugger/src/dbg_wx_trace_win.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -571,7 +571,7 @@ update_bindings(#winInfo{bind=#sub{out=BA}}, Bs) -> wx:foldl(fun({Var,Val},Row) -> wxListCtrl:insertItem(BA, Row, ""), wxListCtrl:setItem(BA, Row, 0, dbg_wx_win:to_string(Var)), - wxListCtrl:setItem(BA, Row, 1, dbg_wx_win:to_string("~200p",[Val])), + wxListCtrl:setItem(BA, Row, 1, dbg_wx_win:to_string("~500P",[Val, 80])), Row+1 end, 0, Bs), put(bindings,Bs), diff --git a/lib/debugger/src/dbg_wx_win.erl b/lib/debugger/src/dbg_wx_win.erl index f029990aa4..faf3cc178f 100644 --- a/lib/debugger/src/dbg_wx_win.erl +++ b/lib/debugger/src/dbg_wx_win.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -75,7 +75,8 @@ create_menus(MB, [{Title,Items}|Ms], Win, Id0) -> Id = create_menu_item(Menu, Items, Win, Id0, true), wxMenuBar:append(MB,Menu,menu_name(Title,ignore)), create_menus(MB,Ms,Win,Id); -create_menus(_MB,[], _Win,Id) -> Id. +create_menus(_MB,[], _Win,Id) -> + Id. create_menu_item(Menu, [separator|Is], Win, Id,Connect) -> wxMenu:appendSeparator(Menu), @@ -102,10 +103,14 @@ create_menu_item(Menu, [{Name, _N, cascade, Items}|Is], Win, Id0,Connect) -> [{id,Id0},{lastId, Id-1},{callback,Filter}]), create_menu_item(Menu, Is, Win, Id, Connect); create_menu_item(Menu, [{Name,Pos}|Is], Win, Id, Connect) -> - Item = wxMenu:append(Menu, Id, menu_name(Name,Pos)), + MenuId = case lists:member(Name, ['Debugger']) of + true -> ?wxID_HELP; + _ -> Id + end, + Item = wxMenu:append(Menu, MenuId, menu_name(Name,Pos)), put(Name,Item), if Connect -> - wxMenu:connect(Win, command_menu_selected, [{id,Id},{userData, Name}]); + wxMenu:connect(Win, command_menu_selected, [{id,MenuId},{userData, Name}]); true -> ignore end, create_menu_item(Menu,Is,Win,Id+1, Connect); @@ -308,6 +313,8 @@ to_string(Format,Args) -> menu_name(Atom, N) when is_atom(Atom) -> menu_name(atom_to_list(Atom),N); +menu_name("Help", _) -> %% Mac needs this to be exactly this + "&Help"; menu_name(Str, Pos) when is_integer(Pos) -> {S1,S2} = lists:split(Pos,Str), S1 ++ [$&|S2]; diff --git a/lib/erl_interface/vsn.mk b/lib/erl_interface/vsn.mk index c5f4c06037..589b9e2f9c 100644 --- a/lib/erl_interface/vsn.mk +++ b/lib/erl_interface/vsn.mk @@ -1 +1 @@ -EI_VSN = 3.6.4 +EI_VSN = 3.6.5 diff --git a/lib/ic/doc/src/Makefile b/lib/ic/doc/src/Makefile index f00bba2c71..26d0932a95 100644 --- a/lib/ic/doc/src/Makefile +++ b/lib/ic/doc/src/Makefile @@ -73,6 +73,9 @@ XML_CHAPTER_FILES = \ BOOK_FILES = book.xml +XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ + $(XML_PART_FILES) $(XML_CHAPTER_FILES) + GIF_FILES = \ book.gif \ notes.gif \ diff --git a/lib/ic/doc/src/c-part.xml b/lib/ic/doc/src/c-part.xml index 91c81c8ef3..cef4399960 100644 --- a/lib/ic/doc/src/c-part.xml +++ b/lib/ic/doc/src/c-part.xml @@ -4,23 +4,21 @@ <part> <header> <copyright> - <year>2002</year> - <year>2007</year> - <holder>Ericsson AB, All Rights Reserved</holder> + <year>2002</year><year>2009</year> + <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - The Initial Developer of the Original Code is Ericsson AB. + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved online at http://www.erlang.org/. + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. + </legalnotice> <title>IDL to C language Mapping</title> diff --git a/lib/ic/doc/src/ch_c_corba_env.xml b/lib/ic/doc/src/ch_c_corba_env.xml index 557eeffdd4..bd4b52ca34 100644 --- a/lib/ic/doc/src/ch_c_corba_env.xml +++ b/lib/ic/doc/src/ch_c_corba_env.xml @@ -281,7 +281,7 @@ typedef struct { <p>By using the <em>CORBA_Environment_alloc</em>/2 function. </p> <p>The CORBA_Environment_alloc function is defined as:</p> <code type="none"> -\\011 CORBA_Environment *CORBA_Environment_alloc(int inbufsz, + CORBA_Environment *CORBA_Environment_alloc(int inbufsz, int outbufsz); </code> <p>where:</p> diff --git a/lib/ic/doc/src/ch_c_mapping.xml b/lib/ic/doc/src/ch_c_mapping.xml index 58b026ee78..f5a921bfd2 100644 --- a/lib/ic/doc/src/ch_c_mapping.xml +++ b/lib/ic/doc/src/ch_c_mapping.xml @@ -770,24 +770,24 @@ CORBA_Environment* oe_env) <p>While the <c>erlang::binary</c> idl type has the same C-definition as a generated sequence of octets :</p> <code type="none"><![CDATA[ -\011 module erlang -\011 { + module erlang + { -\011 .... + .... -\011 // an erlang binary -\011 typedef sequence<octet> binary; -\011 -\011 }; + // an erlang binary + typedef sequence<octet> binary; + + }; ]]></code> <p>it provides a way on sending trasparent data between C and Erlang.</p> <p>The C-definition (ic.h) for an erlang binary is :</p> <code type="none"> -\011 typedef struct { -\011 CORBA_unsigned_long _maximum; -\011 CORBA_unsigned_long _length; -\011 CORBA_octet* _buffer; -\011 } erlang_binary; /* ERLANG BINARY */ + typedef struct { + CORBA_unsigned_long _maximum; + CORBA_unsigned_long _length; + CORBA_octet* _buffer; + } erlang_binary; /* ERLANG BINARY */ </code> <p>The differences (between <c>erlang::binary</c> and <c><![CDATA[sequence< octet >]]></c>) are :</p> <list type="bulleted"> diff --git a/lib/ic/doc/src/ch_erl_genserv.xml b/lib/ic/doc/src/ch_erl_genserv.xml index 972eff7c17..055b751ba1 100644 --- a/lib/ic/doc/src/ch_erl_genserv.xml +++ b/lib/ic/doc/src/ch_erl_genserv.xml @@ -168,18 +168,18 @@ handle_info(Info, State) -> %% IDL specification produce(State) -> case catch random:uniform() of -\\011{'EXIT',_} -> -\\011 {stop, normal, "random:uniform/0 - EXIT", State}; -\\011RUnif -> + {'EXIT',_} -> + {stop, normal, "random:uniform/0 - EXIT", State}; + RUnif -> {reply, RUnif, State} end. init(State, S1, S2, S3) -> case catch random:seed(S1, S2, S3) of -\\011{'EXIT',_} -> -\\011 {stop, normal, State}; -\\011_ -> + {'EXIT',_} -> + {stop, normal, State}; + _ -> {noreply, State} end. </code> diff --git a/lib/ic/doc/src/ch_erl_plain.xml b/lib/ic/doc/src/ch_erl_plain.xml index 36de46f624..1d6f84b5ea 100644 --- a/lib/ic/doc/src/ch_erl_plain.xml +++ b/lib/ic/doc/src/ch_erl_plain.xml @@ -75,7 +75,7 @@ <item> <p>Main file : "plain.idl"</p> <code type="none"> -\011 + module rmod { interface random { diff --git a/lib/ic/doc/src/ch_ic_protocol.xml b/lib/ic/doc/src/ch_ic_protocol.xml index 678fdc766c..68a01a6a46 100644 --- a/lib/ic/doc/src/ch_ic_protocol.xml +++ b/lib/ic/doc/src/ch_ic_protocol.xml @@ -69,9 +69,9 @@ <title>IDL Operations</title> <p>An IDL operation is declared as follows:</p> <code type="none"> -\011[oneway] RetType Op(in IType1 I1, in IType2 I2, ..., in ITypeN IN, -\011out OType1 O1, out OType2 O2, ..., out OTypeM OM) -\011N, M = 0, 1, 2, ...\011\011(2.1.1) + [oneway] RetType Op(in IType1 I1, in IType2 I2, ..., in ITypeN IN, + out OType1 O1, out OType2 O2, ..., out OTypeM OM) + N, M = 0, 1, 2, ... (2.1.1) </code> <p>`Op' is the operation name, RetType is the return type, and ITypei, i = 1, 2, ..., N, and OTypej, j = 1, 2, ..., M, are the `in' types @@ -146,13 +146,13 @@ <section> <title>Call (Request/Reply, i.e. not oneway)</title> <code type="none"> - request:\011\011 Op\011\011\011atom()\011\011N = 0\011 -\011\011\011 {Op, I1, I2, ..., IN}\011tuple()\011\011N > 0 -\011\011\011\011\011\011\011\011(3.1.1) + request: Op atom() N = 0 + {Op, I1, I2, ..., IN} tuple() N > 0 + (3.1.1) - reply:\011\011 Ret\011\011\011\011\011M = 0 -\011\011\011 {Ret, O1, O2, ..., OM}\011\011\011M > 0 -\011\011\011\011\011\011\011\011(3.1.2) </code> + reply: Ret M = 0 + {Ret, O1, O2, ..., OM} M > 0 + (3.1.2)</code> <p><em>Notice:</em> Even if the RetType of the operation Op is declared to be 'void', a return value 'ok' is returned in the reply message. That @@ -166,9 +166,9 @@ <title>Cast (oneway)</title> <code type="none"> - notification:\011Op\011\011\011atom()\011\011N = 0 -\011\011\011{Op, I1, I2, ..., IN}\011tuple()\011\011N > 0 -\011\011\011\011\011\011\011\011(3.2.1) </code> + notification: Op atom() N = 0 + {Op, I1, I2, ..., IN} tuple() N > 0 + (3.2.1)</code> <p>(There is of course no return message). </p> </section> @@ -184,9 +184,9 @@ <title>Call</title> <code type="none"> - request:\011{'$gen_call', {self(), Ref}, Request}\011\011(4.1.1) + request: {'$gen_call', {self(), Ref}, Request} (4.1.1) - reply:\011{Ref, Reply}\011\011\011\011\011(4.1.2) </code> + reply: {Ref, Reply} (4.1.2)</code> <p>where Request and Reply are the messages defined in the previous chapter. </p> @@ -195,7 +195,7 @@ <section> <title>Cast</title> <code type="none"> - notification: {'$gen_cast', Notification}\011\011(4.2.1) </code> + notification: {'$gen_cast', Notification} (4.2.1) </code> <p>where Notification is the message defined in the previous chapter. </p> </section> @@ -205,7 +205,7 @@ <title>Erlang Distribution Protocol</title> <p>Messages (of interest here) between Erlang nodes are of the form: </p> <code type="none"> - Len(4), Type(1), CtrlBin(N), MsgBin(M)\011\011\011(5.1) </code> + Len(4), Type(1), CtrlBin(N), MsgBin(M) (5.1) </code> <p>Type is equal to 112 = PASS_THROUGH. </p> <p>CtrlBin and MsgBin are Erlang terms in binary form (as if created @@ -215,10 +215,10 @@ <p>CtrlBin (of interest here) contains the SEND and REG_SEND control messages, which are binary forms of the Erlang terms</p> <code type="none"> -\011{2, Cookie, ToPid} ,\011\011\011\011\011(5.2) </code> + {2, Cookie, ToPid} , (5.2) </code> <p>and</p> <code type="none"> -\011{6, FromPid, Cookie, ToName} ,\011\011\011\011(5.3) </code> + {6, FromPid, Cookie, ToName} , (5.3) </code> <p>respectively. </p> <p>The CtrlBin(N) message is read and written by erl_interface code diff --git a/lib/ic/doc/src/ch_java.xml b/lib/ic/doc/src/ch_java.xml index 831850f211..a189daa44b 100644 --- a/lib/ic/doc/src/ch_java.xml +++ b/lib/ic/doc/src/ch_java.xml @@ -711,14 +711,14 @@ public class sHelper { // methods public static s unmarshal(OtpInputStream in) throws java.lang.Exception { -\011: -\011: + : + : }; public static void marshal(OtpOutputStream out, s value) throws java.lang.Exception { -\011: -\011: + : + : }; }; diff --git a/lib/ic/doc/src/erl-part.xml b/lib/ic/doc/src/erl-part.xml index b5041dce7f..8dd7001436 100644 --- a/lib/ic/doc/src/erl-part.xml +++ b/lib/ic/doc/src/erl-part.xml @@ -4,23 +4,21 @@ <part> <header> <copyright> - <year>2002</year> - <year>2007</year> - <holder>Ericsson AB, All Rights Reserved</holder> + <year>2002</year><year>2009</year> + <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - The Initial Developer of the Original Code is Ericsson AB. + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved online at http://www.erlang.org/. + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. + </legalnotice> <title>IDL to Erlang language Mapping</title> diff --git a/lib/ic/doc/src/ic_c_protocol.xml b/lib/ic/doc/src/ic_c_protocol.xml index f895fe0723..26862addf9 100644 --- a/lib/ic/doc/src/ic_c_protocol.xml +++ b/lib/ic/doc/src/ic_c_protocol.xml @@ -4,23 +4,21 @@ <cref> <header> <copyright> - <year>2004</year> - <year>2007</year> - <holder>Ericsson AB, All Rights Reserved</holder> + <year>2004</year><year>2009</year> + <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - The Initial Developer of the Original Code is Ericsson AB. + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved online at http://www.erlang.org/. + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. + </legalnotice> <title>IC C Protocol Functions</title> diff --git a/lib/ic/doc/src/java-part.xml b/lib/ic/doc/src/java-part.xml index 69cc0f026c..ab4049ee2a 100644 --- a/lib/ic/doc/src/java-part.xml +++ b/lib/ic/doc/src/java-part.xml @@ -4,23 +4,21 @@ <part> <header> <copyright> - <year>2002</year> - <year>2007</year> - <holder>Ericsson AB, All Rights Reserved</holder> + <year>2002</year><year>2009</year> + <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - The Initial Developer of the Original Code is Ericsson AB. + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved online at http://www.erlang.org/. + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. + </legalnotice> <title>IDL to Java language Mapping</title> diff --git a/lib/ic/doc/src/notes.xml b/lib/ic/doc/src/notes.xml index 021a1e058f..dbafde7b4b 100644 --- a/lib/ic/doc/src/notes.xml +++ b/lib/ic/doc/src/notes.xml @@ -37,9 +37,21 @@ <title>Fixed Bugs and Malfunctions</title> <list type="bulleted"> <item> + <p>Removed superfluous VT in the documentation.</p> + <p>Own id: OTP-8353 Aux Id:</p> + </item> + <item> <p>The option c_timeout was not correctly documented.</p> <p>Own id: OTP-8307 Aux Id: seq11390</p> </item> + <item> + <p>Removed superfluous backslash in the documentation.</p> + <p>Own id: OTP-8354 Aux Id:</p> + </item> + <item> + <p>The documentation EIX file was not generated.</p> + <p>Own id: OTP-8355 Aux Id:</p> + </item> </list> </section> </section> diff --git a/lib/ic/doc/src/old_notes.xml b/lib/ic/doc/src/old_notes.xml deleted file mode 100644 index 9ba0262573..0000000000 --- a/lib/ic/doc/src/old_notes.xml +++ /dev/null @@ -1,1565 +0,0 @@ -<?xml version="1.0" encoding="latin1" ?> -<!DOCTYPE chapter SYSTEM "chapter.dtd"> - -<chapter> - <header> - <copyright> - <year>2003</year><year>2009</year> - <holder>Ericsson AB. All Rights Reserved.</holder> - </copyright> - <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - </legalnotice> - - <title>IDL Compiler Release Notes</title> - <prepared></prepared> - <docno></docno> - <checked></checked> - <date>2003-11-19</date> - <rev>AB</rev> - </header> - - <section> - <title>IC 4.1.8</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>IDL-files containing <c>result</c> or <c>Result</c> as, - for example, parameter name, caused an exit with reason - <c>bad_match</c>.</p> - <p>Own Id: OTP-4532</p> - </item> - <item> - <p>Uninitialized variables were used in <c>ic_init_ref</c> for - C backends. </p> - <p>Own Id: OTP-4537 <br></br> - - Aux Id: seq7666, ETOtr17107</p> - </item> - <item> - <p><c>CORBA_Environment_alloc()</c> left some fields - uninitialized in the returned pointer to an - <c>CORBA_Environment</c> for C backends.</p> - <p>Own Id: OTP-4538</p> - </item> - <item> - <p>The function <c>ic_compare_refs()</c> for C backends - could find two unequal references to be equal.</p> - <p>Own Id: OTP-4539</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.1.7</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Operation names were always scoped in C server backend, - irrespective of the setting of the option - <c>scoped_op_calls</c>.</p> - <p>Own Id: OTP-4521 <br></br> - - Aux Id: seq7643, ETOtr16925</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.1.6</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>For C backends generated code checks that the - <c>_length</c> field of bounded sequences (i.e. specified - as <c><![CDATA[sequence <TYPE, MAX>]]></c>) does not exceed the - specified maximum length. If so, an exception is raised.</p> - <p>Own Id: OTP-4471</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>The <c>_maximum</c> field was not set for sequence structs - generated by the C backends.</p> - <p>Own Id: OTP-4471 <br></br> - - Aux Id: seq7600, ETOtr16308</p> - </item> - <item> - <p>There was a memory leak in C backends in case there was a - decoding error in a sequence with elements of basic type.</p> - <p>Own Id: OTP-4475</p> - </item> - <item> - <p>For for C backends, IDL structs defined within an - interface were not mapped into C structs in appropriate - include files.</p> - <p>Own Id: OTP-4481 <br></br> - - Aux Id: seq7617</p> - </item> - <item> - <p>If the user, incorrectly, trap exit's but did not use the - 'handle_info' compile option it would cause the server to - terminate. The same problem occurred if someone, - illegally, sent a message to the server. It could also - happen for illegal oneway operations.</p> - <p>Own Id: OTP-4488</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.1.5</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Invalid C code was generated for type short. </p> - <p>Own Id: OTP-4450 <br></br> - - Aux Id: seq7582</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.1.4</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Operation functions inherited by an interface were not - placed in the map table in generated code for the C server - backend. As a result such functions were not found by the - switch function of the interface.</p> - <p>Own Id: OTP-4448 <br></br> - - Aux Id: seq7582</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.1.3.1</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A non-ANSI compliant construct in libic.a was changed.</p> - <p>Own Id: -</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.1.3</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>For Erlang and C back-ends an IC version stamp has been - added to generated source code. This stamp i preserved in - compiled target code.</p> - </item> - <item> - <p>For C backends an <c>assert()</c> expression has been - added to generated code. That expression asserts that the - result of a memory allocation size calculation is strictly - positive. An error will result in a printout and an - <c>abort()</c>. The assertion can be inhibited by defining - the macro <c>NDEBUG</c> (according to ANSI C).</p> - <p>If the assertion is inhibited, and a size calculation error - is detected, an INTERNAL CORBA exception is set. </p> - </item> - <item> - <p>An internal reorganization of C backend generator code has - been done (addition of module <c>ic_cclient</c>). Several - changes has been done in generated C code:</p> - <list type="bulleted"> - <item> - <p>The typedef <c>___generic___</c> has been replaced by - the typedef <c>___exec_function___</c>, which has been - made more strict; for backward compatibility the - <c>___generic___</c> typedef is now an alias for - <c>___exec_function___</c>.</p> - </item> - <item> - <p>Function parameters that are arrays, has been changed - to be pointers to array slices, which are equivalent - according to ANSI C. </p> - </item> - <item> - <p>The storage class specifier <c>extern</c> has been - removed from function prototypes in header files.</p> - </item> - <item> - <p>Redundant type casts have been removed from generated code. - Also some local "generic" variables have been renamed.</p> - </item> - </list> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Module info vsn replaced by app_vsn.</p> - <p>Own Id: OTP-4341</p> - </item> - <item> - <p>IC-4.1.2 disabled the definition of float constants - beginning with a zero (e.g. <c>0.14</c>).</p> - <p>Own Id: OTP-4367</p> - </item> - <item> - <p>IC did not handle constant definitions correctly for - char, string, wchar and wstring.</p> - <p>Own Id: OTP-4067, OTP-3222</p> - </item> - <item> - <p>IC did not recognize all reserved words defined in the - OMG specification (2.3.1). The new keywords are <c>fixed, abstract, custom, factory, local, native, private, public, supports, truncatable, 'ValueBase'</c> and - <c>valuetype</c>. But for now this is only active for the - <c>erl_corba</c> backend and only incorrect usage of - <c>fixed</c>, since this datatype is now supported, - triggers an error for this backend.</p> - <p>Own Id: OTP-4368</p> - </item> - <item> - <p>It was not possible to use wchar or wstring inside a - union body when using the Java backend.</p> - <p>Own Id: - OTP-4365</p> - </item> - <item> - <p>The compile options <c>this</c> and <c>handle_info</c> - did not behave as described in the documentation. The - <c>timeout</c> now behaves as, for example, - <c>handle_info</c>.</p> - <p>Own Id: OTP-4386, OTP-3231</p> - </item> - <item> - <p>If we typedef a sequence, which contains a struct or a union, - the access function <c>id/0</c> returned an incorrect IFR Id - if a prefix pragma was used.</p> - <p>Own Id: OTP-4387</p> - </item> - <item> - <p>If an IDL file contained a prefix pragma, incorrect - IFR-id's was generated in the IFR-registration operation - <c>oe_register</c> for aliases (typedef) and - attributes.</p> - <p>Own Id: OTP-4388, OTP-4392</p> - </item> - <item> - <p>For C back-ends, when encodings/decodings failed, memory - allocated for variable size parameter types was not freed.</p> - <p>Own Id: OTP-4391 - <br></br> -Aux Id: seq7438, ETOtr14009</p> - </item> - <item> - <p>If an IDL file contained a multiple typedef - (e.g. typedef string str1, str2;), the <c>oe_unregister</c> - operation failed to remove all data, in this case str2, - from the IFR.</p> - <p>Own Id: OTP-4393</p> - </item> - <item> - <p>IC did not recognize octet-constants - (e.g. const octet octetmax = 255;).</p> - <p>Own Id: OTP-4400</p> - </item> - <item> - <p>Negative 'long long' constants was not accepted - (e.g. const long long MyConstant = -1;).</p> - <p>Own Id: OTP-4401</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.1.2</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Merging of map's (<em>___map___</em>) using the - <em>___merge___</em> function does not work.</p> - <p>Own Id: OTP-4323</p> - </item> - <item> - <p>Error in generated C decode/encode functions for union's with - discriminator where the union has no value for all discriminator - values. E.g. a union with discriminator boolean where only the - discriminator value TRUE has a corresponding union value. - Here is how such a thing would look in IDL:</p> - <pre> -\011 union OptXList switch(boolean) { -\011 case TRUE: integer val; - }; - </pre> - <p>Own Id: OTP-4322</p> - </item> - <item> - <p>Scoped op calls ('{scoped_op_calls, true}') does not handle - module/function names beginning with capital letter (e.g. - Megaco should be 'Megaco') for oneway operations (handle_cast).</p> - <p>Own Id: OTP-4310</p> - </item> - <item> - <p>A bug is fixed on C-IDL erlang binaries that caused - pointer error when residing inside sequences.</p> - <p>Own Id: OTP-4303</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.1.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>A new option 'multiple_be' is added that allows multiple backend - generation for the same IDL file.</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug is fixed on IDL types that contain underscore '_'.</p> - <p>Own Id: OTP-3710</p> - </item> - <item> - <p>A bug is fixed on IDL structs that caused scope confusion - when types and fields of a struct had the same name.</p> - <p>Own Id: OTP-2893</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.0.7</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>The Erlang binary special type is introduced, that - allows efficient transfer of binaries between Erlang and C. </p> - <p>Own Id:OTP-4107</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.0.6</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug is fixed on noc backend which caused generation of erroneous code.</p> - <p>Own Id: OTP-3812</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.0.5</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>The pragma code option is extended to point - specific functions on NOC backend, not only - interfaces.</p> - <p></p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.0.4</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug in pragma prefix when including IDL files is fixed. - This caused problems for Erlang-corba IFR registrations.</p> - <p>Own Id: OTP-3620</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.0.3</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Limited support on multiple file module definitions.</p> - <p>The current version supports multiple file module definitions all - backends except the c oriented backends.</p> - <p>Own Id: OTP-3550</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.0.2</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug is fixed on Erlang backends.</p> - <p>The (recently) introduced generation of files - describing sequence and array files were even - true for included interfaces. In the case of - some Erlang backends this were unnecessary.</p> - <p>Own Id: OTP-3485</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.0.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>New functionality added on Java and Erl_genserv backends.</p> - <p></p> - <list type="bulleted"> - <item> - <p>On the Java client stub :</p> - <p></p> - <list type="bulleted"> - <item> - <p>The Java client have now one more constructor function, - that allows to continue with an already started connection.</p> - </item> - <item> - <p><c>void __stop()</c> which sends a stop cast call to the server. - While this causes the Erlang server to terminate, it - sets a stop flag to the Java server environment, requesting the - server to terminate.</p> - </item> - <item> - <p><c>void __reconnect()</c> which closes the current client connection - if open and then connects to the same server.</p> - </item> - </list> - <p>The Environment variable is now declared as <c>public</c>. </p> - </item> - <item> - <p>On the Java server skeleton :</p> - <p></p> - <list type="bulleted"> - <item> - <p><c>boolean __isStopped()</c> which returns true if a <c>stop</c> - message where received, false otherwise. The user must check if - this function returns true, and in this case exit the implemented - server loop.</p> - </item> - </list> - <p>The Environment variable is now declared as <c>protected</c> which - allows the implementation that extends the stub to access it.</p> - </item> - <item> - <p>On the Erlang gen_server stub :</p> - <p></p> - <list type="bulleted"> - <item> - <p><c>stop(Server)</c> which yields to a cast call to the standard - gen_server <c>stop</c> function. This will always terminate the - Erlang gen_server, while it will set the stop flag for the - Java server stub.</p> - </item> - </list> - </item> - </list> - <p>Own Id: OTP-3433</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 4.0</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>New types handled by IC.</p> - <p>The following OMG-IDL types are added in this compiler version :</p> - <list type="bulleted"> - <item> - <p>long long</p> - <p>unsigned long long</p> - <p>wchar</p> - <p>wstring</p> - </item> - </list> - <p>Own Id: OTP-3331</p> - <p></p> - </item> - <item> - <p>TypeCode as built in type and access code files for array and sequence types.</p> - <list type="bulleted"> - <item> - <p>As TypeCode is a <c>pseudo</c>-interface, it is now is a built-in type on IC.</p> - </item> - <item> - <p>Access code files which contain information about TypeCode, ID and Name are - now generated for user defined arrays and sequences.</p> - </item> - </list> - <p>Own Id: OTP-3392</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.8.2</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <p>A bug is fixed on preprocessor directive expansion.</p> - <p>When nested #ifdef - #ifndef directives, a bug caused - improper included file expansion. This is fixed by - repairing the preprocessor expansion function.</p> - <p>Own Id: OTP-3472</p> - </section> - </section> - - <section> - <title>IC 3.8.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Build in Erlang types support for java-backends</p> - <p>The built-in Erlang types <c>term, port, ref</c> and <c>pid</c> - are needed in Java backends in order to support an - efficient mapping between the two languages. - The new types are also supported by additional - helpers and holders to match with OMGs Java mapping - As a result of this, the following classes are added to - the <c>com.ericsson.otp.ic</c> interface :</p> - <list type="bulleted"> - <item> - <p><c>Term,TermHelper,TermHolder</c> which represents the - built-in Erlang type <c>term</c></p> - </item> - <item> - <p><c>Ref,RefHelper,RefHolder</c> which represents the - built-in Erlang type <c>ref</c></p> - </item> - <item> - <p><c>Port,PortHelper, PortHolder</c> which represents the - built-in Erlang type <c>port</c></p> - </item> - <item><c>Pid, PidHelper and PidHolder</c> which represents the - built-in Erlang type <c>pid</c></item> - </list> - <p></p> - <p>Own Id: OTP-3348</p> - <p></p> - </item> - <item> - <p>Compile time preprocessor macro variable definitions</p> - <p>The preprocessor lacked possibility to accept user - defined variables other than the one defined in IDL files. - This limited the use of command-ruled IDL specifications. - Now the build-in preprocessor allows the user to set variables - by using the "preproc_flags" option the same way - as using the "gcc" preprocessor.</p> - <p>Supported flags : </p> - <list type="bulleted"> - <item> - <p><c><![CDATA["-D< Variable >"]]></c> which defines a variable</p> - </item> - <item> - <p><c><![CDATA["-U< Variable >"]]></c> which undefines a variable</p> - </item> - </list> - <p></p> - <p>Own Id: OTP-3349</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <p>A bug on comment type expansion is fixed.</p> - <p>The comment type expansion were erroneous when - inherited types (NOC backend). - This is now fixed and the type naming agree with - the scope of the inheritor interface.</p> - <p>Own Id: OTP-3346</p> - </section> - </section> - - <section> - <title>IC 3.8</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>The code generated for java backend is optimized - due to use of streams instead for tuple classes - when (un)marshalling message calls. - Support for building clients using asynchronous - client calls and effective multi-threaded servers.</p> - <p>Own Id: OTP-3310</p> - <p></p> - </item> - <item> - <p>The <c>any</c> type is now supported for java backend.</p> - <p>Own Id: OTP-3311</p> - </item> - </list> - </section> - - <section> - <title>A bug on C generated constants is fixed</title> - <p>While the constants are evaluated and behave well when used - inside an IDL specification their C-export were not working properly. - The constant export definitions were not generated well :</p> - <list type="bulleted"> - <item> - <p>the declared C definition were erroneous ( the name did not always agree - with the scope the constant were declared in ).</p> - </item> - <item> - <p>there were no C- definition generated for the c-server backend when - the constants were declared inside an interface.</p> - </item> - </list> - <p>Own Id: OTP-3219</p> - </section> - - <section> - <title>Incompatibilities</title> - <p>Due to optimizations in java backend, the stub initialization and usage - differs than the previous version.</p> - <p>Client stub interface changes:</p> - <list type="bulleted"> - <item> - <p>Client disconnects by calling the <c>__disconnect()</c> function instead - for the old <c>_closeConnection()</c></p> - <p></p> - </item> - <item> - <p>All <c>marshal</c> operation functions have now the interface :</p> - <p><c><![CDATA[void _< OpName >_marshal(Environment<, Param |, Params >)]]></c></p> - <p>instead for</p> - <p><c><![CDATA[OtpErlangTuple _< OpName >_marshal(< Param, | Params, >OtpErlangPid, OtpErlangRef)]]></c></p> - <p></p> - </item> - <item> - <p>All <c>unmarshal</c> operation functions have now the interface :</p> - <p><c><![CDATA[< Ret value > _< OpName >_unmarshal(Environment<, Param |, Params >)]]></c></p> - <p>instead for</p> - <p><c><![CDATA[< Ret value > _< OpName >_unmarshal(< Param, | Params, >OtpErlangTuple, OtpErlangRef)]]></c></p> - <p></p> - </item> - <item> - <p>Call reference extraction is available by the client function :</p> - <p><c>OtpErlangRef __getRef()</c></p> - <p>instead for previous function :</p> - <p><c>OtpErlangRef _getReference(OtpErlangTuple)</c></p> - <p></p> - </item> - </list> - <p>Server skeleton interface changes:</p> - <list type="bulleted"> - <item> - <p>The implementation function no longer have to contain the - two (2) contractor functions (with <c>super()</c>). This is due - to the fact that there is only one contractor function for each - skeleton file :</p> - <p><c><![CDATA[public _< interface name >ImplBase()]]></c></p> - <p></p> - </item> - <item> - <p>The parameter for the caller identity extraction function <c>_getCallerPid</c> - is now an <c>Environment</c> variable instead for an <c>OtpErlangTuple</c>.</p> - <p></p> - </item> - <item> - <p>There is a new <c>invoke</c> function :</p> - <p><c>OtpOutputStream invoke(OtpInputStream)</c></p> - <p>instead for the old one :</p> - <p><c>OtpErlangTuple invoke(OtpErlangTuple)</c></p> - <p></p> - </item> - <item> - <p>The <c>OtpConnection</c> class function used for receiving messages is now :</p> - <p><c>OtpInputStream receiveBuf()</c></p> - <p>instead for the old one :</p> - <p><c>OtpErlangTuple receive()</c></p> - <p></p> - </item> - <item> - <p>The <c>OtpConnection</c> class function used for sending messages is now :</p> - <p><c>void sendBuf(OtpErlangPid, OtpOutputStream)</c></p> - <p>instead for the old one :</p> - <p><c>void send(OtpErlangPid, OtpErlangTuple)</c></p> - <p></p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.7.1</title> - - <section> - <title>Improvements and New Features</title> - <p>Some memory usage optimizations for the compiler were done.</p> - </section> - - <section> - <title>Fixed bugs and malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug is fixed when C backend is used.</p> - <p>When C-union with enumerant discriminator, the size - calculation of the discriminator value were erroneous. - This lead to the side effect that only the first case of the - union were allowed. - The error were fixed by fixing the size calculation of - the discriminator. </p> - <p>Own Id: OTP-3215</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.7</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug is fixed when C backend is used.</p> - <p>When unions with enumerant discriminator - were decoded, an error encountered in the - union size calculation. </p> - <p>Own Id: OTP-3209</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.6</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug is fixed when NOC backend is used.</p> - <p>When several functions with the same name - were found in the included file tree, - a compile time failure occurred.</p> - <p>Own Id: OTP-3203</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.5</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Noc backend optimization</p> - <p>When NOC backend is choosen, the type code - information on the stub functions is reduced - to a single atom "no_tk". - This is the default behavior. The typecode - generation is enabled by the "use_tk" switch.</p> - <p>Own Id: OTP-3196</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>General java backend bug fixes </p> - <p>Protocol errors on user defined structures and - union types are corrected.</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.4</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Semantic test enhancements.</p> - <p>The compiler detects now semantic errors when enumerant - values collide with user defined types on the same name scope.</p> - <p>Own Id: OTP-3157 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>General java backend bug-fixes </p> - <p>Several bugs were fixed on user defined types.</p> - <list type="bulleted"> - <item> - <p>Union discriminators work better when - all possible case values are defined.</p> - </item> - <item> - <p>A bug on Interface inherited operations is - fixed that cause errors on generated server switch.</p> - </item> - <item> - <p>Type definitions on included files are better generated. </p> - </item> - </list> - <p>Own Id: OTP-3156 <br></br> -</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.3</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>A new back-end which generates Java code according to the CORBA IDL to Java mapping for - communication with the Erlang distribution protocol has been added to IC. - For the moment there is no support for the Erlang types Pid, Ref, Port and Term - but this will be added later.</p> - <p>Own Id: OTP-2779 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Fixed the bug that the c code backends sometimes generated incorrect code for - struct arguments. They shall always be pointers. </p> - <p>Own Id: OTP-2732 <br></br> -</p> - </item> - <item> - <p>The code generation is fixed so the array parameters now follow the - CORBA V2.0 C mapping.</p> - <p>Own Id: OTP-2873 <br></br> -</p> - </item> - <item> - <p>Fixed the problem that the checking of the numbers of out-parameters always was true.</p> - <p>Own Id: OTP-2944 <br></br> -</p> - </item> - <item> - <p>Fixed the bug that some temporary variables was not declared when c code.</p> - <p>Own Id: OTP-2950 <br></br> -</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.2.2</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Unions are now supported to agree with OMG's C mapping.</p> - <p>Own Id: OTP-2868 <br></br> -</p> - </item> - <item> - <p>There is now a possibility to use pre- and postcondition methods on the server side - for IC generated Corba Objects. The compiler option is documented in the ic reference manual - and an example of how the pre- and postcondition methods should be designed and used is - added to ic example directory (an ReadMe.txt file exists with some instructions for - running the example code).</p> - <p>Own Id: OTP-3068 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>The compiler ignores unknown/non supported pragma directives. A warning is raised - while the generated code will then be the same as if the corresponding - (unknown) pragma directive were missing. </p> - <p>Own Id: OTP-3052 <br></br> -</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.2.1</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Wrong C code was generated for limited strings when they where included - from another IDL specification.</p> - <p>Own Id: OTP-3033 <br></br> -</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.2</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>The buffers for in/output used by C-stubs are now expandable. - This fixes buffer overflow problems when messages received/sent - do not fit in buffers.</p> - <p>Own Id: OTP-3001 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <p>The CORBA_Environment structure has now two new fields, the buffers for in/output - must now be dynamically allocated.</p> - </section> - </section> - - <section> - <title>IC 3.1.2</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>The generated IFR registration function for constants has been fixed - so the parameters are correct.</p> - <p>Own Id: OTP-2856 <br></br> -</p> - </item> - <item> - <p>Error in the C code generation of ONEWAY operations without parameters - The bug was an decoding error in the operation header. The generated code expected one - parameter instead of zero. This is now fixed.</p> - <p>Own Id: OTP-2909 <br></br> -</p> - </item> - <item> - <p>Type problems on floats and booleans fixed.</p> - <p>Erroneous code for runtime checks on float was removed and - the internal format of the data representing the boolean value - is upgraded.</p> - <p>Own Id: OTP-2925 <br></br> -</p> - </item> - <item> - <p>The generated code for arrays of typedefined strings were - erroneous in the C-backends due to a failure in the compiler internal type - checking.</p> - <p>Own Id: OTP-2936 <br></br> -</p> - </item> - <item> - <p>The generated code for typedefined nested sequences were erroneous - in the C-backends. Pointer mismatches caused compilation failure.</p> - <p>Own Id: OTP-2937 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <p>The IDL specifications must be regenerated for C due to changes in the code generation.</p> - <p>One must regenerate IDL specifications for Erlang CORBA if there are constants in the - specification due to previous errors in the IFR registration functions (OTP-2856).</p> - </section> - </section> - - <section> - <title>IC 3.1.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Improvements on error report on unsupported types by</p> - <p>propagating warning when declaring unions in C -backends</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug is fixed when arrays that contained variable size data - on C-backends</p> - <p>The compiler generated erroneous code when IDL - defined arrays that contained variable size data such - as strings, variable size structs or sequences.</p> - <p>Own Id: OTP-2900 <br></br> -</p> - </item> - <item> - <p>A bug is fixed when sequences that contained variable size data - on C_backends</p> - <p>The compiler generated erroneous code when IDL - defined arrays that contained variable size data such - as strings, variable size structs or other sequences.</p> - <p>Own Id: OTP-2901 <br></br> -</p> - </item> - <item> - <p>A bug concerning bounded strings on C-backends is fixed.</p> - <p>The compiler generated erroneous code for IDL - defined bounded strings. Syntax errors were generated - in special cases of typdedefined strings.</p> - <p>Own Id: OTP-2898 <br></br> -</p> - </item> - <item> - <p>A runtime error when sequences that contained integer types is fixed.</p> - <p>When C-clients/server that communicated with Erlang clients/servers, - and the data send by Erlang part were a list of small numbers, - the Erlang runtime compacts the list to a string. This caused a - runtime error when sending sequences of integer types and all had - value less than 256.</p> - <p>Own Id: OTP-2899 <br></br> -</p> - </item> - <item> - <p>An OMG IDL - C mapping problem on enumerant values is fixed.</p> - <p>The enumerant values names is now prefixed by the current scope, - as defined in the specification.</p> - <p>Own Id: OTP-2902 <br></br> -</p> - </item> - <item> - <p>A problem when using constants in array declarations is fixed.</p> - <p>Array dimensions declared with constants generated erroneous code.</p> - <p>Own Id: OTP-2864 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>Changes in C-generation on enumerant values.</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.1</title> - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug is fixed on the generated structures. </p> - <p>The generated C code for the structures corresponds now - to direct mapping of C-structs. </p> - <p>Own Id: OTP-2843 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>Included structures inside a struct are no longer pointers.</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 3.0</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Interface change for C-backends</p> - <p>Major interface change. The new interface is CORBA 2.0 - compliant.</p> - <p>Own Id: OTP-2845 <br></br> -</p> - </item> - <item> - <p>The C-backends functionality is improved</p> - <list type="bulleted"> - <item> - <p>Due to interface change and some unneeded error - checks,the C-generated code is fairly optimized.</p> - </item> - </list> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Several serious bugs on decoding and memory allocation are fixed. </p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>Interface change on the C-backends</p> - <p>In order to be CORBA 2.0 compatible, the new version - generates fully incompatible C code.</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 2.5.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>A new backend is added : C-server</p> - <p>This back-ends can be used to create servers, - compatible to c-clients, and Erlang genserver clients. - The code produced is a collection of functions for - encoding and decoding messages and a switch that coordinates - them. These parts can be used to create other servers as well. - All functions are exported to header files.</p> - <p>Own Id: OTP-2713 <br></br> -</p> - </item> - <item> - <p>The C-client functionality is improved</p> - <list type="bulleted"> - <item> - <p>The static buffer used for input/output is removed along - with the <c>memset</c> function that initiated it. - The new client is at least 20-30 percent faster.</p> - </item> - <item> - <p>The internal structure of the client is changed. - The client functions are now a collection of encoding - and decoding message functions ruled by a specific - call function. While the basic client generated is - a synchronous client, the exported functions - support the implementation of threaded asynchronous - clients.</p> - </item> - <item> - <p>The static buffer used for input/output is remove along - with the <c>memset</c> function that initiated it. - The new client is at least 20-30 percent faster.</p> - </item> - <item> - <p>The code generated is generally improved, warnings are - (almost) eliminated, while no unidentified variable - errors occur.</p> - </item> - <item> - <p>The IDL types unsigned shorts, shorts, floats are supported now.</p> - </item> - <item> - <p>All generated functions are exported in client header files..</p> - </item> - </list> - <p>Own Id: OTP-2712 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Changes in compiler usage and code generation.</title> - <list type="bulleted"> - <item> - <p>A new option is added for the C-server back-end : <c>c_server</c>.</p> - </item> - <item> - <p>A new option is added : <c>scoped_op_calls</c>.</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A bug oneway operations on erl_corba and erl_genserv that caused - en exit due to internal interface error is fixed. </p> - </item> - <item> - <p>A bug on oneway operations on c_genserv back-end that caused several - variables to be unidentified is fixed. </p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>Interface change on the C-client</p> - <p>The client functions are called with two extra variables, a pointer to - an array of char - used for storage and an integer - the array size</p> - </item> - <item> - <p>The IDL type <c>attribute</c> is disabled, due to some implementation problems.</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 2.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>The compiler now provides more in depth information (printouts) when errors occur.</p> - <p>In some cases the compiler stops compiling - due to an abnormal exit or incompatible input. - In this situation, a "fatal error" may occur but the compiler will - generate information explaining the problem.</p> - <p>Own Id: OTP-2565 <br></br> -</p> - </item> - </list> - </section> - </section> - - <section> - <title>IC 2.0</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>The IDL compiler is now a separate application and is longer a part of Orber.</p> - </item> - <item> - <p>Pragma handling implementation.</p> - <p>Pragma ID, prefix - and version are implemented to agree with CORBA revision - 2.0. The compiler accepts and applies these on the - behavior of the compiled code. <br></br> - In this implementation, - pragmas are accepted by the parser and applied by the use - of ic_pragma functions. <br></br> - All IFR-identity handling now - passes through pragma table. As pragma handling in OMG-IDL - is affecting the identity of an ifr-object, all identity - handling and registration is now controlled by pragma - functions. A hash table called "pragmatab" contains vital - identity information used under compilation. <br></br> -</p> - <p>There two major pragma categories :</p> - <list type="bulleted"> - <item> - <p>Normal pragmas, are used in the code where - basic definitions and statements appear. </p> - </item> - <item> - <p>Under certain circumstances, ugly pragmas can now - appear inside code, parameter lists, structure - definitions ... etc. <br></br> - It is quite challenging to - allow ugly pragmas, but the effects of unlimited ugly - pragma implementation on the parser can be enormous. - Ugly pragmas can cause the parser source code to - become time consuming and user unreadable. <br></br> - In order - to allow ugly pragmas but not destroy the current - structure of the parser, the use of ugly pragmas is - limited. Multiple pragma directives are allowed - inside parameter lists, unions, exceptions, - enumerated type, structures... as long as they are do not - appear between two keywords or between keywords and - identifiers. </p> - </item> - </list> - <p>The pragma effect is the same for both scope and basic - pragma rules. </p> - <p>When compiling, an IFR-identity - must be looked up several times but by storing identity aliases inside - the pragma table there this an increase in both speed and - flexibility. </p> - <p>Own Id: OTP-2128 <br></br> -</p> - </item> - <item> - <p>Code for interface inheritance registration for the IFR - registration code .</p> - <p>Inherited interfaces can now - be registered as a list of interface descriptions by - entering code for inherited interface registration under - new interface creation. This is achieved by correcting the - function reg2/6 and adding two more functions, - get_base_interfaces/2 and call_fun_str/2 </p> - <p>Own Id: - OTP-2134 <br></br> -</p> - </item> - <item> - <p>IFR registration checks for included IDL files.</p> - <p>All top level definitions (with respect to the scope) - - modules, interfaces, constants, types or exceptions - found - in an IDL file are either defined inside the compiled IDL - file or inside included files. - By having an extended registration of all top level - definitions it becomes possible to simply produce checks - for those included by the current IDL file. - A function call include_reg_test/1 is added in all - OE_* files that checks for IFR-registration on all included - IDL files. The code for that function is added inside the - OE_* file, while the function is called under OE_*:OE_register/0 - operation. </p> - <p>Own Id: OTP-2138 <br></br> -</p> - </item> - <item> - <p>Exception registration under IFR-operation creation.</p> - <p>By entering code for exception registration under operation - creation, the exceptions of an operation can be checked now. - This is done by correcting the function get_exceptions/4 - and adding two more functions, excdef/5 and get_EXC_ID/5 - ( the last two are cooperating with the first one and - all three are defined in the module "ictk" ). </p> - <p>Own Id: OTP-2102 <br></br> -</p> - </item> - <item> - <p>New back-end to IDL compiler : Plain Erlang.</p> - <p>The new back-end just translates IDL specifications - to Erlang module calls. No pragmas are allowed.</p> - <p>Own Id: OTP-2471 <br></br> -</p> - </item> - <item> - <p>New back-end to IDL compiler : generic server.</p> - <p>A new back-end that translates IDL specifications - to a standard OTP generic server.</p> - <p>Own Id: OTP-2482 <br></br> -</p> - </item> - <item> - <p>New back-end to IDL compiler : c client generation</p> - <p>A new back-end that translates IDL specifications - to a C API for accessing servers in Erlang. </p> - <p>Own Id: OTP-1511 <br></br> -</p> - </item> - <item> - <p>All records in generated files reveal own Erlang modules.</p> - <p>In Erlang related back-ends, every structure - which generates definition form is a record, - (such as union, struct, exception.... ). These records are - held in a generated Erlang files which - contain functions that reveal record information. <br></br> - - The Erlang file which contain these functions is - named after the scope of the record (similar - to the generated module and interface files). <br></br> - - Three functions are available :</p> - <list type="bulleted"> - <item> - <p>tc/0 - returns the record type code,</p> - </item> - <item> - <p>id/0 - returns the record id,</p> - </item> - <item> - <p>name - returns the record name.</p> - </item> - </list> - <p>Own Id: OTP-2473 <br></br> -</p> - </item> - <item> - <p>Changes in compiler usage and code generation.</p> - <list type="bulleted"> - <item> - <p>New compilation flags. - New flag be ( = back-end ) which is - used by the compiler to choose back-end. - Default back-end is set to erl_corba.</p> - </item> - <item> - <p>Stub files have an extra function oe_dependency/0 - indicating file dependency. This - helps the user to determine which IDL files should to - be compiled beside the compiled file. </p> - </item> - </list> - <p>Own Id: OTP-2474 <br></br> -</p> - </item> - <item> - <p>The IDL generation for CORBA is changed so standard gen_server return values can be used - from the implementation module. The change is compatible so that old values remain valid.</p> - <p>Own Id: OTP-2485 <br></br> -</p> - </item> - <item> - <p>It's now possible to generate an API to a CORBA object that accepts - timeout values in the calls in the same manner as gen_server. - The option to the compiler is "timeout".</p> - <p>Own Id: OTP-2487 <br></br> -</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Empty file generation problem is fixed. - When the IDL module definition did not contain - constant definitions, the generated stub file for that module - definition was empty. After checking the module body, - these files will not be generated anymore.</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>Changes in generated files.</p> - <p>Stub-files generated by the compiler had - prefix "OE_" and those used by Orber - had also a register/unregister function - called "OE_register"/"OE_unregister" and - a directive "OE_get_interface" passed - to the gen_server. - This made it difficult/irritating to use, - for example call to the register function - in Orber would appear as shown below:</p> - <list type="bulleted"> - <item> - <p>'OE_filename':'OE_register'().</p> - </item> - </list> - <p>This is changed by using the prefix "oe_" - instead for "OE_" for the above. - A registration call in Orber is now written:</p> - <list type="bulleted"> - <item> - <p>oe_filename:oe_register(). </p> - </item> - </list> - <p>Own Id: OTP-2440 <br></br> -</p> - </item> - </list> - </section> - </section> -</chapter> - diff --git a/lib/ic/vsn.mk b/lib/ic/vsn.mk index ec4bb7c3a6..e0fccf4889 100644 --- a/lib/ic/vsn.mk +++ b/lib/ic/vsn.mk @@ -1,6 +1,9 @@ IC_VSN = 4.2.24 -TICKETS = OTP-8307 +TICKETS = OTP-8307 \ + OTP-8353 \ + OTP-8354 \ + OTP-8355 TICKETS_4.2.23 = OTP-8201 diff --git a/lib/inets/Makefile b/lib/inets/Makefile index 9a54bfb8e2..ec05efa461 100644 --- a/lib/inets/Makefile +++ b/lib/inets/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1996-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1996-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # @@ -24,7 +24,7 @@ include $(ERL_TOP)/make/$(TARGET)/otp.mk # Macros # ---------------------------------------------------- -SUB_DIRECTORIES = src examples priv doc/src +SUB_DIRECTORIES = src examples priv doc/src include vsn.mk VSN = $(INETS_VSN) @@ -36,3 +36,11 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +info: + @echo "OS: $(OS)" + @echo "DOCB: $(DOCB)" + @echo "" + @echo "INETS_VSN: $(INETS_VSN)" + @echo "APP_VSN: $(APP_VSN)" + @echo "" + diff --git a/lib/inets/doc/src/Makefile b/lib/inets/doc/src/Makefile index 5b5a818db8..e4cb0c4e48 100644 --- a/lib/inets/doc/src/Makefile +++ b/lib/inets/doc/src/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1997-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1997-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # @@ -25,7 +25,7 @@ include $(ERL_TOP)/make/$(TARGET)/otp.mk # ---------------------------------------------------- include ../../vsn.mk VSN=$(INETS_VSN) -APPLICATION=inets + # ---------------------------------------------------- # Include dependency @@ -35,11 +35,13 @@ ifndef DOCSUPPORT include make.dep endif + # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + # ---------------------------------------------------- # Target Specs # ---------------------------------------------------- @@ -56,7 +58,7 @@ XML_REF3_FILES = \ inets.xml \ ftp.xml \ tftp.xml \ - http.xml\ + httpc.xml\ httpd.xml \ httpd_conf.xml \ httpd_socket.xml \ @@ -67,41 +69,29 @@ XML_REF3_FILES = \ mod_security.xml XML_PART_FILES = \ - part.xml \ - part_notes.xml \ - part_notes_history.xml -XML_HTML_FILES = \ - notes_history.xml + part.xml BOOK_FILES = book.xml -XML_FILES = $(BOOK_FILES) \ - $(XML_CHAPTER_FILES) \ - $(XML_PART_FILES) \ - $(XML_REF6_FILES) \ - $(XML_REF3_FILES) \ - $(XML_APPLICATION_FILES) +XML_FILES = \ + $(BOOK_FILES) \ + $(XML_CHAPTER_FILES) \ + $(XML_PART_FILES) \ + $(XML_REF6_FILES) \ + $(XML_REF3_FILES) \ + $(XML_APPLICATION_FILES) -GIF_FILES = \ - inets.gif \ - notes.gif \ - ref_man.gif \ - book.gif \ - warning.gif \ - note.gif +# GIF_FILES = inets.gif # ---------------------------------------------------- HTML_FILES = \ $(XML_APPLICATION_FILES:%.xml=$(HTMLDIR)/%.html) \ - $(XML_HTML_FILES:%.xml=$(HTMLDIR)/%.html) \ $(XML_PART_FILES:%.xml=$(HTMLDIR)/%.html) INFO_FILE = ../../info EXTRA_FILES = summary.html.src \ - $(DEFAULT_GIF_FILES) \ - $(DEFAULT_HTML_FILES) \ $(XML_REF3_FILES:%.xml=$(HTMLDIR)/%.html) \ $(XML_REF6_FILES:%.xml=$(HTMLDIR)/%.html) \ $(XML_CHAPTER_FILES:%.xml=$(HTMLDIR)/%.html) @@ -208,6 +198,7 @@ clean_html: clean_man: rm -f $(MAN3_FILES) + # ---------------------------------------------------- # Release Target # ---------------------------------------------------- @@ -216,11 +207,11 @@ include $(ERL_TOP)/make/otp_release_targets.mk ifdef DOCSUPPORT release_docs_spec: docs + @echo "release_docs_spec(docs) when DOCSUPPORT=$DOCSUPPORT" $(INSTALL_DIR) $(RELSYSDIR)/doc/pdf $(INSTALL_DATA) $(TOP_PDF_FILE) $(RELSYSDIR)/doc/pdf $(INSTALL_DIR) $(RELSYSDIR)/doc/html - $(INSTALL_DATA) $(HTMLDIR)/* \ - $(RELSYSDIR)/doc/html + $(INSTALL_DATA) $(HTMLDIR)/* $(RELSYSDIR)/doc/html $(INSTALL_DATA) $(INFO_FILE) $(RELSYSDIR) $(INSTALL_DIR) $(RELEASE_PATH)/man/man3 $(INSTALL_DATA) $(MAN3DIR)/* $(RELEASE_PATH)/man/man3 @@ -228,15 +219,18 @@ else ifeq ($(DOCTYPE),pdf) release_docs_spec: pdf + @echo "release_docs_spec(pdf)" $(INSTALL_DIR) $(RELEASE_PATH)/pdf $(INSTALL_DATA) $(TOP_PDF_FILE) $(RELEASE_PATH)/pdf else ifeq ($(DOCTYPE),ps) release_docs_spec: ps + @echo "release_docs_spec(ps)" $(INSTALL_DIR) $(RELEASE_PATH)/ps $(INSTALL_DATA) $(TOP_PS_FILE) $(RELEASE_PATH)/ps else release_docs_spec: docs + @echo "release_docs_spec(docs)" $(INSTALL_DIR) $(RELSYSDIR)/doc/html $(INSTALL_DATA) $(GIF_FILES) $(EXTRA_FILES) $(HTML_FILES) \ $(RELSYSDIR)/doc/html @@ -260,10 +254,6 @@ info: @echo "" @echo "TOP_HTML_FILES:\n$(TOP_HTML_FILES)" @echo "" - @echo "DEFAULT_GIF_FILES:\n$(DEFAULT_GIF_FILES)" - @echo "" - @echo "DEFAULT_HTML_FILES:\n$(DEFAULT_HTML_FILES)" - @echo "" @echo "XML_REF3_FILES:\n$(XML_REF3_FILES)" @echo "" @echo "XML_REF6_FILES:\n$(XML_REF6_FILES)" diff --git a/lib/inets/doc/src/ftp.xml b/lib/inets/doc/src/ftp.xml index 9ecca3dde1..25dfe716fc 100644 --- a/lib/inets/doc/src/ftp.xml +++ b/lib/inets/doc/src/ftp.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>ftp</title> @@ -534,12 +534,14 @@ <fsummary>Start an standalone ftp client.</fsummary> <type> <v>Host = string() | ip_address()</v> - <v>Opts = start_options() | open_options()</v> - <v>start_options() = [start_option()]</v> + <v>Opts = options()</v> + <v>options() = [option()]</v> + <v>option() = start_option() | open_option()</v> + <!-- <v>start_options() = [start_option()]</v> --> <v>start_option() = {verbose, verbose()} | {debug, debug()}</v> <v>verbose() = boolean() (defaults to false)</v> <v>debug() = disable | debug | trace (defaults to disable)</v> - <v>open_options() = [open_option()]</v> + <!-- <v>open_options() = [open_option()]</v> --> <v>open_option() = {ipfamily, ipfamily()} | {port, port()} | {mode, mode()} | {timeout, timeout()} | {progress, progress()}</v> <v>ipfamily() = inet | inet6 | inet6fb4 (defaults to inet)</v> <v>port() = integer() > 0 (defaults to 21)</v> @@ -845,7 +847,7 @@ <type> <v>Pid = pid()</v> <v>Command = string()</v> - <v>FTPLine = string() - Note the telnet end of line characters, from the ftp protocol definition, CRLF e.g. "\\r\ " has been removed.</v> + <v>FTPLine = string() - Note the telnet end of line characters, from the ftp protocol definition, CRLF e.g. "\\r\\n" has been removed.</v> </type> <desc> <p>Sends an arbitrary FTP command and returns verbatimly a list diff --git a/lib/inets/doc/src/http_server.xml b/lib/inets/doc/src/http_server.xml index 56317d647c..547617e2e3 100644 --- a/lib/inets/doc/src/http_server.xml +++ b/lib/inets/doc/src/http_server.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2004</year><year>2009</year> + <year>2004</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>HTTP server </title> @@ -82,7 +82,7 @@ <p>The server is configured using an erlang property list. For the available properties see - <seealso marker="inets:inets">httpd(3)</seealso> + <seealso marker="httpd">httpd(3)</seealso> For backwards compatibility also apache-like config files are supported. </p> @@ -246,7 +246,7 @@ every row contains the name of the group and the members of the group separated by a space, for example:</p> <pre> -\011 GroupName: Member1 Member2 .... MemberN +GroupName: Member1 Member2 .... MemberN </pre> </item> <item> @@ -278,8 +278,8 @@ and every row contains User Name and Password separated by a colon, for example:</p> <pre> -\011 UserName:Password -\011 UserName:Password +UserName:Password +UserName:Password </pre> </item> <item> @@ -299,11 +299,11 @@ the specified methods. If no request method is specified all request methods are verified against the restrictions.</p> <pre> -\011 <Limit POST GET HEAD> -\011 order allow deny -\011 require group group1 -\011 allow from 123.145.244.5 -\011 </Limit> +<Limit POST GET HEAD> + order allow deny + require group group1 + allow from 123.145.244.5 +</Limit> </pre> </item> <item> @@ -363,12 +363,10 @@ message-body, separated by a blank line. The message-header contains one or more header fields. The body may be empty. Example: </p> - <code type="none"> -"Content-Type:text/plain\ -Accept-Ranges:none\ -\ -some very -\011plain text" </code> + + <code>"Content-Type:text/plain\nAccept-Ranges:none\n\nsome very + plain text" </code> + <p>The server will interpret the cgi-headers and most of them will be transformed into HTTP headers and sent back to the client together with the body.</p> @@ -387,7 +385,7 @@ some very the extra overhead. An URL which calls an Erlang erl function has the following syntax (regular expression): </p> <code type="none"> -\011 http://your.server.org/***/Module[:/]Function(?QueryString|/PathInfo) +http://your.server.org/***/Module[:/]Function(?QueryString|/PathInfo) </code> <p>*** above depends on how the ErlScriptAlias config directive has been used</p> @@ -428,7 +426,7 @@ http://your.server.org/***/Mod:Func(Arg1,...,ArgN) http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[]))) </code> <p>which effectively will close down the Erlang node, - that is use the erl scheme instead, until this + therefor, use the erl scheme instead, until this security breach has been fixed.</p> <p>Today there are no good way of solving this problem and therefore Eval Scheme may be removed in future @@ -498,14 +496,14 @@ http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[ for parsed files, for example: </p> <pre> -\011text/x-server-parsed-html shtml shtm + text/x-server-parsed-html shtml shtm </pre> <p>This makes files ending with <c>.shtml</c> and <c>.shtm</c> into parsed files. Alternatively, if the performance hit is not a problem, <em>all</em> HTML pages can be marked as parsed: </p> <pre> -\011text/x-server-parsed-html html htm + text/x-server-parsed-html html htm </pre> </section> @@ -518,7 +516,7 @@ http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[ unparsed. Each directive has the following format: </p> <pre> -\011<!--#command tag1="value1" tag2="value2" --> + <!--#command tag1="value1" tag2="value2" --> </pre> <p>Each command takes different arguments, most only accept one tag at a time. Here is a breakdown of the commands and their @@ -612,7 +610,7 @@ http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[ <item> <p>The unescaped version of any search query the client sent, with all shell-special characters escaped with - <c>\\</c>.</p> + <c>\</c>.</p> </item> <tag><c>DATE_LOCAL</c></tag> <item> @@ -753,24 +751,28 @@ http://your.server.org/eval?httpd_example:print(atom_to_list(apply(erlang,halt,[ schema and the tables already is created. </p> <code> - -module(mnesia_test). - -export([start/0,load_data/0]). - -include("mod_auth.hrl"). - - first_start()-> - mnesia:create_schema([node()]), - mnesia:start(), - mnesia:create_table(httpd_user, - [{type,bag},{disc_copies,[node()]}, - {attributes,record_info(fields,httpd_user)}]), - mnesia:create_table(httpd_group, - [{type,bag},{disc_copies,[node()]}, - {attributes,record_info(fields,httpd_group)}]), - mnesia:wait_for_tables([httpd_user,httpd_group],60000). - - start()-> - mnesia:start(), - mnesia:wait_for_tables([httpd_user,httpd_group],60000). +-module(mnesia_test). +-export([start/0,load_data/0]). +-include("mod_auth.hrl"). + +first_start() -> + mnesia:create_schema([node()]), + mnesia:start(), + mnesia:create_table(httpd_user, + [{type, bag}, + {disc_copies, [node()]}, + {attributes, record_info(fields, + httpd_user)}]), + mnesia:create_table(httpd_group, + [{type, bag}, + {disc_copies, [node()]}, + {attributes, record_info(fields, + httpd_group)}]), + mnesia:wait_for_tables([httpd_user, httpd_group], 60000). + +start() -> + mnesia:start(), + mnesia:wait_for_tables([httpd_user, httpd_group], 60000). </code> <p>To create the Mnesia tables we use two records defined in diff --git a/lib/inets/doc/src/http.xml b/lib/inets/doc/src/httpc.xml index f6f8338113..e143ba2c1a 100644 --- a/lib/inets/doc/src/http.xml +++ b/lib/inets/doc/src/httpc.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2004</year><year>2009</year> + <year>2004</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,26 +13,26 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> - <title>http</title> + <title>httpc</title> <prepared>Ingela Anderton Andin</prepared> <responsible></responsible> <docno></docno> <date></date> <rev></rev> </header> - <module>http</module> + <module>httpc</module> <modulesummary>An HTTP/1.1 client </modulesummary> <description> - <p>This module provides the API to a HTTP/1.1 client according to - RFC 2616, caching is currently not supported.</p> + <p>This module provides the API to a HTTP/1.1 compatible client according + to RFC 2616, caching is currently not supported.</p> <note> <p>When starting the Inets application a manager process for the default profile will be started. The functions in this API @@ -64,6 +64,8 @@ request_id() = ref() profile() = atom() path() = string() representing a file path or directory path ip_address() = See inet(3) +socket_opt() = See the Options used by gen_tcp(3) and + ssl(3) connect(s) ]]></code> </section> @@ -130,38 +132,23 @@ ssl_options() = {verify, code()} | <p>The client can be stopped using inets:stop(httpc, Pid) or inets:stop(httpc, Profile).</p> - <marker id="cancel_request"></marker> + <marker id="request1"></marker> </section> <funcs> <func> - <name>cancel_request(RequestId) -> </name> - <name>cancel_request(RequestId, Profile) -> ok</name> - <fsummary>Cancels an asynchronous HTTP-request.</fsummary> - <type> - <v>RequestId = request_id() - A unique identifier as returned - by request/4</v> - <v>Profile = profile()</v> - </type> - <desc> - <p>Cancels an asynchronous HTTP-request. </p> - - <marker id="request1"></marker> - </desc> - </func> - - <func> <name>request(Url) -> </name> <name>request(Url, Profile) -> {ok, Result} | {error, Reason}</name> <fsummary>Sends a get HTTP-request</fsummary> <type> - <v>Url = url() </v> <v>Result = {status_line(), headers(), - body()} | {status_code(), body()} | request_id() </v> + <v>Url = url() </v> + <v>Result = {status_line(), headers(), body()} | + {status_code(), body()} | request_id() </v> <v>Profile = profile()</v> <v>Reason = term() </v> </type> <desc> - <p>Equivalent to http:request(get, {Url, []}, [], []).</p> + <p>Equivalent to httpc:request(get, {Url, []}, [], []).</p> <marker id="request2"></marker> </desc> @@ -177,23 +164,30 @@ ssl_options() = {verify, code()} | <v>Request = request()</v> <v>HTTPOptions = http_options()</v> <v>http_options() = [http_option()]</v> - <v>http_option() = {timeout, timeout()} | + <v>http_option() = {timeout, timeout()} | {connect_timeout, timeout()} | - {ssl, ssl_options()} | - {autoredirect, boolean()} | + {ssl, ssl_options()} | + {autoredirect, boolean()} | {proxy_auth, {userstring(), passwordstring()}} | - {version, http_version()} | - {relaxed, boolean()}</v> + {version, http_version()} | + {relaxed, boolean()}</v> <v>timeout() = integer() >= 0 | infinity</v> <v>Options = options()</v> <v>options() = [option()]</v> - <v>option() = {sync, boolean()} | - {stream, stream_to()} | - {body_format, body_format()} | - {full_result, boolean()} | - {headers_as_is, boolean()}</v> - <v>stream_to() = self | {self, once} | filename() </v> - <v>body_format() = string() | binary() </v> + <v>option() = {sync, boolean()} | + {stream, stream_to()} | + {body_format, body_format()} | + {full_result, boolean()} | + {headers_as_is, boolean() | + {socket_opts, socket_opts()} | + {receiver, receiver()}}</v> + <v>stream_to() = none | self | {self, once} | filename() </v> + <v>socket_opts() = [socket_opt()]</v> + <v>receiver() = pid() | function()/1 | {Module, Function, Args} </v> + <v>Module = atom() </v> + <v>Function = atom() </v> + <v>Args = list() </v> + <v>body_format() = string | binary </v> <v>Result = {status_line(), headers(), body()} | {status_code(), body()} | request_id() </v> <v>Profile = profile() </v> @@ -203,29 +197,25 @@ ssl_options() = {verify, code()} | <desc> <p>Sends a HTTP-request. The function can be both synchronous and asynchronous. In the later case the function will return - {ok, RequestId} and later on message(s) will be sent to the - calling process on the format: </p> -<pre> - {http, {RequestId, Result}} - {http, {RequestId, {error, Reason}}} - {http, {RequestId, stream_start, Headers} - {http, {RequestId, stream, BinBodyPart} - {http, {RequestId, stream_end, Headers} - {http, {RequestId, saved_to_file}}. -</pre> + {ok, RequestId} and later on the information will be delivered + to the <c>receiver</c> depending on that value. </p> <p>Http option (<c>http_option()</c>) details: </p> <taglist> <tag><c><![CDATA[timeout]]></c></tag> <item> <p>Timeout time for the request. </p> + <p>The clock start ticking as soon as the request has been + sent. </p> + <p>Time is in milliseconds. </p> <p>Defaults to <c>infinity</c>. </p> </item> <tag><c><![CDATA[connect_timeout]]></c></tag> <item> <p>Connection timeout time, used during the initial request, - when the client is connecting to the server. </p> + when the client is <em>connecting</em> to the server. </p> + <p>Time is in milliseconds. </p> <p>Defaults to the value of the <c>timeout</c> option. </p> </item> @@ -329,8 +319,92 @@ ssl_options() = {verify, code()} | <p>Defaults to <c>false</c>. </p> </item> + <tag><c><![CDATA[socket_opts]]></c></tag> + <item> + <p>Socket options to be used for this and subsequent + request(s). </p> + <p>Overrides any value set by the + <seealso marker="set_options">set_options</seealso> + function. </p> + <p>Note that the validity of the options are <em>not</em> + checked in any way. </p> + <p>Note that this may change the socket behaviour + (see <seealso marker="inet#setopts">inet:setopts/2</seealso>) + for an already existing, and therefor already connected + request handler. </p> + <p>By defaults the socket options set by the + <seealso marker="#set_options">set_options/1,2</seealso> + function is used when establishing connection. </p> + </item> + + <tag><c><![CDATA[receiver]]></c></tag> + <item> + <p>Defines how the client will deliver the result for a + asynchroneous request (<c>sync</c> has the value + <c>false</c>). </p> + + <taglist> + <tag><c><![CDATA[pid()]]></c></tag> + <item> + <p>Message(s) will be sent to this process in the format: </p> +<pre> +{http, ReplyInfo} +</pre> + </item> + + <tag><c><![CDATA[function/1]]></c></tag> + <item> + <p>Information will be delivered to the receiver via calls + to the provided fun: </p> +<pre> +Receiver(ReplyInfo) +</pre> + </item> + + <tag><c><![CDATA[{Module, Funcion, Args}]]></c></tag> + <item> + <p>Information will be delivered to the receiver via calls + to the callback function: </p> +<pre> +apply(Module, Function, [ReplyInfo | Args]) +</pre> + </item> + + </taglist> + <p>In all cases above, <c>ReplyInfo</c> has the following + structure: </p> + +<pre> +{RequestId, saved_to_file} +{RequestId, {error, Reason}} +{RequestId, Result} +{RequestId, stream_start, Headers} +{RequestId, stream_start, Headers, HandlerPid} +{RequestId, stream, BinBodyPart} +{RequestId, stream_end, Headers} +</pre> + + <p>Defaults to the <c>pid()</c> of the process calling the request + function (<c>self()</c>). </p> + </item> </taglist> + <marker id="cancel_request"></marker> + </desc> + </func> + + <func> + <name>cancel_request(RequestId) -> </name> + <name>cancel_request(RequestId, Profile) -> ok</name> + <fsummary>Cancels an asynchronous HTTP-request.</fsummary> + <type> + <v>RequestId = request_id() - A unique identifier as returned + by request/4</v> + <v>Profile = profile()</v> + </type> + <desc> + <p>Cancels an asynchronous HTTP-request. </p> + <marker id="set_options"></marker> </desc> </func> @@ -341,17 +415,30 @@ ssl_options() = {verify, code()} | <fsummary>Sets options to be used for subsequent requests.</fsummary> <type> <v>Options = [Option]</v> - <v>Option = {proxy, {Proxy, NoProxy}} | {max_sessions, MaxSessions} | - {max_keep_alive_length, MaxKeepAlive} | {keep_alive_timeout, KeepAliveTimeout} | - {max_pipeline_length, MaxPipeline} | {pipeline_timeout, PipelineTimeout} | - {cookies | CookieMode} | - {ipfamily, IpFamily} | {ip, IpAddress} | {port, Port} | - {verbose, VerboseMode} </v> + <v>Option = {proxy, {Proxy, NoProxy}} | + {max_sessions, MaxSessions} | + {max_keep_alive_length, MaxKeepAlive} | + {keep_alive_timeout, KeepAliveTimeout} | + {max_pipeline_length, MaxPipeline} | + {pipeline_timeout, PipelineTimeout} | + {cookies, CookieMode} | + {ipfamily, IpFamily} | + {ip, IpAddress} | + {port, Port} | + {socket_opts, socket_opts()} | + {verbose, VerboseMode} </v> <v>Proxy = {Hostname, Port}</v> <v>Hostname = string() </v> <d>ex: "localhost" or "foo.bar.se"</d> <v>Port = integer()</v> <d>ex: 8080 </d> + <v>socket_opts() = [socket_opt()]</v> + <d>The options are appended to the socket options used by the + client. </d> + <d>These are the default values when a new request handler + is started (for the initial connect). They are passed directly + to the underlying transport (gen_tcp or ssl) <em>without</em> + verification! </d> <v>NoProxy = [NoProxyDesc]</v> <v>NoProxyDesc = DomainDesc | HostName | IPDesc</v> <v>DomainDesc = "*.Domain"</v> @@ -439,12 +526,13 @@ ssl_options() = {verify, code()} | same behavior as active once for sockets.</p> <marker id="verify_cookie"></marker> + <marker id="store_cookie"></marker> </desc> </func> <func> - <name>verify_cookie(SetCookieHeaders, Url) -> </name> - <name>verify_cookie(SetCookieHeaders, Url, Profile) -> ok | {error, Reason}</name> + <name>store_cookie(SetCookieHeaders, Url) -> </name> + <name>store_cookie(SetCookieHeaders, Url, Profile) -> ok | {error, Reason}</name> <fsummary>Saves the cookies defined in SetCookieHeaders in the client profile's cookie database.</fsummary> <type> <v>SetCookieHeaders = headers() - where field = "set-cookie"</v> @@ -454,7 +542,7 @@ ssl_options() = {verify, code()} | <desc> <p>Saves the cookies defined in SetCookieHeaders in the client profile's cookie database. You need to - call this function if you set the option cookies to verify. + call this function if you set the option cookies to <c>verify</c>. If no profile is specified the default profile will be used. </p> @@ -476,6 +564,43 @@ ssl_options() = {verify, code()} | when making a request to Url using the profile Profile. If no profile is specified the default profile will be used. </p> + + <marker id="reset_cookies"></marker> + </desc> + </func> + + + <func> + <name>reset_cookies() -> void()</name> + <name>reset_cookies(Profile) -> void()</name> + <fsummary>Reset the cookie database.</fsummary> + <type> + <v>Profile = profile()</v> + </type> + <desc> + <p>Resets (clears) the cookie database for the specified Profile. + If no profile is specified the default profile will be used. + </p> + </desc> + </func> + + + <func> + <name>which_cookies() -> cookies()</name> + <name>which_cookies(Profile) -> cookies()</name> + <fsummary>Dumps out the entire cookie database.</fsummary> + <type> + <v>Profile = profile()</v> + <v>cookies() = [cooie_stores()]</v> + <v>cookie_stores() = {cookies, icookies()} | {session_cookies, icookies()}</v> + <v>icookies() = [icookie()]</v> + <v>cookie() = term()</v> + </type> + <desc> + <p>This function produces a list of the entire cookie database. + It is intended for debugging/testing purposes. + If no profile is specified the default profile will be used. + </p> </desc> </func> </funcs> @@ -483,6 +608,7 @@ ssl_options() = {verify, code()} | <section> <title>SEE ALSO</title> <p>RFC 2616, <seealso marker="inets">inets(3)</seealso>, + <seealso marker="kernel:gen_tcp">gen_tcp(3)</seealso>, <seealso marker="ssl:ssl">ssl(3)</seealso> </p> </section> diff --git a/lib/inets/doc/src/httpd.xml b/lib/inets/doc/src/httpd.xml index 60afcc6cfe..7dabeb33e9 100644 --- a/lib/inets/doc/src/httpd.xml +++ b/lib/inets/doc/src/httpd.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>httpd</title> @@ -93,7 +93,7 @@ followed by the value followed by a new line. Ex: <code> - {server_root, "/urs/local/www"} -> ServerRoot /usr/local/www +{server_root, "/urs/local/www"} -> ServerRoot /usr/local/www </code> <p>With a few exceptions, that are documented @@ -103,9 +103,9 @@ as:</p> <pre> <![CDATA[ - <Directory Dir> - <Properties handled as described above> - </Directory> +<Directory Dir> + <Properties handled as described above> +</Directory> ]]> </pre> </item> @@ -239,9 +239,9 @@ as an Apache like file as well as directly in the property list. Such a file may look like:</p> <pre> - \011 # MIME type\011\011\011Extension - \011 text/html\011\011\011html htm - \011 text/plain\011\011\011asc txt +# MIME type Extension +text/html html htm +text/plain asc txt </pre> <p>Defaults to [{"html","text/html"},{"htm","text/html"}]</p> @@ -869,19 +869,19 @@ bytes ModData = #mod{} -record(mod, { -\011\011data = [], -\011\011socket_type = ip_comm, -\011\011socket, -\011\011config_db, -\011\011method, -\011\011absolute_uri, -\011\011request_uri, -\011\011http_version, -\011\011request_line, -\011\011parsed_header = [], -\011\011entity_body, -\011\011connection -\011 }). + data = [], + socket_type = ip_comm, + socket, + config_db, + method, + absolute_uri, + request_uri, + http_version, + request_line, + parsed_header = [], + entity_body, + connection + }). </code> <p>The fields of the <c>mod</c> record has the following meaning: </p> diff --git a/lib/inets/doc/src/httpd_util.xml b/lib/inets/doc/src/httpd_util.xml index 1566ee29d1..642e5213b0 100644 --- a/lib/inets/doc/src/httpd_util.xml +++ b/lib/inets/doc/src/httpd_util.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>httpd_util</title> @@ -218,7 +218,8 @@ <marker id="lookup_mime"></marker> <p><c>lookup_mime</c> returns the mime type associated with a specific file suffix as specified in the <c>mime.types</c> - file (located in the <path unix="$SERVER_ROOT/conf/mime.types" windows="%SERVER_ROOT%\\\\conf\\\\mime.types">config directory</path>).</p> + file (located in the + <path unix="$SERVER_ROOT/conf/mime.types" windows="%SERVER_ROOT%\conf\mime.types">config directory</path>).</p> <marker id="lookup_mime_default"></marker> </desc> @@ -239,7 +240,7 @@ <p><c>lookup_mime_default</c> returns the mime type associated with a specific file suffix as specified in the <c>mime.types</c> file (located in the - <path unix="$SERVER_ROOT/conf/mime.types" windows="%SERVER_ROOT%\\\\conf\\\\mime.types">config directory</path>). + <path unix="$SERVER_ROOT/conf/mime.types" windows="%SERVER_ROOT%\conf\mime.types">config directory</path>). If no appropriate association can be found the value of DefaultType is returned.</p> diff --git a/lib/inets/doc/src/inets.xml b/lib/inets/doc/src/inets.xml index e5fe32f32f..81dfe7e944 100644 --- a/lib/inets/doc/src/inets.xml +++ b/lib/inets/doc/src/inets.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2007</year><year>2009</year> + <year>2007</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>inets</title> @@ -129,7 +129,7 @@ </type> <desc> <p>Dynamically starts an inets service after the inets - application has been started.\011</p> + application has been started. </p> <note> <p>Dynamically started services will not be handled by application takeover and failover behavior when inets is diff --git a/lib/inets/doc/src/make.dep b/lib/inets/doc/src/make.dep index d96c6dc5b8..8deb7e7a5a 100644 --- a/lib/inets/doc/src/make.dep +++ b/lib/inets/doc/src/make.dep @@ -1,3 +1,23 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1999-2010. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# + # ---------------------------------------------------- # >>>> Do not edit this file <<<< # This file was automaticly generated by @@ -9,7 +29,7 @@ # TeX files that the DVI file depend on # ---------------------------------------------------- -book.dvi: book.tex ftp.tex ftp_client.tex http.tex http_client.tex \ +book.dvi: book.tex ftp.tex ftp_client.tex httpc.tex http_client.tex \ http_server.tex httpd.tex httpd_conf.tex httpd_socket.tex \ httpd_util.tex inets.tex inets_services.tex \ mod_alias.tex mod_auth.tex mod_esi.tex mod_security.tex \ diff --git a/lib/inets/doc/src/mod_esi.xml b/lib/inets/doc/src/mod_esi.xml index d4541a1d15..6bad77dc0a 100644 --- a/lib/inets/doc/src/mod_esi.xml +++ b/lib/inets/doc/src/mod_esi.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>mod_esi</title> @@ -94,7 +94,7 @@ that the first chunk of data sent to the client must at least contain all HTTP header fields that the response will generate. If the first chunk not contains - <em>End of HTTP header</em> that is <c>"\\r\ \\r\ "</c> + <em>End of HTTP header</em> that is <c>"\r\n\r\n"</c> the server will assume that no HTTP header fields will be generated.</p> </desc> diff --git a/lib/inets/doc/src/notes.xml b/lib/inets/doc/src/notes.xml index 687e127d0b..e95c8d6e97 100644 --- a/lib/inets/doc/src/notes.xml +++ b/lib/inets/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2002</year><year>2009</year> + <year>2002</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Inets Release Notes</title> @@ -32,21 +32,108 @@ <file>notes.xml</file> </header> - <section><title>Inets 5.2.0.1</title> + <section><title>Inets 5.3</title> <section><title>Improvements and New Features</title> - <p>-</p> <!-- + <p>-</p> +--> + <list> <item> - <p>The documentation is now built with open source tools - (<em>xsltproc</em> and <em>fop</em>) that exists on most - platforms. One visible change is that the frames are removed.</p> - <p>Own Id: OTP-8249</p> + <p>[httpc] - Allow users to pass socket options to the transport + module when making requests. </p> + <p>See the <c>socket_opts</c> option in the + <seealso marker="httpc#request2">request/4</seealso> or + <seealso marker="httpc#set_options">set_options/1,2</seealso> + for more info, </p> + <p>Own Id: OTP-8352</p> </item> - </list> + <item> + <p>[httpc] Fix bug crafting Host header when port is not 80. </p> + <p>The host header should include the port number as well as the + host name when making a request to a server listening on a port + other than the HTTP default of 80. Currently, only the host + name is included. This is important to make the http client + more compliant with the HTTP specification. </p> + <p>Own Id: OTP-8371</p> + <p>Kelly McLaughlin</p> + </item> + + <item> + <p>[httpc|httpd] http_chunk data handling/passing improvement. </p> + <p>This is a modification to the http_chunk module to forward any + full chunk received, regardless of whether the size field for the + following chunk has been received yet. This allows http_chunk to + be used in situations where a long term HTTP connection is used to + send periodic status updates as individual chunks. Previously a + given chunk would not be forwarded to the client process until the + size for the next chunk had been read which rendered the module + difficult to use for the scenario described. </p> + <p>Bernard Duggan</p> + <p>Own Id: OTP-8351</p> + </item> + + <item> + <p>Include the inets test suite in the release of the + application. </p> + <p>Own Id: OTP-8349</p> + </item> + + <item> + <p>[httpc] - It is now possible to configure the client to + deliver an async reply to more receivers then the calling + process. </p> + <p>See the + <seealso marker="httpc#request2">receiver</seealso> + option for more info, </p> + <p>Own Id: OTP-8106</p> + </item> + + <item> + <p>[httpd] - Methods "PUT" and "DELETE" now allowed. </p> + <p>[email protected]</p> + <p>Own Id: OTP-8103</p> + </item> + + <item> + <p>[httpc] Several more or less critical fixes:</p> + <p> + <list type="bulleted"> + <item> + <p>Initial call between the httpc manager and request + handler was synchronous. </p> + <p>When the manager starts a new request handler, + this is no longer a synchronous operation. Previously, + the new request handler made the connection to the + server and issuing of the first request (the reason + for starting it) in the gen_server init function. + If the connection for some reason "took some time", + the manager hanged, leaving all other activities by + that manager also hanging. </p> + </item> +<!-- + <item> + <p>Copying of data between processes</p> + <p>TBD</p> + </item> + <item> + <p>Reading of requests</p> + <p>TBD</p> + </item> --> + </list> + </p> + <p>As a side-effect of these changes, some modules was also + renamed, and a new api module, + <seealso marker="httpc">httpc</seealso>, has been introduced + (the old module <c>http</c> is <em>not</em> removed, but is + now just wrapper for <c>httpc</c>). </p> + <p>Own Id: OTP-8016</p> + <p>*** POTENTIAL INCOMPATIBILITY ***</p> + </item> + </list> </section> <section><title>Fixed Bugs and Malfunctions</title> @@ -57,13 +144,32 @@ <list> <item> - <p>Fixing minor Dialyzer and copyright problem.</p> + <p>[httpd] The server did not fully support the documented module + callback api. Specifically, the load function should be able to + return the atom <c>ok</c>, but this was not accepted. </p> + <p>Own Id: OTP-8359</p> </item> + <item> + <p>Fixing various documentation-related bugs (bad quotes).</p> + <p>Own Id: OTP-8327</p> + </item> + + <item> + <p>Fixing minor Dialyzer and copyright problem(s). </p> + <p>Own Id: OTP-8315</p> + </item> + + <item> + <p>[httpc] - Added basic sanity check of option value + combinations.</p> + <p>[email protected]</p> + <p>Own Id: OTP-8056</p> + </item> </list> </section> - </section> <!-- 5.2.0.1 --> + </section> <!-- 5.3 --> <section><title>Inets 5.2</title> @@ -173,7 +279,7 @@ <p>Timeout out requests are retried. </p> </item> </list> - <p>Jean-S�bastien P�dron</p> + <p>Jean-Sébastien Pédron</p> <p>Own Id: OTP-8248</p> </item> diff --git a/lib/inets/doc/src/notes_history.xml b/lib/inets/doc/src/notes_history.xml index 53375c9aa7..6480bad758 100644 --- a/lib/inets/doc/src/notes_history.xml +++ b/lib/inets/doc/src/notes_history.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2004</year><year>2009</year> + <year>2004</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Inets Release Notes History</title> @@ -385,8 +385,7 @@ </item> <item> <p>[httpc, httpd] - In some cases if a body contained the - sequence "\\r\ - 0" and was chunked encoded this sequence + sequence "\r\n0" and was chunked encoded this sequence was incorrectly interpreted as the last chunk.</p> <p>Own Id: OTP-6264 Aux Id: OTP-6005 </p> </item> @@ -968,8 +967,7 @@ design was changed to use gen_tcp active once semantics. The API is not effected except for the function ftp:quote/2 which now returns a list of strings (ftp - result lines) where the line endings "\\r\ - " has been + result lines) where the line endings "\r\n" has been removed. This was the original intention for the return value of ftp:quote/2 but it was non trivial to make a good such solution with the old design and a compromise @@ -1055,13 +1053,11 @@ <p>Own Id: OTP-5551 Aux Id: seq9854 </p> </item> <item> - <p>The HTTP server now handles "GET /\\r\ - \\r\ - " as well as - "GET / \\r\ - \\r\ - ". According to the RFC the whitespace is - not needed.</p> + <p>The HTTP server now handles + "GET /\r\n\r\n" + as well as + "GET / \r\n\r\n". + According to the RFC the whitespace is not needed.</p> <p>Own Id: OTP-5552 Aux Id: seq8426 </p> </item> </list> diff --git a/lib/inets/doc/src/ref_man.xml b/lib/inets/doc/src/ref_man.xml index 7ec2c041c8..45d5dfcd0e 100644 --- a/lib/inets/doc/src/ref_man.xml +++ b/lib/inets/doc/src/ref_man.xml @@ -4,7 +4,7 @@ <application xmlns:xi="http://www.w3.org/2001/XInclude"> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Inets Reference Manual</title> @@ -36,7 +36,7 @@ <xi:include href="inets.xml"/> <xi:include href="ftp.xml"/> <xi:include href="tftp.xml"/> - <xi:include href="http.xml"/> + <xi:include href="httpc.xml"/> <xi:include href="httpd.xml"/> <xi:include href="httpd_conf.xml"/> <xi:include href="httpd_socket.xml"/> diff --git a/lib/inets/src/ftp/Makefile b/lib/inets/src/ftp/Makefile index 70d51115e6..0c15277a18 100644 --- a/lib/inets/src/ftp/Makefile +++ b/lib/inets/src/ftp/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # @@ -32,7 +32,8 @@ VSN = $(INETS_VSN) # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + # ---------------------------------------------------- # Target Specs @@ -49,15 +50,17 @@ ERL_FILES = $(MODULES:%=%.erl) TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' ifeq ($(FTP_DEBUG),true) INETS_FLAGS += -Dftp_debug endif + # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- @@ -94,6 +97,7 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" diff --git a/lib/inets/src/http_client/Makefile b/lib/inets/src/http_client/Makefile index 23170f439f..628c91421f 100644 --- a/lib/inets/src/http_client/Makefile +++ b/lib/inets/src/http_client/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # @@ -22,6 +22,7 @@ include $(ERL_TOP)/make/target.mk EBIN = ../../ebin include $(ERL_TOP)/make/$(TARGET)/otp.mk + # ---------------------------------------------------- # Application version # ---------------------------------------------------- @@ -29,17 +30,20 @@ include ../../vsn.mk VSN = $(INETS_VSN) + # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + # ---------------------------------------------------- # Target Specs # ---------------------------------------------------- MODULES = \ http \ - http_cookie \ + httpc \ + httpc_cookie \ httpc_handler \ httpc_manager \ httpc_sup \ @@ -55,20 +59,24 @@ ERL_FILES = $(MODULES:%=%.erl) TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' + # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- INETS_ERL_FLAGS += -I ../http_lib -I ../inets_app -pa ../../ebin -ERL_COMPILE_FLAGS += $(INETS_ERL_FLAGS)\ +ERL_COMPILE_FLAGS += $(INETS_ERL_FLAGS) \ $(INETS_FLAGS) \ +'{parse_transform,sys_pre_attributes}' \ +'{attribute,insert,app_vsn,$(APP_VSN)}' + + # ---------------------------------------------------- # Targets # ---------------------------------------------------- @@ -94,6 +102,7 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" diff --git a/lib/inets/src/http_client/http.erl b/lib/inets/src/http_client/http.erl index ce5d7723f0..7e1e90b50e 100644 --- a/lib/inets/src/http_client/http.erl +++ b/lib/inets/src/http_client/http.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2002-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2002-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -24,7 +24,6 @@ %%% - RFC 2818 HTTP Over TLS -module(http). --behaviour(inets_service). %% API -export([request/1, request/2, request/4, request/5, @@ -35,15 +34,6 @@ cookie_header/2, stream_next/1, default_profile/0]). -%% Behavior callbacks --export([start_standalone/1, start_service/1, - stop_service/1, services/0, service_info/1]). - --include("http_internal.hrl"). --include("httpc_internal.hrl"). - --define(DEFAULT_PROFILE, default). - %%%========================================================================= %%% API @@ -51,751 +41,75 @@ %%-------------------------------------------------------------------------- %% request(Url [, Profile]) -> -%% {ok, {StatusLine, Headers, Body}} | {error,Reason} -%% -%% Url - string() -%% Description: Calls request/4 with default values. +%% request(Method, Request, HTTPOptions, Options [, Profile]) %%-------------------------------------------------------------------------- -request(Url) -> - request(Url, default_profile()). - -request(Url, Profile) -> - request(get, {Url, []}, [], [], Profile). - - -%%-------------------------------------------------------------------------- -%% request(Method, Request, HTTPOptions, Options [, Profile]) -> -%% {ok, {StatusLine, Headers, Body}} | {ok, {Status, Body}} | -%% {ok, RequestId} | {error,Reason} | {ok, {saved_as, FilePath} -%% -%% Method - atom() = head | get | put | post | trace | options| delete -%% Request - {Url, Headers} | {Url, Headers, ContentType, Body} -%% Url - string() -%% HTTPOptions - [HttpOption] -%% HTTPOption - {timeout, Time} | {connect_timeout, Time} | -%% {ssl, SSLOptions} | {proxy_auth, {User, Password}} -%% Ssloptions = [SSLOption] -%% SSLOption = {verify, code()} | {depth, depth()} | {certfile, path()} | -%% {keyfile, path()} | {password, string()} | {cacertfile, path()} | -%% {ciphers, string()} -%% Options - [Option] -%% Option - {sync, Boolean} | {body_format, BodyFormat} | -%% {full_result, Boolean} | {stream, To} | -%% {headers_as_is, Boolean} -%% StatusLine = {HTTPVersion, StatusCode, ReasonPhrase}</v> -%% HTTPVersion = string() -%% StatusCode = integer() -%% ReasonPhrase = string() -%% Headers = [Header] -%% Header = {Field, Value} -%% Field = string() -%% Value = string() -%% Body = string() | binary() - HTLM-code -%% -%% Description: Sends a HTTP-request. The function can be both -%% syncronus and asynchronous in the later case the function will -%% return {ok, RequestId} and later on a message will be sent to the -%% calling process on the format {http, {RequestId, {StatusLine, -%% Headers, Body}}} or {http, {RequestId, {error, Reason}}} -%%-------------------------------------------------------------------------- +request(Url) -> httpc:request(Url). +request(Url, Profile) -> httpc:request(Url, Profile). request(Method, Request, HttpOptions, Options) -> - request(Method, Request, HttpOptions, Options, default_profile()). + httpc:request(Method, Request, HttpOptions, Options). +request(Method, Request, HttpOptions, Options, Profile) -> + httpc:request(Method, Request, HttpOptions, Options, Profile). -request(Method, {Url, Headers}, HTTPOptions, Options, Profile) - when (Method =:= options) orelse - (Method =:= get) orelse - (Method =:= head) orelse - (Method =:= delete) orelse - (Method =:= trace) -> - case http_uri:parse(Url) of - {error, Reason} -> - {error, Reason}; - ParsedUrl -> - handle_request(Method, Url, ParsedUrl, Headers, [], [], - HTTPOptions, Options, Profile) - end; - -request(Method, {Url,Headers,ContentType,Body}, HTTPOptions, Options, Profile) - when (Method =:= post) orelse (Method =:= put) -> - case http_uri:parse(Url) of - {error, Reason} -> - {error, Reason}; - ParsedUrl -> - handle_request(Method, Url, - ParsedUrl, Headers, ContentType, Body, - HTTPOptions, Options, Profile) - end. %%-------------------------------------------------------------------------- -%% request(RequestId) -> ok -%% RequestId - As returned by request/4 -%% -%% Description: Cancels a HTTP-request. +%% cancel_request(RequestId [, Profile]) %%------------------------------------------------------------------------- -cancel_request(RequestId) -> - cancel_request(RequestId, default_profile()). +cancel_request(RequestId) -> + httpc:cancel_request(RequestId). cancel_request(RequestId, Profile) -> - ok = httpc_manager:cancel_request(RequestId, profile_name(Profile)), - receive - %% If the request was allready fullfilled throw away the - %% answer as the request has been canceled. - {http, {RequestId, _}} -> - ok - after 0 -> - ok - end. - - -set_option(Key, Value) -> - set_option(Key, Value, default_profile()). - -set_option(Key, Value, Profile) -> - set_options([{Key, Value}], Profile). + httpc:cancel_request(RequestId, Profile). %%-------------------------------------------------------------------------- -%% set_options(Options [, Profile]) -> ok | {error, Reason} -%% Options - [Option] -%% Profile - atom() -%% Option - {proxy, {Proxy, NoProxy}} | {max_sessions, MaxSessions} | -%% {max_pipeline_length, MaxPipeline} | -%% {pipeline_timeout, PipelineTimeout} | {cookies, CookieMode} | -%% {ipfamily, IpFamily} -%% Proxy - {Host, Port} -%% NoProxy - [Domain | HostName | IPAddress] -%% MaxSessions, MaxPipeline, PipelineTimeout = integer() -%% CookieMode - enabled | disabled | verify -%% IpFamily - inet | inet6 | inet6fb4 -%% Description: Informs the httpc_manager of the new settings. +%% set_options(Options [, Profile]) +%% set_option(Key, Value [, Profile]) %%------------------------------------------------------------------------- + set_options(Options) -> - set_options(Options, default_profile()). + httpc:set_options(Options). set_options(Options, Profile) -> - case validate_options(Options) of - {ok, Opts} -> - try httpc_manager:set_options(Opts, profile_name(Profile)) of - Result -> - Result - catch - exit:{noproc, _} -> - {error, inets_not_started} - end; - {error, Reason} -> - {error, Reason} - end. + httpc:set_options(Options, Profile). + +set_option(Key, Value) -> + httpc:set_option(Key, Value). +set_option(Key, Value, Profile) -> + httpc:set_option(Key, Value, Profile). %%-------------------------------------------------------------------------- -%% verify_cookies(SetCookieHeaders, Url [, Profile]) -> ok | {error, reason} -%% -%% -%% Description: Store the cookies from <SetCookieHeaders> -%% in the cookie database -%% for the profile <Profile>. This function shall be used when the option -%% cookie is set to verify. +%% verify_cookies(SetCookieHeaders, Url [, Profile]) %%------------------------------------------------------------------------- -verify_cookies(SetCookieHeaders, Url) -> - verify_cookies(SetCookieHeaders, Url, default_profile()). +verify_cookies(SetCookieHeaders, Url) -> + httpc:store_cookies(SetCookieHeaders, Url). verify_cookies(SetCookieHeaders, Url, Profile) -> - {_, _, Host, Port, Path, _} = http_uri:parse(Url), - ProfileName = profile_name(Profile), - Cookies = http_cookie:cookies(SetCookieHeaders, Path, Host), - try httpc_manager:store_cookies(Cookies, {Host, Port}, ProfileName) of - _ -> - ok - catch - exit:{noproc, _} -> - {error, {not_started, Profile}} - end. + httpc:store_cookies(SetCookieHeaders, Url, Profile). + %%-------------------------------------------------------------------------- -%% cookie_header(Url [, Profile]) -> Header | {error, Reason} -%% -%% Description: Returns the cookie header that would be sent when making -%% a request to <Url>. +%% cookie_header(Url [, Profile]) %%------------------------------------------------------------------------- -cookie_header(Url) -> - cookie_header(Url, default_profile()). +cookie_header(Url) -> + httpc:cookie_header(Url). cookie_header(Url, Profile) -> - try httpc_manager:cookies(Url, profile_name(Profile)) of - Header -> - Header - catch - exit:{noproc, _} -> - {error, {not_started, Profile}} - end. - - -stream_next(Pid) -> - httpc_handler:stream_next(Pid). - -%%%======================================================================== -%%% Behavior callbacks -%%%======================================================================== -start_standalone(PropList) -> - case proplists:get_value(profile, PropList) of - undefined -> - {error, no_profile}; - Profile -> - Dir = - proplists:get_value(data_dir, PropList, only_session_cookies), - httpc_manager:start_link({Profile, Dir}, stand_alone) - end. - -start_service(Config) -> - httpc_profile_sup:start_child(Config). - -stop_service(Profile) when is_atom(Profile) -> - httpc_profile_sup:stop_child(Profile); -stop_service(Pid) when is_pid(Pid) -> - case service_info(Pid) of - {ok, [{profile, Profile}]} -> - stop_service(Profile); - Error -> - Error - end. - -services() -> - [{httpc, Pid} || {_, Pid, _, _} <- - supervisor:which_children(httpc_profile_sup)]. -service_info(Pid) -> - try [{ChildName, ChildPid} || - {ChildName, ChildPid, _, _} <- - supervisor:which_children(httpc_profile_sup)] of - Children -> - child_name2info(child_name(Pid, Children)) - catch - exit:{noproc, _} -> - {error, service_not_available} - end. - - -%%%======================================================================== -%%% Internal functions -%%%======================================================================== -handle_request(Method, Url, - {Scheme, UserInfo, Host, Port, Path, Query}, - Headers, ContentType, Body, - HTTPOptions0, Options, Profile) -> - - HTTPOptions = http_options(HTTPOptions0), - Sync = proplists:get_value(sync, Options, true), - NewHeaders = lists:map(fun({Key, Val}) -> - {http_util:to_lower(Key), Val} end, - Headers), - Stream = proplists:get_value(stream, Options, none), - case {Sync, Stream} of - {true, self} -> - {error, streaming_error}; - _ -> - RecordHeaders = header_record(NewHeaders, - #http_request_h{}, - Host, - HTTPOptions#http_options.version), - Request = #request{from = self(), - scheme = Scheme, - address = {Host,Port}, - path = Path, - pquery = Query, - method = Method, - headers = RecordHeaders, - content = {ContentType,Body}, - settings = HTTPOptions, - abs_uri = Url, - userinfo = UserInfo, - stream = Stream, - headers_as_is = headers_as_is(Headers, Options)}, - try httpc_manager:request(Request, profile_name(Profile)) of - {ok, RequestId} -> - handle_answer(RequestId, Sync, Options); - {error, Reason} -> - {error, Reason} - catch - error:{noproc, _} -> - {error, {not_started, Profile}} - end - end. - - -handle_answer(RequestId, false, _) -> - {ok, RequestId}; -handle_answer(RequestId, true, Options) -> - receive - {http, {RequestId, saved_to_file}} -> - {ok, saved_to_file}; - {http, {RequestId, Result = {_,_,_}}} -> - return_answer(Options, Result); - {http, {RequestId, {error, Reason}}} -> - {error, Reason} - end. - -return_answer(Options, {{"HTTP/0.9",_,_}, _, BinBody}) -> - Body = format_body(BinBody, Options), - {ok, Body}; - -return_answer(Options, {StatusLine, Headers, BinBody}) -> - - Body = format_body(BinBody, Options), - - case proplists:get_value(full_result, Options, true) of - true -> - {ok, {StatusLine, Headers, Body}}; - false -> - {_, Status, _} = StatusLine, - {ok, {Status, Body}} - end. - -format_body(BinBody, Options) -> - case proplists:get_value(body_format, Options, string) of - string -> - binary_to_list(BinBody); - _ -> - BinBody - end. + httpc:cookie_header(Url, Profile). -%% This options is a workaround for http servers that do not follow the -%% http standard and have case sensative header parsing. Should only be -%% used if there is no other way to communicate with the server or for -%% testing purpose. -headers_as_is(Headers, Options) -> - case proplists:get_value(headers_as_is, Options, false) of - false -> - []; - true -> - Headers - end. +%%-------------------------------------------------------------------------- +%% stream_next(Pid) +%%------------------------------------------------------------------------- -http_options(HttpOptions) -> - HttpOptionsDefault = http_options_default(), - http_options(HttpOptionsDefault, HttpOptions, #http_options{}). - -http_options([], [], Acc) -> - Acc; -http_options([], HttpOptions, Acc) -> - Fun = fun(BadOption) -> - Report = io_lib:format("Invalid option ~p ignored ~n", - [BadOption]), - error_logger:info_report(Report) - end, - lists:foreach(Fun, HttpOptions), - Acc; -http_options([{Tag, Default, Idx, Post} | Defaults], HttpOptions, Acc) -> - case lists:keysearch(Tag, 1, HttpOptions) of - {value, {Tag, Val0}} -> - case Post(Val0) of - {ok, Val} -> - Acc2 = setelement(Idx, Acc, Val), - HttpOptions2 = lists:keydelete(Tag, 1, HttpOptions), - http_options(Defaults, HttpOptions2, Acc2); - error -> - Report = io_lib:format("Invalid option ~p:~p ignored ~n", - [Tag, Val0]), - error_logger:info_report(Report), - HttpOptions2 = lists:keydelete(Tag, 1, HttpOptions), - http_options(Defaults, HttpOptions2, Acc) - end; - false -> - DefaultVal = - case Default of - {value, Val} -> - Val; - {field, DefaultIdx} -> - element(DefaultIdx, Acc) - end, - Acc2 = setelement(Idx, Acc, DefaultVal), - http_options(Defaults, HttpOptions, Acc2) - end. - -http_options_default() -> - VersionPost = - fun(Value) when is_atom(Value) -> - {ok, http_util:to_upper(atom_to_list(Value))}; - (Value) when is_list(Value) -> - {ok, http_util:to_upper(Value)}; - (_) -> - error - end, - TimeoutPost = fun(Value) when is_integer(Value) andalso (Value >= 0) -> - {ok, Value}; - (infinity = Value) -> - {ok, Value}; - (_) -> - error - end, - AutoRedirectPost = fun(Value) when (Value =:= true) orelse - (Value =:= false) -> - {ok, Value}; - (_) -> - error - end, - SslPost = fun(Value) when is_list(Value) -> - {ok, Value}; - (_) -> - error - end, - ProxyAuthPost = fun({User, Passwd} = Value) when is_list(User) andalso - is_list(Passwd) -> - {ok, Value}; - (_) -> - error - end, - RelaxedPost = fun(Value) when (Value =:= true) orelse - (Value =:= false) -> - {ok, Value}; - (_) -> - error - end, - ConnTimeoutPost = - fun(Value) when is_integer(Value) andalso (Value >= 0) -> - {ok, Value}; - (infinity = Value) -> - {ok, Value}; - (_) -> - error - end, - [ - {version, {value, "HTTP/1.1"}, #http_options.version, VersionPost}, - {timeout, {value, ?HTTP_REQUEST_TIMEOUT}, #http_options.timeout, TimeoutPost}, - {autoredirect, {value, true}, #http_options.autoredirect, AutoRedirectPost}, - {ssl, {value, []}, #http_options.ssl, SslPost}, - {proxy_auth, {value, undefined}, #http_options.proxy_auth, ProxyAuthPost}, - {relaxed, {value, false}, #http_options.relaxed, RelaxedPost}, - %% this field has to be *after* the timeout field (as that field is used for the default value) - {connect_timeout, {field, #http_options.timeout}, #http_options.connect_timeout, ConnTimeoutPost} - ]. - -validate_options(Options) -> - (catch validate_options(Options, [])). - -validate_options([], ValidateOptions) -> - {ok, lists:reverse(ValidateOptions)}; - -validate_options([{proxy, Proxy} = Opt| Tail], Acc) -> - validate_proxy(Proxy), - validate_options(Tail, [Opt | Acc]); - -validate_options([{max_sessions, Value} = Opt| Tail], Acc) -> - validate_max_sessions(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{keep_alive_timeout, Value} = Opt| Tail], Acc) -> - validate_keep_alive_timeout(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{max_keep_alive_length, Value} = Opt| Tail], Acc) -> - validate_max_keep_alive_length(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{pipeline_timeout, Value} = Opt| Tail], Acc) -> - validate_pipeline_timeout(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{max_pipeline_length, Value} = Opt| Tail], Acc) -> - validate_max_pipeline_length(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{cookies, Value} = Opt| Tail], Acc) -> - validate_cookies(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{ipfamily, Value} = Opt| Tail], Acc) -> - validate_ipfamily(Value), - validate_options(Tail, [Opt | Acc]); - -%% For backward compatibillity -validate_options([{ipv6, Value}| Tail], Acc) -> - NewValue = validate_ipv6(Value), - Opt = {ipfamily, NewValue}, - validate_options(Tail, [Opt | Acc]); - -validate_options([{ip, Value} = Opt| Tail], Acc) -> - validate_ip(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{port, Value} = Opt| Tail], Acc) -> - validate_port(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{verbose, Value} = Opt| Tail], Acc) -> - validate_verbose(Value), - validate_options(Tail, [Opt | Acc]); - -validate_options([{_, _} = Opt| _], _Acc) -> - {error, {not_an_option, Opt}}. - - -validate_proxy({{ProxyHost, ProxyPort}, NoProxy} = Proxy) - when is_list(ProxyHost) andalso - is_integer(ProxyPort) andalso - is_list(NoProxy) -> - Proxy; -validate_proxy(BadProxy) -> - bad_option(proxy, BadProxy). - -validate_max_sessions(Value) when is_integer(Value) andalso (Value >= 0) -> - Value; -validate_max_sessions(BadValue) -> - bad_option(max_sessions, BadValue). - -validate_keep_alive_timeout(Value) when is_integer(Value) andalso (Value >= 0) -> - Value; -validate_keep_alive_timeout(infinity = Value) -> - Value; -validate_keep_alive_timeout(BadValue) -> - bad_option(keep_alive_timeout, BadValue). - -validate_max_keep_alive_length(Value) when is_integer(Value) andalso (Value >= 0) -> - Value; -validate_max_keep_alive_length(BadValue) -> - bad_option(max_keep_alive_length, BadValue). - -validate_pipeline_timeout(Value) when is_integer(Value) -> - Value; -validate_pipeline_timeout(infinity = Value) -> - Value; -validate_pipeline_timeout(BadValue) -> - bad_option(pipeline_timeout, BadValue). - -validate_max_pipeline_length(Value) when is_integer(Value) -> - Value; -validate_max_pipeline_length(BadValue) -> - bad_option(max_pipeline_length, BadValue). - -validate_cookies(Value) - when ((Value =:= enabled) orelse - (Value =:= disabled) orelse - (Value =:= verify)) -> - Value; -validate_cookies(BadValue) -> - bad_option(cookies, BadValue). - -validate_ipv6(Value) when (Value =:= enabled) orelse (Value =:= disabled) -> - case Value of - enabled -> - inet6fb4; - disabled -> - inet - end; -validate_ipv6(BadValue) -> - bad_option(ipv6, BadValue). - -validate_ipfamily(Value) - when (Value =:= inet) orelse (Value =:= inet6) orelse (Value =:= inet6fb4) -> - Value; -validate_ipfamily(BadValue) -> - bad_option(ipfamily, BadValue). - -validate_ip(Value) - when is_tuple(Value) andalso ((size(Value) =:= 4) orelse (size(Value) =:= 8)) -> - Value; -validate_ip(BadValue) -> - bad_option(ip, BadValue). - -validate_port(Value) when is_integer(Value) -> - Value; -validate_port(BadValue) -> - bad_option(port, BadValue). - -validate_verbose(Value) - when ((Value =:= false) orelse - (Value =:= verbose) orelse - (Value =:= debug) orelse - (Value =:= trace)) -> - ok; -validate_verbose(BadValue) -> - bad_option(verbose, BadValue). - -bad_option(Option, BadValue) -> - throw({error, {bad_option, Option, BadValue}}). - - - -header_record([], RequestHeaders, Host, Version) -> - validate_headers(RequestHeaders, Host, Version); -header_record([{"cache-control", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'cache-control' = Val}, - Host, Version); -header_record([{"connection", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{connection = Val}, Host, - Version); -header_record([{"date", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{date = Val}, Host, - Version); -header_record([{"pragma", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{pragma = Val}, Host, - Version); -header_record([{"trailer", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{trailer = Val}, Host, - Version); -header_record([{"transfer-encoding", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'transfer-encoding' = Val}, - Host, Version); -header_record([{"upgrade", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{upgrade = Val}, Host, - Version); -header_record([{"via", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{via = Val}, Host, - Version); -header_record([{"warning", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{warning = Val}, Host, - Version); -header_record([{"accept", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{accept = Val}, Host, - Version); -header_record([{"accept-charset", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'accept-charset' = Val}, - Host, Version); -header_record([{"accept-encoding", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, RequestHeaders#http_request_h{'accept-encoding' = Val}, - Host, Version); -header_record([{"accept-language", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, RequestHeaders#http_request_h{'accept-language' = Val}, - Host, Version); -header_record([{"authorization", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{authorization = Val}, - Host, Version); -header_record([{"expect", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{expect = Val}, Host, - Version); -header_record([{"from", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{from = Val}, Host, - Version); -header_record([{"host", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{host = Val}, Host, - Version); -header_record([{"if-match", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'if-match' = Val}, - Host, Version); -header_record([{"if-modified-since", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'if-modified-since' = Val}, - Host, Version); -header_record([{"if-none-match", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'if-none-match' = Val}, - Host, Version); -header_record([{"if-range", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'if-range' = Val}, - Host, Version); - -header_record([{"if-unmodified-since", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, RequestHeaders#http_request_h{'if-unmodified-since' - = Val}, Host, Version); -header_record([{"max-forwards", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'max-forwards' = Val}, - Host, Version); -header_record([{"proxy-authorization", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, RequestHeaders#http_request_h{'proxy-authorization' - = Val}, Host, Version); -header_record([{"range", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{range = Val}, Host, - Version); -header_record([{"referer", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{referer = Val}, Host, - Version); -header_record([{"te", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{te = Val}, Host, - Version); -header_record([{"user-agent", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'user-agent' = Val}, - Host, Version); -header_record([{"allow", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{allow = Val}, Host, - Version); -header_record([{"content-encoding", Val} | Rest], RequestHeaders, Host, - Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'content-encoding' = Val}, - Host, Version); -header_record([{"content-language", Val} | Rest], RequestHeaders, - Host, Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'content-language' = Val}, - Host, Version); -header_record([{"content-length", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'content-length' = Val}, - Host, Version); -header_record([{"content-location", Val} | Rest], RequestHeaders, - Host, Version) -> - header_record(Rest, - RequestHeaders#http_request_h{'content-location' = Val}, - Host, Version); -header_record([{"content-md5", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'content-md5' = Val}, - Host, Version); -header_record([{"content-range", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'content-range' = Val}, - Host, Version); -header_record([{"content-type", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'content-type' = Val}, - Host, Version); -header_record([{"expires", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{expires = Val}, Host, - Version); -header_record([{"last-modified", Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{'last-modified' = Val}, - Host, Version); -header_record([{Key, Val} | Rest], RequestHeaders, Host, Version) -> - header_record(Rest, RequestHeaders#http_request_h{ - other = [{Key, Val} | - RequestHeaders#http_request_h.other]}, - Host, Version). +stream_next(Pid) -> + httpc:stream_next(Pid). -validate_headers(RequestHeaders = #http_request_h{te = undefined}, Host, - "HTTP/1.1" = Version) -> - validate_headers(RequestHeaders#http_request_h{te = ""}, Host, - "HTTP/1.1" = Version); -validate_headers(RequestHeaders = #http_request_h{host = undefined}, - Host, "HTTP/1.1" = Version) -> - validate_headers(RequestHeaders#http_request_h{host = Host}, Host, Version); -validate_headers(RequestHeaders, _, _) -> - RequestHeaders. +%%-------------------------------------------------------------------------- +%% default_profile() +%%------------------------------------------------------------------------- default_profile() -> - ?DEFAULT_PROFILE. - -profile_name(?DEFAULT_PROFILE) -> - httpc_manager; -profile_name(Pid) when is_pid(Pid) -> - Pid; -profile_name(Profile) -> - list_to_atom("httpc_manager_" ++ atom_to_list(Profile)). - -child_name2info(undefined) -> - {error, no_such_service}; -child_name2info(httpc_manager) -> - {ok, [{profile, default}]}; -child_name2info({http, Profile}) -> - {ok, [{profile, Profile}]}. - -child_name(_, []) -> - undefined; -child_name(Pid, [{Name, Pid} | _]) -> - Name; -child_name(Pid, [_ | Children]) -> - child_name(Pid, Children). - -%% d(F) -> -%% d(F, []). - -%% d(F, A) -> -%% d(get(dbg), F, A). - -%% d(true, F, A) -> -%% io:format(user, "~w:~w:" ++ F ++ "~n", [self(), ?MODULE | A]); -%% d(_, _, _) -> -%% ok. - + httpc:default_profile(). diff --git a/lib/inets/src/http_client/httpc.erl b/lib/inets/src/http_client/httpc.erl new file mode 100644 index 0000000000..5205605e0a --- /dev/null +++ b/lib/inets/src/http_client/httpc.erl @@ -0,0 +1,1079 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +%% Description: +%%% This version of the HTTP/1.1 client supports: +%%% - RFC 2616 HTTP 1.1 client part +%%% - RFC 2818 HTTP Over TLS + +-module(httpc). + +-behaviour(inets_service). + +%% API +-export([ + request/1, request/2, request/4, request/5, + cancel_request/1, cancel_request/2, + set_option/2, set_option/3, + set_options/1, set_options/2, + store_cookies/2, store_cookies/3, + cookie_header/1, cookie_header/2, + which_cookies/0, which_cookies/1, + reset_cookies/0, reset_cookies/1, + stream_next/1, + default_profile/0, + profile_name/1, profile_name/2, + info/0, info/1 + ]). + +%% Behavior callbacks +-export([start_standalone/1, start_service/1, + stop_service/1, + services/0, service_info/1]). + +-include("http_internal.hrl"). +-include("httpc_internal.hrl"). + +-define(DEFAULT_PROFILE, default). + + +%%%========================================================================= +%%% API +%%%========================================================================= + +default_profile() -> + ?DEFAULT_PROFILE. + + +profile_name(?DEFAULT_PROFILE) -> + httpc_manager; +profile_name(Profile) -> + profile_name("httpc_manager_", Profile). + +profile_name(Prefix, Profile) when is_atom(Profile) -> + list_to_atom(Prefix ++ atom_to_list(Profile)); +profile_name(Prefix, Profile) when is_pid(Profile) -> + ProfileStr0 = + string:strip(string:strip(erlang:pid_to_list(Profile), left, $<), right, $>), + F = fun($.) -> $_; (X) -> X end, + ProfileStr = [F(C) || C <- ProfileStr0], + list_to_atom(Prefix ++ "pid_" ++ ProfileStr). + + +%%-------------------------------------------------------------------------- +%% request(Url) -> {ok, {StatusLine, Headers, Body}} | {error,Reason} +%% request(Url Profile) -> +%% {ok, {StatusLine, Headers, Body}} | {error,Reason} +%% +%% Url - string() +%% Description: Calls request/4 with default values. +%%-------------------------------------------------------------------------- + +request(Url) -> + request(Url, default_profile()). + +request(Url, Profile) -> + request(get, {Url, []}, [], [], Profile). + + +%%-------------------------------------------------------------------------- +%% request(Method, Request, HTTPOptions, Options [, Profile]) -> +%% {ok, {StatusLine, Headers, Body}} | {ok, {Status, Body}} | +%% {ok, RequestId} | {error,Reason} | {ok, {saved_as, FilePath} +%% +%% Method - atom() = head | get | put | post | trace | options| delete +%% Request - {Url, Headers} | {Url, Headers, ContentType, Body} +%% Url - string() +%% HTTPOptions - [HttpOption] +%% HTTPOption - {timeout, Time} | {connect_timeout, Time} | +%% {ssl, SSLOptions} | {proxy_auth, {User, Password}} +%% Ssloptions = [SSLOption] +%% SSLOption = {verify, code()} | {depth, depth()} | {certfile, path()} | +%% {keyfile, path()} | {password, string()} | {cacertfile, path()} | +%% {ciphers, string()} +%% Options - [Option] +%% Option - {sync, Boolean} | {body_format, BodyFormat} | +%% {full_result, Boolean} | {stream, To} | +%% {headers_as_is, Boolean} +%% StatusLine = {HTTPVersion, StatusCode, ReasonPhrase}</v> +%% HTTPVersion = string() +%% StatusCode = integer() +%% ReasonPhrase = string() +%% Headers = [Header] +%% Header = {Field, Value} +%% Field = string() +%% Value = string() +%% Body = string() | binary() - HTLM-code +%% +%% Description: Sends a HTTP-request. The function can be both +%% syncronus and asynchronous in the later case the function will +%% return {ok, RequestId} and later on a message will be sent to the +%% calling process on the format {http, {RequestId, {StatusLine, +%% Headers, Body}}} or {http, {RequestId, {error, Reason}}} +%%-------------------------------------------------------------------------- + +request(Method, Request, HttpOptions, Options) -> + request(Method, Request, HttpOptions, Options, default_profile()). + +request(Method, {Url, Headers}, HTTPOptions, Options, Profile) + when (Method =:= options) orelse + (Method =:= get) orelse + (Method =:= head) orelse + (Method =:= delete) orelse + (Method =:= trace) andalso + (is_atom(Profile) orelse is_pid(Profile)) -> + ?hcrt("request", [{method, Method}, + {url, Url}, + {headers, Headers}, + {http_options, HTTPOptions}, + {options, Options}, + {profile, Profile}]), + case http_uri:parse(Url) of + {error, Reason} -> + {error, Reason}; + ParsedUrl -> + handle_request(Method, Url, ParsedUrl, Headers, [], [], + HTTPOptions, Options, Profile) + end; + +request(Method, {Url,Headers,ContentType,Body}, HTTPOptions, Options, Profile) + when ((Method =:= post) orelse (Method =:= put)) andalso + (is_atom(Profile) orelse is_pid(Profile)) -> + ?hcrt("request", [{method, Method}, + {url, Url}, + {headers, Headers}, + {content_type, ContentType}, + {body, Body}, + {http_options, HTTPOptions}, + {options, Options}, + {profile, Profile}]), + case http_uri:parse(Url) of + {error, Reason} -> + {error, Reason}; + ParsedUrl -> + handle_request(Method, Url, + ParsedUrl, Headers, ContentType, Body, + HTTPOptions, Options, Profile) + end. + + +%%-------------------------------------------------------------------------- +%% cancel_request(RequestId) -> ok +%% cancel_request(RequestId, Profile) -> ok +%% RequestId - As returned by request/4 +%% +%% Description: Cancels a HTTP-request. +%%------------------------------------------------------------------------- +cancel_request(RequestId) -> + cancel_request(RequestId, default_profile()). + +cancel_request(RequestId, Profile) + when is_atom(Profile) orelse is_pid(Profile) -> + ?hcrt("cancel request", [{request_id, RequestId}, {profile, Profile}]), + ok = httpc_manager:cancel_request(RequestId, profile_name(Profile)), + receive + %% If the request was already fulfilled throw away the + %% answer as the request has been canceled. + {http, {RequestId, _}} -> + ok + after 0 -> + ok + end. + + +%%-------------------------------------------------------------------------- +%% set_options(Options) -> ok | {error, Reason} +%% set_options(Options, Profile) -> ok | {error, Reason} +%% Options - [Option] +%% Profile - atom() +%% Option - {proxy, {Proxy, NoProxy}} | {max_sessions, MaxSessions} | +%% {max_pipeline_length, MaxPipeline} | +%% {pipeline_timeout, PipelineTimeout} | {cookies, CookieMode} | +%% {ipfamily, IpFamily} +%% Proxy - {Host, Port} +%% NoProxy - [Domain | HostName | IPAddress] +%% MaxSessions, MaxPipeline, PipelineTimeout = integer() +%% CookieMode - enabled | disabled | verify +%% IpFamily - inet | inet6 | inet6fb4 +%% Description: Informs the httpc_manager of the new settings. +%%------------------------------------------------------------------------- +set_options(Options) -> + set_options(Options, default_profile()). +set_options(Options, Profile) when is_atom(Profile) orelse is_pid(Profile) -> + ?hcrt("set cookies", [{options, Options}, {profile, Profile}]), + case validate_options(Options) of + {ok, Opts} -> + try + begin + httpc_manager:set_options(Opts, profile_name(Profile)) + end + catch + exit:{noproc, _} -> + {error, inets_not_started} + end; + {error, Reason} -> + {error, Reason} + end. + +set_option(Key, Value) -> + set_option(Key, Value, default_profile()). + +set_option(Key, Value, Profile) -> + set_options([{Key, Value}], Profile). + + +%%-------------------------------------------------------------------------- +%% store_cookies(SetCookieHeaders, Url [, Profile]) -> ok | {error, reason} +%% +%% +%% Description: Store the cookies from <SetCookieHeaders> +%% in the cookie database +%% for the profile <Profile>. This function shall be used when the option +%% cookie is set to verify. +%%------------------------------------------------------------------------- +store_cookies(SetCookieHeaders, Url) -> + store_cookies(SetCookieHeaders, Url, default_profile()). + +store_cookies(SetCookieHeaders, Url, Profile) + when is_atom(Profile) orelse is_pid(Profile) -> + ?hcrt("store cookies", [{set_cookie_headers, SetCookieHeaders}, + {url, Url}, + {profile, Profile}]), + try + begin + {_, _, Host, Port, Path, _} = http_uri:parse(Url), + Address = {Host, Port}, + ProfileName = profile_name(Profile), + Cookies = httpc_cookie:cookies(SetCookieHeaders, Path, Host), + httpc_manager:store_cookies(Cookies, Address, ProfileName), + ok + end + catch + exit:{noproc, _} -> + {error, {not_started, Profile}}; + error:{badmatch, Bad} -> + {error, {parse_failed, Bad}} + end. + + +%%-------------------------------------------------------------------------- +%% cookie_header(Url [, Profile]) -> Header | {error, Reason} +%% +%% Description: Returns the cookie header that would be sent when making +%% a request to <Url>. +%%------------------------------------------------------------------------- +cookie_header(Url) -> + cookie_header(Url, default_profile()). + +cookie_header(Url, Profile) -> + ?hcrt("cookie header", [{url, Url}, + {profile, Profile}]), + try + begin + httpc_manager:which_cookies(Url, profile_name(Profile)) + end + catch + exit:{noproc, _} -> + {error, {not_started, Profile}} + end. + + +%%-------------------------------------------------------------------------- +%% which_cookies() -> [cookie()] +%% which_cookies(Profile) -> [cookie()] +%% +%% Description: Debug function, dumping the cookie database +%%------------------------------------------------------------------------- +which_cookies() -> + which_cookies(default_profile()). + +which_cookies(Profile) -> + ?hcrt("which cookies", [{profile, Profile}]), + try + begin + httpc_manager:which_cookies(profile_name(Profile)) + end + catch + exit:{noproc, _} -> + {error, {not_started, Profile}} + end. + + +%%-------------------------------------------------------------------------- +%% info() -> list() +%% info(Profile) -> list() +%% +%% Description: Debug function, retreive info about the profile +%%------------------------------------------------------------------------- +info() -> + info(default_profile()). + +info(Profile) -> + ?hcrt("info", [{profile, Profile}]), + try + begin + httpc_manager:info(profile_name(Profile)) + end + catch + exit:{noproc, _} -> + {error, {not_started, Profile}} + end. + + +%%-------------------------------------------------------------------------- +%% reset_cookies() -> void() +%% reset_cookies(Profile) -> void() +%% +%% Description: Debug function, reset the cookie database +%%------------------------------------------------------------------------- +reset_cookies() -> + reset_cookies(default_profile()). + +reset_cookies(Profile) -> + ?hcrt("reset cookies", [{profile, Profile}]), + try + begin + httpc_manager:reset_cookies(profile_name(Profile)) + end + catch + exit:{noproc, _} -> + {error, {not_started, Profile}} + end. + + +%%-------------------------------------------------------------------------- +%% stream_next(Pid) -> Header | {error, Reason} +%% +%% Description: Triggers the next message to be streamed, e.i. +%% same behavior as active once for sockets. +%%------------------------------------------------------------------------- +stream_next(Pid) -> + ?hcrt("stream next", [{handler, Pid}]), + httpc_handler:stream_next(Pid). + + +%%%======================================================================== +%%% Behaviour callbacks +%%%======================================================================== +start_standalone(PropList) -> + ?hcrt("start standalone", [{proplist, PropList}]), + case proplists:get_value(profile, PropList) of + undefined -> + {error, no_profile}; + Profile -> + Dir = + proplists:get_value(data_dir, PropList, only_session_cookies), + httpc_manager:start_link(Profile, Dir, stand_alone) + end. + +start_service(Config) -> + ?hcrt("start service", [{config, Config}]), + httpc_profile_sup:start_child(Config). + +stop_service(Profile) when is_atom(Profile) -> + ?hcrt("stop service", [{profile, Profile}]), + httpc_profile_sup:stop_child(Profile); +stop_service(Pid) when is_pid(Pid) -> + ?hcrt("stop service", [{pid, Pid}]), + case service_info(Pid) of + {ok, [{profile, Profile}]} -> + stop_service(Profile); + Error -> + Error + end. + +services() -> + [{httpc, Pid} || {_, Pid, _, _} <- + supervisor:which_children(httpc_profile_sup)]. +service_info(Pid) -> + try [{ChildName, ChildPid} || + {ChildName, ChildPid, _, _} <- + supervisor:which_children(httpc_profile_sup)] of + Children -> + child_name2info(child_name(Pid, Children)) + catch + exit:{noproc, _} -> + {error, service_not_available} + end. + + +%%%======================================================================== +%%% Internal functions +%%%======================================================================== + +handle_request(Method, Url, + {Scheme, UserInfo, Host, Port, Path, Query}, + Headers, ContentType, Body, + HTTPOptions0, Options0, Profile) -> + + Started = http_util:timestamp(), + NewHeaders = [{http_util:to_lower(Key), Val} || {Key, Val} <- Headers], + + try + begin + HTTPOptions = http_options(HTTPOptions0), + Options = request_options(Options0), + Sync = proplists:get_value(sync, Options), + Stream = proplists:get_value(stream, Options), + Host2 = header_host(Host, Port), + HeadersRecord = header_record(NewHeaders, Host2, HTTPOptions), + Receiver = proplists:get_value(receiver, Options), + SocketOpts = proplists:get_value(socket_opts, Options), + Request = #request{from = Receiver, + scheme = Scheme, + address = {Host, Port}, + path = Path, + pquery = Query, + method = Method, + headers = HeadersRecord, + content = {ContentType, Body}, + settings = HTTPOptions, + abs_uri = Url, + userinfo = UserInfo, + stream = Stream, + headers_as_is = headers_as_is(Headers, Options), + socket_opts = SocketOpts, + started = Started}, + case httpc_manager:request(Request, profile_name(Profile)) of + {ok, RequestId} -> + handle_answer(RequestId, Sync, Options); + {error, Reason} -> + {error, Reason} + end + end + catch + error:{noproc, _} -> + {error, {not_started, Profile}}; + throw:Error -> + Error + end. + + +handle_answer(RequestId, false, _) -> + {ok, RequestId}; +handle_answer(RequestId, true, Options) -> + receive + {http, {RequestId, saved_to_file}} -> + {ok, saved_to_file}; + {http, {RequestId, {_,_,_} = Result}} -> + return_answer(Options, Result); + {http, {RequestId, {error, Reason}}} -> + {error, Reason} + end. + +return_answer(Options, {{"HTTP/0.9",_,_}, _, BinBody}) -> + Body = maybe_format_body(BinBody, Options), + {ok, Body}; + +return_answer(Options, {StatusLine, Headers, BinBody}) -> + + Body = maybe_format_body(BinBody, Options), + + case proplists:get_value(full_result, Options, true) of + true -> + {ok, {StatusLine, Headers, Body}}; + false -> + {_, Status, _} = StatusLine, + {ok, {Status, Body}} + end. + +maybe_format_body(BinBody, Options) -> + case proplists:get_value(body_format, Options, string) of + string -> + binary_to_list(BinBody); + _ -> + BinBody + end. + +%% This options is a workaround for http servers that do not follow the +%% http standard and have case sensative header parsing. Should only be +%% used if there is no other way to communicate with the server or for +%% testing purpose. +headers_as_is(Headers, Options) -> + case proplists:get_value(headers_as_is, Options, false) of + false -> + []; + true -> + Headers + end. + + +http_options(HttpOptions) -> + HttpOptionsDefault = http_options_default(), + http_options(HttpOptionsDefault, HttpOptions, #http_options{}). + +http_options([], [], Acc) -> + Acc; +http_options([], HttpOptions, Acc) -> + Fun = fun(BadOption) -> + Report = io_lib:format("Invalid option ~p ignored ~n", + [BadOption]), + error_logger:info_report(Report) + end, + lists:foreach(Fun, HttpOptions), + Acc; +http_options([{Tag, Default, Idx, Post} | Defaults], HttpOptions, Acc) -> + case lists:keysearch(Tag, 1, HttpOptions) of + {value, {Tag, Val0}} -> + case Post(Val0) of + {ok, Val} -> + Acc2 = setelement(Idx, Acc, Val), + HttpOptions2 = lists:keydelete(Tag, 1, HttpOptions), + http_options(Defaults, HttpOptions2, Acc2); + error -> + Report = io_lib:format("Invalid option ~p:~p ignored ~n", + [Tag, Val0]), + error_logger:info_report(Report), + HttpOptions2 = lists:keydelete(Tag, 1, HttpOptions), + http_options(Defaults, HttpOptions2, Acc) + end; + false -> + DefaultVal = + case Default of + {value, Val} -> + Val; + {field, DefaultIdx} -> + element(DefaultIdx, Acc) + end, + Acc2 = setelement(Idx, Acc, DefaultVal), + http_options(Defaults, HttpOptions, Acc2) + end. + +http_options_default() -> + VersionPost = + fun(Value) when is_atom(Value) -> + {ok, http_util:to_upper(atom_to_list(Value))}; + (Value) when is_list(Value) -> + {ok, http_util:to_upper(Value)}; + (_) -> + error + end, + TimeoutPost = fun(Value) when is_integer(Value) andalso (Value >= 0) -> + {ok, Value}; + (infinity = Value) -> + {ok, Value}; + (_) -> + error + end, + AutoRedirectPost = fun(Value) when (Value =:= true) orelse + (Value =:= false) -> + {ok, Value}; + (_) -> + error + end, + SslPost = fun(Value) when is_list(Value) -> + {ok, Value}; + (_) -> + error + end, + ProxyAuthPost = fun({User, Passwd} = Value) when is_list(User) andalso + is_list(Passwd) -> + {ok, Value}; + (_) -> + error + end, + RelaxedPost = fun(Value) when (Value =:= true) orelse + (Value =:= false) -> + {ok, Value}; + (_) -> + error + end, + ConnTimeoutPost = + fun(Value) when is_integer(Value) andalso (Value >= 0) -> + {ok, Value}; + (infinity = Value) -> + {ok, Value}; + (_) -> + error + end, + [ + {version, {value, "HTTP/1.1"}, #http_options.version, VersionPost}, + {timeout, {value, ?HTTP_REQUEST_TIMEOUT}, #http_options.timeout, TimeoutPost}, + {autoredirect, {value, true}, #http_options.autoredirect, AutoRedirectPost}, + {ssl, {value, []}, #http_options.ssl, SslPost}, + {proxy_auth, {value, undefined}, #http_options.proxy_auth, ProxyAuthPost}, + {relaxed, {value, false}, #http_options.relaxed, RelaxedPost}, + %% this field has to be *after* the timeout field (as that field is used for the default value) + {connect_timeout, {field, #http_options.timeout}, #http_options.connect_timeout, ConnTimeoutPost} + ]. + + +request_options_defaults() -> + VerifyBoolean = + fun(Value) when ((Value =:= true) orelse (Value =:= false)) -> + ok; + (_) -> + error + end, + + VerifySync = VerifyBoolean, + + VerifyStream = + fun(none = _Value) -> + ok; + (self = _Value) -> + ok; + ({self, once} = _Value) -> + ok; + (Value) when is_list(Value) -> + ok; + (_) -> + error + end, + + VerifyBodyFormat = + fun(string = _Value) -> + ok; + (binary = _Value) -> + ok; + (_) -> + error + end, + + VerifyFullResult = VerifyBoolean, + + VerifyHeaderAsIs = VerifyBoolean, + + VerifyReceiver = + fun(Value) when is_pid(Value) -> + ok; + ({M, F, A}) when (is_atom(M) andalso + is_atom(F) andalso + is_list(A)) -> + ok; + (Value) when is_function(Value, 1) -> + ok; + (_) -> + error + end, + + VerifySocketOpts = + fun([]) -> + {ok, undefined}; + (Value) when is_list(Value) -> + ok; + (_) -> + error + end, + + [ + {sync, true, VerifySync}, + {stream, none, VerifyStream}, + {body_format, string, VerifyBodyFormat}, + {full_result, true, VerifyFullResult}, + {headers_as_is, false, VerifyHeaderAsIs}, + {receiver, self(), VerifyReceiver}, + {socket_opts, undefined, VerifySocketOpts} + ]. + +request_options(Options) -> + Defaults = request_options_defaults(), + request_options(Defaults, Options, []). + +request_options([], [], Acc) -> + request_options_sanity_check(Acc), + lists:reverse(Acc); +request_options([], Options, Acc) -> + Fun = fun(BadOption) -> + Report = io_lib:format("Invalid option ~p ignored ~n", + [BadOption]), + error_logger:info_report(Report) + end, + lists:foreach(Fun, Options), + Acc; +request_options([{Key, DefaultVal, Verify} | Defaults], Options, Acc) -> + case lists:keysearch(Key, 1, Options) of + {value, {Key, Value}} -> + case Verify(Value) of + ok -> + Options2 = lists:keydelete(Key, 1, Options), + request_options(Defaults, Options2, [{Key, Value} | Acc]); + {ok, Value2} -> + Options2 = lists:keydelete(Key, 1, Options), + request_options(Defaults, Options2, [{Key, Value2} | Acc]); + error -> + Report = io_lib:format("Invalid option ~p:~p ignored ~n", + [Key, Value]), + error_logger:info_report(Report), + Options2 = lists:keydelete(Key, 1, Options), + request_options(Defaults, Options2, Acc) + end; + false -> + request_options(Defaults, Options, [{Key, DefaultVal} | Acc]) + end. + +request_options_sanity_check(Opts) -> + case proplists:get_value(sync, Opts) of + Sync when (Sync =:= true) -> + case proplists:get_value(receiver, Opts) of + Pid when is_pid(Pid) andalso (Pid =:= self()) -> + ok; + BadReceiver -> + throw({error, {bad_options_combo, + [{sync, true}, {receiver, BadReceiver}]}}) + end, + case proplists:get_value(stream, Opts) of + Stream when (Stream =:= self) orelse + (Stream =:= {self, once}) -> + throw({error, streaming_error}); + _ -> + ok + end; + _ -> + ok + end, + ok. + +validate_options(Options) -> + (catch validate_options(Options, [])). + +validate_options([], ValidateOptions) -> + {ok, lists:reverse(ValidateOptions)}; + +validate_options([{proxy, Proxy} = Opt| Tail], Acc) -> + validate_proxy(Proxy), + validate_options(Tail, [Opt | Acc]); + +validate_options([{max_sessions, Value} = Opt| Tail], Acc) -> + validate_max_sessions(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{keep_alive_timeout, Value} = Opt| Tail], Acc) -> + validate_keep_alive_timeout(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{max_keep_alive_length, Value} = Opt| Tail], Acc) -> + validate_max_keep_alive_length(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{pipeline_timeout, Value} = Opt| Tail], Acc) -> + validate_pipeline_timeout(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{max_pipeline_length, Value} = Opt| Tail], Acc) -> + validate_max_pipeline_length(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{cookies, Value} = Opt| Tail], Acc) -> + validate_cookies(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{ipfamily, Value} = Opt| Tail], Acc) -> + validate_ipfamily(Value), + validate_options(Tail, [Opt | Acc]); + +%% For backward compatibillity +validate_options([{ipv6, Value}| Tail], Acc) -> + NewValue = validate_ipv6(Value), + Opt = {ipfamily, NewValue}, + validate_options(Tail, [Opt | Acc]); + +validate_options([{ip, Value} = Opt| Tail], Acc) -> + validate_ip(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{port, Value} = Opt| Tail], Acc) -> + validate_port(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{socket_opts, Value} = Opt| Tail], Acc) -> + validate_socket_opts(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{verbose, Value} = Opt| Tail], Acc) -> + validate_verbose(Value), + validate_options(Tail, [Opt | Acc]); + +validate_options([{_, _} = Opt| _], _Acc) -> + {error, {not_an_option, Opt}}. + + +validate_proxy({{ProxyHost, ProxyPort}, NoProxy} = Proxy) + when is_list(ProxyHost) andalso + is_integer(ProxyPort) andalso + is_list(NoProxy) -> + Proxy; +validate_proxy(BadProxy) -> + bad_option(proxy, BadProxy). + +validate_max_sessions(Value) when is_integer(Value) andalso (Value >= 0) -> + Value; +validate_max_sessions(BadValue) -> + bad_option(max_sessions, BadValue). + +validate_keep_alive_timeout(Value) when is_integer(Value) andalso (Value >= 0) -> + Value; +validate_keep_alive_timeout(infinity = Value) -> + Value; +validate_keep_alive_timeout(BadValue) -> + bad_option(keep_alive_timeout, BadValue). + +validate_max_keep_alive_length(Value) when is_integer(Value) andalso (Value >= 0) -> + Value; +validate_max_keep_alive_length(BadValue) -> + bad_option(max_keep_alive_length, BadValue). + +validate_pipeline_timeout(Value) when is_integer(Value) -> + Value; +validate_pipeline_timeout(infinity = Value) -> + Value; +validate_pipeline_timeout(BadValue) -> + bad_option(pipeline_timeout, BadValue). + +validate_max_pipeline_length(Value) when is_integer(Value) -> + Value; +validate_max_pipeline_length(BadValue) -> + bad_option(max_pipeline_length, BadValue). + +validate_cookies(Value) + when ((Value =:= enabled) orelse + (Value =:= disabled) orelse + (Value =:= verify)) -> + Value; +validate_cookies(BadValue) -> + bad_option(cookies, BadValue). + +validate_ipv6(Value) when (Value =:= enabled) orelse (Value =:= disabled) -> + case Value of + enabled -> + inet6fb4; + disabled -> + inet + end; +validate_ipv6(BadValue) -> + bad_option(ipv6, BadValue). + +validate_ipfamily(Value) + when (Value =:= inet) orelse (Value =:= inet6) orelse (Value =:= inet6fb4) -> + Value; +validate_ipfamily(BadValue) -> + bad_option(ipfamily, BadValue). + +validate_ip(Value) + when is_tuple(Value) andalso ((size(Value) =:= 4) orelse (size(Value) =:= 8)) -> + Value; +validate_ip(BadValue) -> + bad_option(ip, BadValue). + +validate_port(Value) when is_integer(Value) -> + Value; +validate_port(BadValue) -> + bad_option(port, BadValue). + +validate_socket_opts(Value) when is_list(Value) -> + Value; +validate_socket_opts(BadValue) -> + bad_option(socket_opts, BadValue). + +validate_verbose(Value) + when ((Value =:= false) orelse + (Value =:= verbose) orelse + (Value =:= debug) orelse + (Value =:= trace)) -> + ok; +validate_verbose(BadValue) -> + bad_option(verbose, BadValue). + +bad_option(Option, BadValue) -> + throw({error, {bad_option, Option, BadValue}}). + + +header_host(Host, 80 = _Port) -> + Host; +header_host(Host, Port) -> + Host ++ ":" ++ integer_to_list(Port). + + +header_record(NewHeaders, Host, #http_options{version = Version}) -> + header_record(NewHeaders, #http_request_h{}, Host, Version). + +header_record([], RequestHeaders, Host, Version) -> + validate_headers(RequestHeaders, Host, Version); +header_record([{"cache-control", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'cache-control' = Val}, + Host, Version); +header_record([{"connection", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{connection = Val}, Host, + Version); +header_record([{"date", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{date = Val}, Host, + Version); +header_record([{"pragma", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{pragma = Val}, Host, + Version); +header_record([{"trailer", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{trailer = Val}, Host, + Version); +header_record([{"transfer-encoding", Val} | Rest], RequestHeaders, Host, + Version) -> + header_record(Rest, + RequestHeaders#http_request_h{'transfer-encoding' = Val}, + Host, Version); +header_record([{"upgrade", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{upgrade = Val}, Host, + Version); +header_record([{"via", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{via = Val}, Host, + Version); +header_record([{"warning", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{warning = Val}, Host, + Version); +header_record([{"accept", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{accept = Val}, Host, + Version); +header_record([{"accept-charset", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'accept-charset' = Val}, + Host, Version); +header_record([{"accept-encoding", Val} | Rest], RequestHeaders, Host, + Version) -> + header_record(Rest, RequestHeaders#http_request_h{'accept-encoding' = Val}, + Host, Version); +header_record([{"accept-language", Val} | Rest], RequestHeaders, Host, + Version) -> + header_record(Rest, RequestHeaders#http_request_h{'accept-language' = Val}, + Host, Version); +header_record([{"authorization", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{authorization = Val}, + Host, Version); +header_record([{"expect", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{expect = Val}, Host, + Version); +header_record([{"from", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{from = Val}, Host, + Version); +header_record([{"host", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{host = Val}, Host, + Version); +header_record([{"if-match", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'if-match' = Val}, + Host, Version); +header_record([{"if-modified-since", Val} | Rest], RequestHeaders, Host, + Version) -> + header_record(Rest, + RequestHeaders#http_request_h{'if-modified-since' = Val}, + Host, Version); +header_record([{"if-none-match", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'if-none-match' = Val}, + Host, Version); +header_record([{"if-range", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'if-range' = Val}, + Host, Version); + +header_record([{"if-unmodified-since", Val} | Rest], RequestHeaders, Host, + Version) -> + header_record(Rest, RequestHeaders#http_request_h{'if-unmodified-since' + = Val}, Host, Version); +header_record([{"max-forwards", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'max-forwards' = Val}, + Host, Version); +header_record([{"proxy-authorization", Val} | Rest], RequestHeaders, Host, + Version) -> + header_record(Rest, RequestHeaders#http_request_h{'proxy-authorization' + = Val}, Host, Version); +header_record([{"range", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{range = Val}, Host, + Version); +header_record([{"referer", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{referer = Val}, Host, + Version); +header_record([{"te", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{te = Val}, Host, + Version); +header_record([{"user-agent", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'user-agent' = Val}, + Host, Version); +header_record([{"allow", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{allow = Val}, Host, + Version); +header_record([{"content-encoding", Val} | Rest], RequestHeaders, Host, + Version) -> + header_record(Rest, + RequestHeaders#http_request_h{'content-encoding' = Val}, + Host, Version); +header_record([{"content-language", Val} | Rest], RequestHeaders, + Host, Version) -> + header_record(Rest, + RequestHeaders#http_request_h{'content-language' = Val}, + Host, Version); +header_record([{"content-length", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'content-length' = Val}, + Host, Version); +header_record([{"content-location", Val} | Rest], RequestHeaders, + Host, Version) -> + header_record(Rest, + RequestHeaders#http_request_h{'content-location' = Val}, + Host, Version); +header_record([{"content-md5", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'content-md5' = Val}, + Host, Version); +header_record([{"content-range", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'content-range' = Val}, + Host, Version); +header_record([{"content-type", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'content-type' = Val}, + Host, Version); +header_record([{"expires", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{expires = Val}, Host, + Version); +header_record([{"last-modified", Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{'last-modified' = Val}, + Host, Version); +header_record([{Key, Val} | Rest], RequestHeaders, Host, Version) -> + header_record(Rest, RequestHeaders#http_request_h{ + other = [{Key, Val} | + RequestHeaders#http_request_h.other]}, + Host, Version). + +validate_headers(RequestHeaders = #http_request_h{te = undefined}, Host, + "HTTP/1.1" = Version) -> + validate_headers(RequestHeaders#http_request_h{te = ""}, Host, + "HTTP/1.1" = Version); +validate_headers(RequestHeaders = #http_request_h{host = undefined}, + Host, "HTTP/1.1" = Version) -> + validate_headers(RequestHeaders#http_request_h{host = Host}, Host, Version); +validate_headers(RequestHeaders, _, _) -> + RequestHeaders. + + +child_name2info(undefined) -> + {error, no_such_service}; +child_name2info(httpc_manager) -> + {ok, [{profile, default}]}; +child_name2info({httpc, Profile}) -> + {ok, [{profile, Profile}]}. + +child_name(_, []) -> + undefined; +child_name(Pid, [{Name, Pid} | _]) -> + Name; +child_name(Pid, [_ | Children]) -> + child_name(Pid, Children). + +%% d(F) -> +%% d(F, []). + +%% d(F, A) -> +%% d(get(dbg), F, A). + +%% d(true, F, A) -> +%% io:format(user, "~w:~w:" ++ F ++ "~n", [self(), ?MODULE | A]); +%% d(_, _, _) -> +%% ok. + diff --git a/lib/inets/src/http_client/http_cookie.erl b/lib/inets/src/http_client/httpc_cookie.erl index e091070f72..586701b4a1 100644 --- a/lib/inets/src/http_client/http_cookie.erl +++ b/lib/inets/src/http_client/httpc_cookie.erl @@ -1,164 +1,260 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% Description: Cookie handling according to RFC 2109 --module(http_cookie). +-module(httpc_cookie). -include("httpc_internal.hrl"). --export([header/4, cookies/3, open_cookie_db/1, close_cookie_db/1, insert/2]). +-export([open_db/3, close_db/1, insert/2, header/4, cookies/3]). +-export([reset_db/1, which_cookies/1]). + +-record(cookie_db, {db, session_db}). + %%%========================================================================= %%% API %%%========================================================================= -header(Scheme, {Host, _}, Path, CookieDb) -> - case lookup_cookies(Host, Path, CookieDb) of - [] -> - {"cookie", ""}; - Cookies -> - {"cookie", cookies_to_string(Scheme, Cookies)} + +%%-------------------------------------------------------------------- +%% Func: open_db(DbName, DbDir, SessionDbName) -> #cookie_db{} +%% Purpose: Create the cookie db +%%-------------------------------------------------------------------- + +open_db(_, only_session_cookies, SessionDbName) -> + ?hcrt("open (session cookies only) db", + [{session_db_name, SessionDbName}]), + SessionDb = ets:new(SessionDbName, + [protected, bag, {keypos, #http_cookie.domain}]), + #cookie_db{session_db = SessionDb}; + +open_db(Name, Dir, SessionDbName) -> + ?hcrt("open db", + [{name, Name}, {dir, Dir}, {session_db_name, SessionDbName}]), + File = filename:join(Dir, atom_to_list(Name)), + case dets:open_file(Name, [{keypos, #http_cookie.domain}, + {type, bag}, + {file, File}, + {ram_file, true}]) of + {ok, Db} -> + SessionDb = ets:new(SessionDbName, + [protected, bag, + {keypos, #http_cookie.domain}]), + #cookie_db{db = Db, session_db = SessionDb}; + {error, Reason} -> + throw({error, {failed_open_file, Name, File, Reason}}) end. -cookies(Headers, RequestPath, RequestHost) -> - Cookies = parse_set_cookies(Headers, {RequestPath, RequestHost}), - accept_cookies(Cookies, RequestPath, RequestHost). - -open_cookie_db({{_, only_session_cookies}, SessionDbName}) -> - EtsDb = ets:new(SessionDbName, [protected, bag, - {keypos, #http_cookie.domain}]), - {undefined, EtsDb}; - -open_cookie_db({{DbName, Dbdir}, SessionDbName}) -> - File = filename:join(Dbdir, atom_to_list(DbName)), - {ok, DetsDb} = dets:open_file(DbName, [{keypos, #http_cookie.domain}, - {type, bag}, - {file, File}, - {ram_file, true}]), - EtsDb = ets:new(SessionDbName, [protected, bag, - {keypos, #http_cookie.domain}]), - {DetsDb, EtsDb}. - -close_cookie_db({undefined, EtsDb}) -> - ets:delete(EtsDb); - -close_cookie_db({DetsDb, EtsDb}) -> - dets:close(DetsDb), - ets:delete(EtsDb). + +%%-------------------------------------------------------------------- +%% Func: reset_db(CookieDb) -> void() +%% Purpose: Reset (empty) the cookie database +%% +%%-------------------------------------------------------------------- + +reset_db(#cookie_db{db = undefined, session_db = SessionDb}) -> + ets:delete_all_objects(SessionDb), + ok; +reset_db(#cookie_db{db = Db, session_db = SessionDb}) -> + dets:delete_all_objects(Db), + ets:delete_all_objects(SessionDb), + ok. + + +%%-------------------------------------------------------------------- +%% Func: close_db(CookieDb) -> ok +%% Purpose: Close the cookie db +%%-------------------------------------------------------------------- + +close_db(#cookie_db{db = Db, session_db = SessionDb}) -> + ?hcrt("close db", []), + maybe_dets_close(Db), + ets:delete(SessionDb), + ok. + +maybe_dets_close(undefined) -> + ok; +maybe_dets_close(Db) -> + dets:close(Db). + + +%%-------------------------------------------------------------------- +%% Func: insert(CookieDb) -> ok +%% Purpose: Close the cookie db +%%-------------------------------------------------------------------- %% If no persistent cookie database is defined we %% treat all cookies as if they where session cookies. -insert(Cookie = #http_cookie{max_age = Int}, - Dbs = {undefined, _}) when is_integer(Int) -> - insert(Cookie#http_cookie{max_age = session}, Dbs); - -insert(Cookie = #http_cookie{domain = Key, name = Name, - path = Path, max_age = session}, - Db = {_, CookieDb}) -> - case ets:match_object(CookieDb, #http_cookie{domain = Key, - name = Name, - path = Path, - _ = '_'}) of +insert(#cookie_db{db = undefined} = CookieDb, + #http_cookie{max_age = Int} = Cookie) when is_integer(Int) -> + insert(CookieDb, Cookie#http_cookie{max_age = session}); + +insert(#cookie_db{session_db = SessionDb} = CookieDb, + #http_cookie{domain = Key, + name = Name, + path = Path, + max_age = session} = Cookie) -> + ?hcrt("insert session cookie", [{cookie, Cookie}]), + Pattern = #http_cookie{domain = Key, name = Name, path = Path, _ = '_'}, + case ets:match_object(SessionDb, Pattern) of [] -> - ets:insert(CookieDb, Cookie); + ets:insert(SessionDb, Cookie); [NewCookie] -> - delete(NewCookie, Db), - ets:insert(CookieDb, Cookie) + delete(CookieDb, NewCookie), + ets:insert(SessionDb, Cookie) end, ok; -insert(#http_cookie{domain = Key, name = Name, - path = Path, max_age = 0}, - Db = {CookieDb, _}) -> - case dets:match_object(CookieDb, #http_cookie{domain = Key, - name = Name, - path = Path, - _ = '_'}) of +insert(#cookie_db{db = Db} = CookieDb, + #http_cookie{domain = Key, + name = Name, + path = Path, + max_age = 0}) -> + ?hcrt("insert", [{domain, Key}, {name, Name}, {path, Path}]), + Pattern = #http_cookie{domain = Key, name = Name, path = Path, _ = '_'}, + case dets:match_object(Db, Pattern) of [] -> ok; [NewCookie] -> - delete(NewCookie, Db) + delete(CookieDb, NewCookie) end, ok; -insert(Cookie = #http_cookie{domain = Key, name = Name, path = Path}, - Db = {CookieDb, _}) -> - case dets:match_object(CookieDb, #http_cookie{domain = Key, - name = Name, - path = Path, - _ = '_'}) of +insert(#cookie_db{db = Db} = CookieDb, + #http_cookie{domain = Key, name = Name, path = Path} = Cookie) -> + ?hcrt("insert", [{cookie, Cookie}]), + Pattern = #http_cookie{domain = Key, + name = Name, + path = Path, + _ = '_'}, + case dets:match_object(Db, Pattern) of [] -> - dets:insert(CookieDb, Cookie); - [NewCookie] -> - delete(NewCookie, Db), - dets:insert(CookieDb, Cookie) + dets:insert(Db, Cookie); + [OldCookie] -> + delete(CookieDb, OldCookie), + dets:insert(Db, Cookie) end, ok. + + +%%-------------------------------------------------------------------- +%% Func: header(CookieDb) -> ok +%% Purpose: Cookies +%%-------------------------------------------------------------------- + +header(CookieDb, Scheme, {Host, _}, Path) -> + ?hcrd("header", [{scheme, Scheme}, {host, Host}, {path, Path}]), + case lookup_cookies(CookieDb, Host, Path) of + [] -> + {"cookie", ""}; + Cookies -> + {"cookie", cookies_to_string(Scheme, Cookies)} + end. + + +%%-------------------------------------------------------------------- +%% Func: cookies(Headers, RequestPath, RequestHost) -> [cookie()] +%% Purpose: Which cookies are stored +%%-------------------------------------------------------------------- + +cookies(Headers, RequestPath, RequestHost) -> + ?hcrt("cookies", [{headers, Headers}, + {request_path, RequestPath}, + {request_host, RequestHost}]), + Cookies = parse_set_cookies(Headers, {RequestPath, RequestHost}), + accept_cookies(Cookies, RequestPath, RequestHost). + + +%%-------------------------------------------------------------------- +%% Func: which_cookies(CookieDb) -> [cookie()] +%% Purpose: For test and debug purpose, +%% dump the entire cookie database +%%-------------------------------------------------------------------- + +which_cookies(#cookie_db{db = undefined, session_db = SessionDb}) -> + SessionCookies = ets:tab2list(SessionDb), + [{session_cookies, SessionCookies}]; +which_cookies(#cookie_db{db = Db, session_db = SessionDb}) -> + Cookies = dets:match_object(Db, '_'), + SessionCookies = ets:tab2list(SessionDb), + [{cookies, Cookies}, {session_cookies, SessionCookies}]. + + %%%======================================================================== %%% Internal functions %%%======================================================================== -lookup_cookies(Key, {undefined, Ets}) -> - ets:match_object(Ets, #http_cookie{domain = Key, - _ = '_'}); -lookup_cookies(Key, {Dets,Ets}) -> - SessionCookies = ets:match_object(Ets, #http_cookie{domain = Key, - _ = '_'}), - Cookies = dets:match_object(Dets, #http_cookie{domain = Key, - _ = '_'}), + +delete(#cookie_db{session_db = SessionDb}, + #http_cookie{max_age = session} = Cookie) -> + ets:delete_object(SessionDb, Cookie); +delete(#cookie_db{db = Db}, Cookie) -> + dets:delete_object(Db, Cookie). + + +lookup_cookies(#cookie_db{db = undefined, session_db = SessionDb}, Key) -> + Pattern = #http_cookie{domain = Key, _ = '_'}, + Cookies = ets:match_object(SessionDb, Pattern), + ?hcrt("lookup cookies", [{cookies, Cookies}]), + Cookies; + +lookup_cookies(#cookie_db{db = Db, session_db = SessionDb}, Key) -> + Pattern = #http_cookie{domain = Key, _ = '_'}, + SessionCookies = ets:match_object(SessionDb, Pattern), + ?hcrt("lookup cookies", [{session_cookies, SessionCookies}]), + Cookies = dets:match_object(Db, Pattern), + ?hcrt("lookup cookies", [{cookies, Cookies}]), Cookies ++ SessionCookies. -delete(Cookie = #http_cookie{max_age = session}, {_, CookieDb}) -> - ets:delete_object(CookieDb, Cookie); -delete(Cookie, {CookieDb, _}) -> - dets:delete_object(CookieDb, Cookie). -lookup_cookies(Host, Path, Db) -> +lookup_cookies(CookieDb, Host, Path) -> Cookies = case http_util:is_hostname(Host) of true -> - HostCookies = lookup_cookies(Host, Db), + HostCookies = lookup_cookies(CookieDb, Host), [_| DomainParts] = string:tokens(Host, "."), - lookup_domain_cookies(DomainParts, Db, HostCookies); + lookup_domain_cookies(CookieDb, DomainParts, HostCookies); false -> % IP-adress - lookup_cookies(Host, Db) + lookup_cookies(CookieDb, Host) end, - ValidCookies = valid_cookies(Cookies, [], Db), + ValidCookies = valid_cookies(CookieDb, Cookies), lists:filter(fun(Cookie) -> lists:prefix(Cookie#http_cookie.path, Path) end, ValidCookies). %% For instance if Host=localhost -lookup_domain_cookies([], _, AccCookies) -> +lookup_domain_cookies(_CookieDb, [], AccCookies) -> lists:flatten(AccCookies); + %% Top domains can not have cookies -lookup_domain_cookies([_], _, AccCookies) -> +lookup_domain_cookies(_CookieDb, [_], AccCookies) -> lists:flatten(AccCookies); -lookup_domain_cookies([Next | DomainParts], CookieDb, AccCookies) -> + +lookup_domain_cookies(CookieDb, [Next | DomainParts], AccCookies) -> Domain = merge_domain_parts(DomainParts, [Next ++ "."]), - lookup_domain_cookies(DomainParts, CookieDb, - [lookup_cookies(Domain, CookieDb) - | AccCookies]). + lookup_domain_cookies(CookieDb, DomainParts, + [lookup_cookies(CookieDb, Domain) | AccCookies]). merge_domain_parts([Part], Merged) -> lists:flatten(["." | lists:reverse([Part | Merged])]); merge_domain_parts([Part| Rest], Merged) -> merge_domain_parts(Rest, [".", Part | Merged]). -cookies_to_string(Scheme, Cookies = [Cookie | _]) -> +cookies_to_string(Scheme, [Cookie | _] = Cookies) -> Version = "$Version=" ++ Cookie#http_cookie.version ++ "; ", cookies_to_string(Scheme, path_sort(Cookies), [Version]). @@ -170,7 +266,7 @@ cookies_to_string(_, [], CookieStrs) -> lists:flatten(lists:reverse(CookieStrs)) end; -cookies_to_string(https, [Cookie = #http_cookie{secure = true}| Cookies], +cookies_to_string(https, [#http_cookie{secure = true} = Cookie| Cookies], CookieStrs) -> Str = case Cookies of [] -> @@ -193,7 +289,7 @@ cookies_to_string(Scheme, [Cookie | Cookies], CookieStrs) -> end, cookies_to_string(Scheme, Cookies, [Str | CookieStrs]). -cookie_to_string(Cookie = #http_cookie{name = Name, value = Value}) -> +cookie_to_string(#http_cookie{name = Name, value = Value} = Cookie) -> Str = Name ++ "=" ++ Value, add_domain(add_path(Str, Cookie), Cookie). @@ -208,19 +304,19 @@ add_domain(Str, #http_cookie{domain = Domain}) -> Str ++ "; $Domain=" ++ Domain. parse_set_cookies(OtherHeaders, DefaultPathDomain) -> - SetCookieHeaders = lists:foldl(fun({"set-cookie", Value}, Acc) -> - [string:tokens(Value, ",")| Acc]; - (_, Acc) -> - Acc - end, [], OtherHeaders), + SetCookieHeaders = + lists:foldl(fun({"set-cookie", Value}, Acc) -> + [string:tokens(Value, ",")| Acc]; + (_, Acc) -> + Acc + end, [], OtherHeaders), - lists:flatten(lists:map(fun(CookieHeader) -> - NewHeader = - fix_netscape_cookie(CookieHeader, - []), - parse_set_cookie(NewHeader, [], - DefaultPathDomain) end, - SetCookieHeaders)). + lists:flatten( + lists:map(fun(CookieHeader) -> + NewHeader = fix_netscape_cookie(CookieHeader, []), + parse_set_cookie(NewHeader, [], DefaultPathDomain) + end, + SetCookieHeaders)). parse_set_cookie([], AccCookies, _) -> AccCookies; @@ -282,16 +378,16 @@ cookie_attributes([{"expires", Value}| Attributes], Cookie) -> Time = http_util:convert_netscapecookie_date(Value), ExpireTime = calendar:datetime_to_gregorian_seconds(Time), cookie_attributes(Attributes, - Cookie#http_cookie{max_age = ExpireTime}); + Cookie#http_cookie{max_age = ExpireTime}); cookie_attributes([{"path", Value}| Attributes], Cookie) -> cookie_attributes(Attributes, - Cookie#http_cookie{path = Value}); + Cookie#http_cookie{path = Value}); cookie_attributes([{"secure", _}| Attributes], Cookie) -> cookie_attributes(Attributes, - Cookie#http_cookie{secure = true}); + Cookie#http_cookie{secure = true}); cookie_attributes([{"version", Value}| Attributes], Cookie) -> cookie_attributes(Attributes, - Cookie#http_cookie{version = Value}); + Cookie#http_cookie{version = Value}); %% Disregard unknown attributes. cookie_attributes([_| Attributes], Cookie) -> cookie_attributes(Attributes, Cookie). @@ -302,8 +398,7 @@ domain_default(Cookie = #http_cookie{domain = undefined}, domain_default(Cookie, _) -> Cookie. -path_default(Cookie = #http_cookie{path = undefined}, - DefaultPath) -> +path_default(#http_cookie{path = undefined} = Cookie, DefaultPath) -> Cookie#http_cookie{path = skip_right_most_slash(DefaultPath), path_default = true}; path_default(Cookie, _) -> @@ -321,7 +416,10 @@ accept_cookies(Cookies, RequestPath, RequestHost) -> end, Cookies). accept_cookie(Cookie, RequestPath, RequestHost) -> - accept_path(Cookie, RequestPath) and accept_domain(Cookie, RequestHost). + Accepted = + accept_path(Cookie, RequestPath) andalso + accept_domain(Cookie, RequestHost), + Accepted. accept_path(#http_cookie{path = Path}, RequestPath) -> lists:prefix(Path, RequestPath). @@ -330,18 +428,20 @@ accept_domain(#http_cookie{domain = RequestHost}, RequestHost) -> true; accept_domain(#http_cookie{domain = Domain}, RequestHost) -> - HostCheck = case http_util:is_hostname(RequestHost) of - true -> - (lists:suffix(Domain, RequestHost) andalso - (not - lists:member($., - string:substr(RequestHost, 1, - (length(RequestHost) - - length(Domain)))))); - false -> - false - end, - HostCheck andalso (hd(Domain) == $.) + HostCheck = + case http_util:is_hostname(RequestHost) of + true -> + (lists:suffix(Domain, RequestHost) andalso + (not + lists:member($., + string:substr(RequestHost, 1, + (length(RequestHost) - + length(Domain)))))); + false -> + false + end, + HostCheck + andalso (hd(Domain) =:= $.) andalso (length(string:tokens(Domain, ".")) > 1). cookie_expires(0) -> @@ -356,16 +456,20 @@ is_cookie_expired(#http_cookie{max_age = ExpireTime}) -> NowSec = calendar:datetime_to_gregorian_seconds({date(), time()}), ExpireTime - NowSec =< 0. -valid_cookies([], Valid, _) -> + +valid_cookies(Db, Cookies) -> + valid_cookies(Db, Cookies, []). + +valid_cookies(_Db, [], Valid) -> Valid; -valid_cookies([Cookie | Cookies], Valid, Db) -> +valid_cookies(Db, [Cookie | Cookies], Valid) -> case is_cookie_expired(Cookie) of true -> - delete(Cookie, Db), - valid_cookies(Cookies, Valid, Db); + delete(Db, Cookie), + valid_cookies(Db, Cookies, Valid); false -> - valid_cookies(Cookies, [Cookie | Valid], Db) + valid_cookies(Db, Cookies, [Cookie | Valid]) end. path_sort(Cookies)-> diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl index 7b737c2f86..fec74932a2 100644 --- a/lib/inets/src/http_client/httpc_handler.erl +++ b/lib/inets/src/http_client/httpc_handler.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2002-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2002-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -28,7 +28,15 @@ %%-------------------------------------------------------------------- %% Internal Application API --export([start_link/3, send/2, cancel/2, stream/3, stream_next/1]). +-export([ + start_link/2, + connect_and_send/2, + send/2, + cancel/2, + stream/3, + stream_next/1, + info/1 + ]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, @@ -50,7 +58,7 @@ mfa, % {Moduel, Function, Args} pipeline = queue:new(), % queue() keep_alive = queue:new(), % queue() - status = new, % new | pipeline | keep_alive | close | ssl_tunnel + status, % undefined | new | pipeline | keep_alive | close | ssl_tunnel canceled = [], % [RequestId] max_header_size = nolimit, % nolimit | integer() max_body_size = nolimit, % nolimit | integer() @@ -85,9 +93,13 @@ %% the reply or part of it has arrived.) %%-------------------------------------------------------------------- %%-------------------------------------------------------------------- -start_link(Request, Options, ProfileName) -> - {ok, proc_lib:spawn_link(?MODULE, init, [[Request, Options, - ProfileName]])}. + +start_link(Options, ProfileName) -> + Args = [Options, ProfileName], + gen_server:start_link(?MODULE, Args, []). + +connect_and_send(Request, HandlerPid) -> + call({connect_and_send, Request}, HandlerPid). %%-------------------------------------------------------------------- @@ -126,6 +138,18 @@ stream_next(Pid) -> %%-------------------------------------------------------------------- +%% Function: info(Pid) -> [{Key, Val}] +%% Pid = pid() - the pid of the http-request handler process. +%% +%% Description: +%% Returns various information related to this handler +%% Used for debugging and testing +%%-------------------------------------------------------------------- +info(Pid) -> + call(info, Pid). + + +%%-------------------------------------------------------------------- %% Function: stream(BodyPart, Request, Code) -> _ %% BodyPart = binary() %% Request = #request{} @@ -138,21 +162,21 @@ stream_next(Pid) -> %%-------------------------------------------------------------------- %% Request should not be streamed stream(BodyPart, Request = #request{stream = none}, _) -> - ?hcrt("stream - none", [{body_part, BodyPart}]), + ?hcrt("stream - none", []), {BodyPart, Request}; %% Stream to caller stream(BodyPart, Request = #request{stream = Self}, Code) when ((Code =:= 200) orelse (Code =:= 206)) andalso ((Self =:= self) orelse (Self =:= {self, once})) -> - ?hcrt("stream - self", [{stream, Self}, {code, Code}, {body_part, BodyPart}]), + ?hcrt("stream - self", [{stream, Self}, {code, Code}]), httpc_response:send(Request#request.from, {Request#request.id, stream, BodyPart}), {<<>>, Request}; stream(BodyPart, Request = #request{stream = Self}, 404) when (Self =:= self) orelse (Self =:= {self, once}) -> - ?hcrt("stream - self with 404", [{stream, Self}, {body_part, BodyPart}]), + ?hcrt("stream - self with 404", [{stream, Self}]), httpc_response:send(Request#request.from, {Request#request.id, stream, BodyPart}), {<<>>, Request}; @@ -162,7 +186,7 @@ stream(BodyPart, Request = #request{stream = Self}, 404) %% We keep this for backward compatibillity... stream(BodyPart, Request = #request{stream = Filename}, Code) when ((Code =:= 200) orelse (Code =:= 206)) andalso is_list(Filename) -> - ?hcrt("stream - filename", [{stream, Filename}, {code, Code}, {body_part, BodyPart}]), + ?hcrt("stream - filename", [{stream, Filename}, {code, Code}]), case file:open(Filename, [write, raw, append, delayed_write]) of {ok, Fd} -> ?hcrt("stream - file open ok", [{fd, Fd}]), @@ -174,7 +198,7 @@ stream(BodyPart, Request = #request{stream = Filename}, Code) %% Stream to file stream(BodyPart, Request = #request{stream = Fd}, Code) when ((Code =:= 200) orelse (Code =:= 206)) -> - ?hcrt("stream to file", [{stream, Fd}, {code, Code}, {body_part, BodyPart}]), + ?hcrt("stream to file", [{stream, Fd}, {code, Code}]), case file:write(Fd, BodyPart) of ok -> {<<>>, Request}; @@ -183,7 +207,7 @@ stream(BodyPart, Request = #request{stream = Fd}, Code) end; stream(BodyPart, Request,_) -> % only 200 and 206 responses can be streamed - ?hcrt("stream - ignore", [{request, Request}, {body_part, BodyPart}]), + ?hcrt("stream - ignore", [{request, Request}]), {BodyPart, Request}. @@ -192,10 +216,9 @@ stream(BodyPart, Request,_) -> % only 200 and 206 responses can be streamed %%==================================================================== %%-------------------------------------------------------------------- -%% Function: init([Request, Options, ProfileName]) -> {ok, State} | -%% {ok, State, Timeout} | ignore |{stop, Reason} +%% Function: init([Options, ProfileName]) -> {ok, State} | +%% {ok, State, Timeout} | ignore | {stop, Reason} %% -%% Request = #request{} %% Options = #options{} %% ProfileName = atom() - id of httpc manager process %% @@ -206,30 +229,16 @@ stream(BodyPart, Request,_) -> % only 200 and 206 responses can be streamed %% but we do not want that so errors will be handled by the process %% sending an init_error message to itself. %%-------------------------------------------------------------------- -init([Request, Options, ProfileName]) -> +init([Options, ProfileName]) -> + ?hcrv("init - starting", [{options, Options}, {profile, ProfileName}]), process_flag(trap_exit, true), - handle_verbose(Options#options.verbose), - Address = handle_proxy(Request#request.address, Options#options.proxy), - {ok, State} = - case {Address /= Request#request.address, Request#request.scheme} of - {true, https} -> - Error = https_through_proxy_is_not_currently_supported, - self() ! {init_error, - Error, httpc_response:error(Request, Error)}, - {ok, #state{request = Request, options = Options, - status = ssl_tunnel}}; - %% This is what we should do if and when ssl supports - %% "socket upgrading" - %%send_ssl_tunnel_request(Address, Request, - %% #state{options = Options, - %% status = ssl_tunnel}); - {_, _} -> - send_first_request(Address, Request, - #state{options = Options, - profile_name = ProfileName}) - end, - gen_server:enter_loop(?MODULE, [], State). + State = #state{status = undefined, + options = Options, + profile_name = ProfileName}, + ?hcrd("init - started", []), + {ok, State}. + %%-------------------------------------------------------------------- %% Function: handle_call(Request, From, State) -> {reply, Reply, State} | @@ -240,39 +249,85 @@ init([Request, Options, ProfileName]) -> %% {stop, Reason, State} (terminate/2 is called) %% Description: Handling call messages %%-------------------------------------------------------------------- -handle_call(Request, _, State = #state{session = Session = - #tcp_session{socket = Socket, - type = pipeline}, - timers = Timers, - options = Options, - profile_name = ProfileName}) -> - Address = handle_proxy(Request#request.address, Options#options.proxy), + + +%% This is the first request, the reason the proc was started +handle_call({connect_and_send, #request{address = Address0, + scheme = Scheme} = Request}, + _From, + #state{options = #options{proxy = Proxy}, + status = undefined, + session = undefined} = State) -> + ?hcrv("connect and send", [{address0, Address0}, {proxy, Proxy}]), + Address = handle_proxy(Address0, Proxy), + if + ((Address =/= Address0) andalso (Scheme =:= https)) -> + %% This is what we should do if and when ssl supports + %% "socket upgrading" + %%send_ssl_tunnel_request(Address, Request, + %% #state{options = Options, + %% status = ssl_tunnel}); + Reason = https_through_proxy_is_not_currently_supported, + Error = {error, Reason}, + {stop, Error, Error, State}; + true -> + case connect_and_send_first_request(Address, Request, State) of + {ok, NewState} -> + {reply, ok, NewState}; + {stop, Error, NewState} -> + {stop, Error, Error, NewState} + end + end; + +handle_call(#request{address = Addr} = Request, _, + #state{status = Status, + session = #tcp_session{socket = Socket, + type = pipeline} = Session, + timers = Timers, + options = #options{proxy = Proxy} = _Options, + profile_name = ProfileName} = State) + when Status =/= undefined -> + + ?hcrv("new request on a pipeline session", + [{request, Request}, + {profile, ProfileName}, + {status, Status}, + {timers, Timers}]), + + Address = handle_proxy(Addr, Proxy), case httpc_request:send(Address, Request, Socket) of ok -> + + ?hcrd("request sent", []), + %% Activate the request time out for the new request - NewState = activate_request_timeout(State#state{request = - Request}), + NewState = + activate_request_timeout(State#state{request = Request}), + + ClientClose = + httpc_request:is_client_closing(Request#request.headers), - ClientClose = httpc_request:is_client_closing( - Request#request.headers), case State#state.request of - #request{} -> %% Old request no yet finished + #request{} -> %% Old request not yet finished + ?hcrd("old request still not finished", []), %% Make sure to use the new value of timers in state - NewTimers = NewState#state.timers, + NewTimers = NewState#state.timers, NewPipeline = queue:in(Request, State#state.pipeline), - NewSession = + NewSession = Session#tcp_session{queue_length = %% Queue + current queue:len(NewPipeline) + 1, client_close = ClientClose}, httpc_manager:insert_session(NewSession, ProfileName), + ?hcrd("session updated", []), {reply, ok, State#state{pipeline = NewPipeline, - session = NewSession, - timers = NewTimers}}; + session = NewSession, + timers = NewTimers}}; undefined -> - %% Note: tcp-message reciving has already been + %% Note: tcp-message receiving has already been %% activated by handle_pipeline/2. + ?hcrd("no current request", []), cancel_timer(Timers#timers.queue_timer, timeout_queue), NewSession = @@ -281,54 +336,67 @@ handle_call(Request, _, State = #state{session = Session = httpc_manager:insert_session(NewSession, ProfileName), Relaxed = (Request#request.settings)#http_options.relaxed, - {reply, ok, - NewState#state{request = Request, - session = NewSession, - mfa = {httpc_response, parse, - [State#state.max_header_size, - Relaxed]}, - timers = - Timers#timers{queue_timer = - undefined}}} + MFA = {httpc_response, parse, + [State#state.max_header_size, Relaxed]}, + NewTimers = Timers#timers{queue_timer = undefined}, + ?hcrd("session created", []), + {reply, ok, NewState#state{request = Request, + session = NewSession, + mfa = MFA, + timers = NewTimers}} end; {error, Reason} -> + ?hcri("failed sending request", [{reason, Reason}]), {reply, {pipeline_failed, Reason}, State} end; -handle_call(Request, _, #state{session = Session = - #tcp_session{type = keep_alive, - socket = Socket}, - timers = Timers, - options = Options, - profile_name = ProfileName} = State) -> - - ClientClose = httpc_request:is_client_closing(Request#request.headers), +handle_call(#request{address = Addr} = Request, _, + #state{status = Status, + session = #tcp_session{socket = Socket, + type = keep_alive} = Session, + timers = Timers, + options = #options{proxy = Proxy} = _Options, + profile_name = ProfileName} = State) + when Status =/= undefined -> - Address = handle_proxy(Request#request.address, - Options#options.proxy), + ?hcrv("new request on a keep-alive session", + [{request, Request}, + {profile, ProfileName}, + {status, Status}]), + + Address = handle_proxy(Addr, Proxy), case httpc_request:send(Address, Request, Socket) of ok -> + + ?hcrd("request sent", []), + + %% Activate the request time out for the new request NewState = - activate_request_timeout(State#state{request = - Request}), + activate_request_timeout(State#state{request = Request}), + + ClientClose = + httpc_request:is_client_closing(Request#request.headers), case State#state.request of #request{} -> %% Old request not yet finished %% Make sure to use the new value of timers in state - NewTimers = NewState#state.timers, + ?hcrd("old request still not finished", []), + NewTimers = NewState#state.timers, NewKeepAlive = queue:in(Request, State#state.keep_alive), - NewSession = + NewSession = Session#tcp_session{queue_length = %% Queue + current queue:len(NewKeepAlive) + 1, client_close = ClientClose}, httpc_manager:insert_session(NewSession, ProfileName), + ?hcrd("session updated", []), {reply, ok, State#state{keep_alive = NewKeepAlive, - session = NewSession, - timers = NewTimers}}; + session = NewSession, + timers = NewTimers}}; undefined -> %% Note: tcp-message reciving has already been %% activated by handle_pipeline/2. + ?hcrd("no current request", []), cancel_timer(Timers#timers.queue_timer, timeout_queue), NewSession = @@ -337,16 +405,23 @@ handle_call(Request, _, #state{session = Session = httpc_manager:insert_session(NewSession, ProfileName), Relaxed = (Request#request.settings)#http_options.relaxed, - {reply, ok, - NewState#state{request = Request, - session = NewSession, - mfa = {httpc_response, parse, - [State#state.max_header_size, - Relaxed]}}} + MFA = {httpc_response, parse, + [State#state.max_header_size, Relaxed]}, + {reply, ok, NewState#state{request = Request, + session = NewSession, + mfa = MFA}} end; - {error, Reason} -> + + {error, Reason} -> + ?hcri("failed sending request", [{reason, Reason}]), {reply, {request_failed, Reason}, State} - end. + end; + + +handle_call(info, _, State) -> + Info = handler_info(State), + {reply, Info, State}. + %%-------------------------------------------------------------------- %% Function: handle_cast(Msg, State) -> {noreply, State} | @@ -367,19 +442,30 @@ handle_call(Request, _, #state{session = Session = %% handle_keep_alive_queue/2 on the other hand will just skip the %% request as if it was never issued as in this case the request will %% not have been sent. -handle_cast({cancel, RequestId}, State = #state{request = Request = - #request{id = RequestId}, - profile_name = ProfileName}) -> +handle_cast({cancel, RequestId}, + #state{request = #request{id = RequestId} = Request, + profile_name = ProfileName, + canceled = Canceled} = State) -> + ?hcrv("cancel current request", [{request_id, RequestId}, + {profile, ProfileName}, + {canceled, Canceled}]), httpc_manager:request_canceled(RequestId, ProfileName), + ?hcrv("canceled", []), {stop, normal, - State#state{canceled = [RequestId | State#state.canceled], - request = Request#request{from = answer_sent}}}; -handle_cast({cancel, RequestId}, State = #state{profile_name = ProfileName}) -> + State#state{canceled = [RequestId | Canceled], + request = Request#request{from = answer_sent}}}; +handle_cast({cancel, RequestId}, + #state{profile_name = ProfileName, + canceled = Canceled} = State) -> + ?hcrv("cancel", [{request_id, RequestId}, + {profile, ProfileName}, + {canceled, Canceled}]), httpc_manager:request_canceled(RequestId, ProfileName), - {noreply, State#state{canceled = [RequestId | State#state.canceled]}}; + ?hcrv("canceled", []), + {noreply, State#state{canceled = [RequestId | Canceled]}}; + handle_cast(stream_next, #state{session = Session} = State) -> - http_transport:setopts(socket_type(Session#tcp_session.scheme), - Session#tcp_session.socket, [{active, once}]), + activate_once(Session), {noreply, State#state{once = once}}. @@ -390,7 +476,7 @@ handle_cast(stream_next, #state{session = Session} = State) -> %% Description: Handling all non call/cast messages %%-------------------------------------------------------------------- handle_info({Proto, _Socket, Data}, - #state{mfa = {Module, Function, Args} = MFA, + #state{mfa = {Module, Function, Args}, request = #request{method = Method, stream = Stream} = Request, session = Session, @@ -399,64 +485,68 @@ handle_info({Proto, _Socket, Data}, (Proto =:= ssl) orelse (Proto =:= httpc_handler) -> - ?hcri("received data", [{proto, Proto}, {data, Data}, {mfa, MFA}, {method, Method}, {stream, Stream}, {session, Session}, {status_line, StatusLine}]), + ?hcri("received data", [{proto, Proto}, + {module, Module}, + {function, Function}, + {method, Method}, + {stream, Stream}, + {session, Session}, + {status_line, StatusLine}]), FinalResult = try Module:Function([Data | Args]) of {ok, Result} -> - ?hcrd("data processed - ok", [{result, Result}]), + ?hcrd("data processed - ok", []), handle_http_msg(Result, State); {_, whole_body, _} when Method =:= head -> ?hcrd("data processed - whole body", []), handle_response(State#state{body = <<>>}); {Module, whole_body, [Body, Length]} -> - ?hcrd("data processed - whole body", [{module, Module}, {body, Body}, {length, Length}]), + ?hcrd("data processed - whole body", [{length, Length}]), {_, Code, _} = StatusLine, {NewBody, NewRequest} = stream(Body, Request, Code), %% When we stream we will not keep the already %% streamed data, that would be a waste of memory. - NewLength = case Stream of - none -> - Length; - _ -> - Length - size(Body) - end, + NewLength = + case Stream of + none -> + Length; + _ -> + Length - size(Body) + end, NewState = next_body_chunk(State), - - {noreply, NewState#state{mfa = {Module, whole_body, - [NewBody, NewLength]}, + NewMFA = {Module, whole_body, [NewBody, NewLength]}, + {noreply, NewState#state{mfa = NewMFA, request = NewRequest}}; NewMFA -> - ?hcrd("data processed", [{new_mfa, NewMFA}]), - http_transport:setopts(socket_type(Session#tcp_session.scheme), - Session#tcp_session.socket, - [{active, once}]), + ?hcrd("data processed - new mfa", []), + activate_once(Session), {noreply, State#state{mfa = NewMFA}} catch - exit:_ -> - ClientErrMsg = httpc_response:error(Request, - {could_not_parse_as_http, - Data}), - NewState = answer_request(Request, ClientErrMsg, State), + exit:_Exit -> + ?hcrd("data processing exit", [{exit, _Exit}]), + ClientReason = {could_not_parse_as_http, Data}, + ClientErrMsg = httpc_response:error(Request, ClientReason), + NewState = answer_request(Request, ClientErrMsg, State), {stop, normal, NewState}; - error:_ -> - ClientErrMsg = httpc_response:error(Request, - {could_not_parse_as_http, - Data}), - NewState = answer_request(Request, ClientErrMsg, State), + error:_Error -> + ?hcrd("data processing error", [{error, _Error}]), + ClientReason = {could_not_parse_as_http, Data}, + ClientErrMsg = httpc_response:error(Request, ClientReason), + NewState = answer_request(Request, ClientErrMsg, State), {stop, normal, NewState} end, - ?hcri("data processed", [{result, FinalResult}]), + ?hcri("data processed", []), FinalResult; handle_info({Proto, Socket, Data}, - #state{mfa = MFA, - request = Request, - session = Session, - status = Status, + #state{mfa = MFA, + request = Request, + session = Session, + status = Status, status_line = StatusLine, profile_name = Profile} = State) when (Proto =:= tcp) orelse @@ -474,6 +564,7 @@ handle_info({Proto, Socket, Data}, "~n", [Proto, Socket, Data, MFA, Request, Session, Status, StatusLine, Profile]), + {noreply, State}; @@ -513,28 +604,35 @@ handle_info({ssl_error, _, _} = Reason, State) -> handle_info({timeout, RequestId}, #state{request = #request{id = RequestId} = Request, canceled = Canceled} = State) -> + ?hcri("timeout of current request", [{id, RequestId}]), httpc_response:send(Request#request.from, - httpc_response:error(Request,timeout)), + httpc_response:error(Request, timeout)), + ?hcrv("response (timeout) sent - now terminate", []), {stop, normal, State#state{request = Request#request{from = answer_sent}, canceled = [RequestId | Canceled]}}; handle_info({timeout, RequestId}, #state{canceled = Canceled} = State) -> + ?hcri("timeout", [{id, RequestId}]), Filter = fun(#request{id = Id, from = From} = Request) when Id =:= RequestId -> + ?hcrv("found request", [{id, Id}, {from, From}]), %% Notify the owner Response = httpc_response:error(Request, timeout), httpc_response:send(From, Response), + ?hcrv("response (timeout) sent", []), [Request#request{from = answer_sent}]; (_) -> true end, case State#state.status of pipeline -> + ?hcrd("pipeline", []), Pipeline = queue:filter(Filter, State#state.pipeline), {noreply, State#state{canceled = [RequestId | Canceled], pipeline = Pipeline}}; keep_alive -> + ?hcrd("keep_alive", []), KeepAlive = queue:filter(Filter, State#state.keep_alive), {noreply, State#state{canceled = [RequestId | Canceled], keep_alive = KeepAlive}} @@ -577,9 +675,10 @@ terminate(normal, #state{session = undefined}) -> %% Init error sending, no session information has been setup but %% there is a socket that needs closing. -terminate(normal, #state{request = Request, - session = #tcp_session{id = undefined, - socket = Socket}}) -> +terminate(normal, + #state{request = Request, + session = #tcp_session{id = undefined, + socket = Socket}}) -> http_transport:close(socket_type(Request), Socket); %% Socket closed remotely @@ -590,6 +689,9 @@ terminate(normal, request = Request, timers = Timers, pipeline = Pipeline}) -> + ?hcrt("terminate(normal) - remote close", + [{id, Id}, {profile, ProfileName}]), + %% Clobber session (catch httpc_manager:delete_session(Id, ProfileName)), @@ -605,23 +707,28 @@ terminate(normal, %% And, just in case, close our side (**really** overkill) http_transport:close(socket_type(Request), Socket); -terminate(_, State = #state{session = Session, - request = undefined, - profile_name = ProfileName, - timers = Timers, - pipeline = Pipeline, - keep_alive = KeepAlive}) -> - catch httpc_manager:delete_session(Session#tcp_session.id, - ProfileName), +terminate(_, #state{session = #tcp_session{id = Id, + socket = Socket, + scheme = Scheme}, + request = undefined, + profile_name = ProfileName, + timers = Timers, + pipeline = Pipeline, + keep_alive = KeepAlive} = State) -> + (catch httpc_manager:delete_session(Id, ProfileName)), maybe_retry_queue(Pipeline, State), maybe_retry_queue(KeepAlive, State), cancel_timer(Timers#timers.queue_timer, timeout_queue), - Socket = Session#tcp_session.socket, - http_transport:close(socket_type(Session#tcp_session.scheme), Socket); + http_transport:close(socket_type(Scheme), Socket); + +terminate(Reason, #state{request = undefined}) -> + ?hcrt("terminate", [{reason, Reason}]), + ok; -terminate(Reason, State = #state{request = Request}) -> +terminate(Reason, #state{request = Request} = State) -> + ?hcrd("terminate", [{reason, Reason}, {request, Request}]), NewState = maybe_send_answer(Request, httpc_response:error(Request, Reason), State), @@ -641,13 +748,16 @@ maybe_send_answer(Request, Answer, State) -> answer_request(Request, Answer, State). deliver_answers([]) -> + ?hcrd("deliver answer done", []), ok; -deliver_answers([#request{from = From} = Request | Requests]) +deliver_answers([#request{id = Id, from = From} = Request | Requests]) when is_pid(From) -> Response = httpc_response:error(Request, socket_closed_remotely), + ?hcrd("deliver answer", [{id, Id}, {from, From}, {response, Response}]), httpc_response:send(From, Response), deliver_answers(Requests); -deliver_answers([_|Requests]) -> +deliver_answers([Request|Requests]) -> + ?hcrd("skip deliver answer", [{request, Request}]), deliver_answers(Requests). @@ -691,19 +801,22 @@ new_queue(Queue, Fun) -> end, List), queue:from_list(NewList). -%%-------------------------------------------------------------------- + +%%%-------------------------------------------------------------------- %%% Internal functions -%%-------------------------------------------------------------------- +%%%-------------------------------------------------------------------- -connect(SocketType, ToAddress, #options{ipfamily = IpFamily, - ip = FromAddress, - port = FromPort}, Timeout) -> +connect(SocketType, ToAddress, + #options{ipfamily = IpFamily, + ip = FromAddress, + port = FromPort, + socket_opts = Opts0}, Timeout) -> Opts1 = case FromPort of default -> - []; + Opts0; _ -> - [{port, FromPort}] + [{port, FromPort} | Opts0] end, Opts2 = case FromAddress of @@ -728,101 +841,157 @@ connect(SocketType, ToAddress, #options{ipfamily = IpFamily, http_transport:connect(SocketType, ToAddress, Opts3, Timeout) end. - -send_first_request(Address, Request, #state{options = Options} = State) -> - SocketType = socket_type(Request), - ConnTimeout = (Request#request.settings)#http_options.connect_timeout, - ?hcri("connect", +connect_and_send_first_request(Address, + #request{settings = Settings, + headers = Headers, + address = OrigAddress, + scheme = Scheme} = Request, + #state{options = Options} = State) -> + + ?hcrd("connect", [{address, Address}, {request, Request}, {options, Options}]), + + SocketType = socket_type(Request), + ConnTimeout = Settings#http_options.connect_timeout, case connect(SocketType, Address, Options, ConnTimeout) of {ok, Socket} -> - ?hcri("connected - now send first request", [{socket, Socket}]), + ?hcrd("connected - now send first request", [{socket, Socket}]), case httpc_request:send(Address, Request, Socket) of ok -> - ?hcri("first request sent", []), + ?hcrd("first request sent", []), ClientClose = - httpc_request:is_client_closing( - Request#request.headers), + httpc_request:is_client_closing(Headers), SessionType = httpc_manager:session_type(Options), Session = - #tcp_session{id = {Request#request.address, self()}, - scheme = Request#request.scheme, - socket = Socket, + #tcp_session{id = {OrigAddress, self()}, + scheme = Scheme, + socket = Socket, client_close = ClientClose, - type = SessionType}, - TmpState = State#state{request = Request, - session = Session, - mfa = init_mfa(Request, State), - status_line = - init_status_line(Request), - headers = undefined, - body = undefined, - status = new}, - http_transport:setopts(SocketType, - Socket, [{active, once}]), + type = SessionType}, + TmpState = + State#state{request = Request, + session = Session, + mfa = init_mfa(Request, State), + status_line = init_status_line(Request), + headers = undefined, + body = undefined, + status = new}, + ?hcrt("activate socket", []), + activate_once(Session), NewState = activate_request_timeout(TmpState), {ok, NewState}; - {error, Reason} -> - %% Commented out in wait of ssl support to avoid - %% dialyzer warning - %%case State#state.status of - %% new -> % Called from init/1 - self() ! {init_error, error_sending, - httpc_response:error(Request, Reason)}, - {ok, State#state{request = Request, - session = - #tcp_session{socket = Socket}}} - %%ssl_tunnel -> % Not called from init/1 - %% NewState = - %% answer_request(Request, - %%httpc_response:error(Request, - %%Reason), - %% State), - %% {stop, normal, NewState} - %% end + {error, Reason} -> + ?hcrv("failed sending request", [{reason, Reason}]), + Error = {error, {send_failed, + httpc_response:error(Request, Reason)}}, + {stop, Error, State#state{request = Request}} end; - {error, Reason} -> - %% Commented out in wait of ssl support to avoid - %% dialyzer warning - %% case State#state.status of - %% new -> % Called from init/1 - self() ! {init_error, error_connecting, - httpc_response:error(Request, Reason)}, - {ok, State#state{request = Request}} - %% ssl_tunnel -> % Not called from init/1 - %% NewState = - %% answer_request(Request, - %% httpc_response:error(Request, - %% Reason), - %% State), - %% {stop, normal, NewState} - %%end + {error, Reason} -> + ?hcri("connect failed", [{reason, Reason}]), + Error = {error, {connect_failed, + httpc_response:error(Request, Reason)}}, + {stop, Error, State#state{request = Request}} end. + +handler_info(#state{request = Request, + session = Session, + status_line = _StatusLine, + pipeline = Pipeline, + keep_alive = KeepAlive, + status = Status, + canceled = _Canceled, + options = _Options, + timers = _Timers} = _State) -> + + ?hcrt("handler info", [{request, Request}, + {session, Session}, + {pipeline, Pipeline}, + {keep_alive, KeepAlive}, + {status, Status}]), + + %% Info about the current request + RequestInfo = + case Request of + undefined -> + []; + #request{id = Id, + started = ReqStarted} -> + [{id, Id}, {started, ReqStarted}] + end, + + ?hcrt("handler info", [{request_info, RequestInfo}]), + + %% Info about the current session/socket + SessionType = Session#tcp_session.type, + QueueLen = case Session#tcp_session.type of + pipeline -> + queue:len(Pipeline); + keep_alive -> + queue:len(KeepAlive) + end, + Socket = Session#tcp_session.socket, + Scheme = Session#tcp_session.scheme, + SocketType = socket_type(Scheme), + + ?hcrt("handler info", [{session_type, SessionType}, + {queue_length, QueueLen}, + {scheme, Scheme}, + {socket_type, SocketType}, + {socket, Socket}]), + + SocketOpts = http_transport:getopts(SocketType, Socket), + SocketStats = http_transport:getstat(SocketType, Socket), + + Remote = http_transport:peername(SocketType, Socket), + Local = http_transport:sockname(SocketType, Socket), + + ?hcrt("handler info", [{remote, Remote}, + {local, Local}, + {socket_opts, SocketOpts}, + {socket_stats, SocketStats}]), + + SocketInfo = [{remote, Remote}, + {local, Local}, + {socket_opts, SocketOpts}, + {socket_stats, SocketStats}], + + SessionInfo = + [{type, SessionType}, + {queue_length, QueueLen}, + {scheme, Scheme}, + {socket_info, SocketInfo}], + + [{status, Status}, + {current_request, RequestInfo}, + {session, SessionInfo}]. + + + handle_http_msg({Version, StatusCode, ReasonPharse, Headers, Body}, State = #state{request = Request}) -> - ?hcrt("handle_http_msg", [{body, Body}]), + ?hcrt("handle_http_msg", [{headers, Headers}]), case Headers#http_response_h.'content-type' of "multipart/byteranges" ++ _Param -> - exit(not_yet_implemented); + exit({not_yet_implemented, multypart_byteranges}); _ -> - StatusLine = {Version, StatusCode, ReasonPharse}, + StatusLine = {Version, StatusCode, ReasonPharse}, {ok, NewRequest} = start_stream(StatusLine, Headers, Request), handle_http_body(Body, State#state{request = NewRequest, status_line = StatusLine, headers = Headers}) end; -handle_http_msg({ChunkedHeaders, Body}, - State = #state{headers = Headers}) -> - ?hcrt("handle_http_msg", [{chunked_headers, ChunkedHeaders}, {body, Body}]), +handle_http_msg({ChunkedHeaders, Body}, #state{headers = Headers} = State) -> + ?hcrt("handle_http_msg", + [{chunked_headers, ChunkedHeaders}, {headers, Headers}]), NewHeaders = http_chunk:handle_headers(Headers, ChunkedHeaders), handle_response(State#state{headers = NewHeaders, body = Body}); -handle_http_msg(Body, State = #state{status_line = {_,Code, _}}) -> - ?hcrt("handle_http_msg", [{body, Body}, {code, Code}]), - {NewBody, NewRequest}= stream(Body, State#state.request, Code), +handle_http_msg(Body, #state{status_line = {_,Code, _}} = State) -> + ?hcrt("handle_http_msg", [{code, Code}]), + {NewBody, NewRequest} = stream(Body, State#state.request, Code), handle_response(State#state{body = NewBody, request = NewRequest}). handle_http_body(<<>>, State = #state{status_line = {_,304, _}}) -> @@ -837,11 +1006,12 @@ handle_http_body(<<>>, State = #state{request = #request{method = head}}) -> ?hcrt("handle_http_body - head", []), handle_response(State#state{body = <<>>}); -handle_http_body(Body, State = #state{headers = Headers, - max_body_size = MaxBodySize, - status_line = {_,Code, _}, - request = Request}) -> - ?hcrt("handle_http_body", [{body, Body}, {max_body_size, MaxBodySize}, {code, Code}]), +handle_http_body(Body, #state{headers = Headers, + max_body_size = MaxBodySize, + status_line = {_,Code, _}, + request = Request} = State) -> + ?hcrt("handle_http_body", + [{max_body_size, MaxBodySize}, {headers, Headers}, {code, Code}]), TransferEnc = Headers#http_response_h.'transfer-encoding', case case_insensitive_header(TransferEnc) of "chunked" -> @@ -850,12 +1020,17 @@ handle_http_body(Body, State = #state{headers = Headers, State#state.max_header_size, {Code, Request}) of {Module, Function, Args} -> - ?hcrt("handle_http_body - new mfa", [{module, Module}, {function, Function}, {args, Args}]), + ?hcrt("handle_http_body - new mfa", + [{module, Module}, + {function, Function}, + {args, Args}]), NewState = next_body_chunk(State), {noreply, NewState#state{mfa = {Module, Function, Args}}}; {ok, {ChunkedHeaders, NewBody}} -> - ?hcrt("handle_http_body - nyew body", [{chunked_headers, ChunkedHeaders}, {new_body, NewBody}]), + ?hcrt("handle_http_body - new body", + [{chunked_headers, ChunkedHeaders}, + {new_body, NewBody}]), NewHeaders = http_chunk:handle_headers(Headers, ChunkedHeaders), handle_response(State#state{headers = NewHeaders, @@ -872,12 +1047,13 @@ handle_http_body(Body, State = #state{headers = Headers, ?hcrt("handle_http_body - other", []), Length = list_to_integer(Headers#http_response_h.'content-length'), - case ((Length =< MaxBodySize) or (MaxBodySize == nolimit)) of + case ((Length =< MaxBodySize) orelse (MaxBodySize =:= nolimit)) of true -> case httpc_response:whole_body(Body, Length) of {ok, Body} -> - {NewBody, NewRequest}= stream(Body, Request, Code), - handle_response(State#state{body = NewBody, + {NewBody, NewRequest} = + stream(Body, Request, Code), + handle_response(State#state{body = NewBody, request = NewRequest}); MFA -> NewState = next_body_chunk(State), @@ -893,90 +1069,79 @@ handle_http_body(Body, State = #state{headers = Headers, end end. -%%% Normaly I do not comment out code, I throw it away. But this might -%%% actually be used on day if ssl is improved. -%% handle_response(State = #state{status = ssl_tunnel, -%% request = Request, -%% options = Options, -%% session = #tcp_session{socket = Socket, -%% scheme = Scheme}, -%% status_line = {_, 200, _}}) -> -%% %%% Insert code for upgrading the socket if and when ssl supports this. -%% Address = handle_proxy(Request#request.address, Options#options.proxy), -%% send_first_request(Address, Request, State); -%% handle_response(State = #state{status = ssl_tunnel, -%% request = Request}) -> -%% NewState = answer_request(Request, -%% httpc_response:error(Request, -%% ssl_proxy_tunnel_failed), -%% State), -%% {stop, normal, NewState}; - -handle_response(State = #state{status = new}) -> - handle_response(try_to_enable_pipeline_or_keep_alive(State)); - -handle_response(State = - #state{request = Request, +handle_response(#state{status = new} = State) -> + ?hcrd("handle response - status = new", []), + handle_response(try_to_enable_pipeline_or_keep_alive(State)); + +handle_response(#state{request = Request, status = Status, session = Session, status_line = StatusLine, headers = Headers, body = Body, options = Options, - profile_name = ProfileName}) when Status =/= new -> - ?hcrt("handle response", [{status, Status}, {session, Session}, {status_line, StatusLine}, {profile_name, ProfileName}]), + profile_name = ProfileName} = State) + when Status =/= new -> + + ?hcrd("handle response", [{profile, ProfileName}, + {status, Status}, + {request, Request}, + {session, Session}, + {status_line, StatusLine}]), + handle_cookies(Headers, Request, Options, ProfileName), case httpc_response:result({StatusLine, Headers, Body}, Request) of %% 100-continue continue -> + ?hcrd("handle response - continue", []), %% Send request body {_, RequestBody} = Request#request.content, http_transport:send(socket_type(Session#tcp_session.scheme), Session#tcp_session.socket, RequestBody), %% Wait for next response - http_transport:setopts(socket_type(Session#tcp_session.scheme), - Session#tcp_session.socket, - [{active, once}]), + activate_once(Session), Relaxed = (Request#request.settings)#http_options.relaxed, - {noreply, - State#state{mfa = {httpc_response, parse, - [State#state.max_header_size, - Relaxed]}, - status_line = undefined, - headers = undefined, - body = undefined - }}; + MFA = {httpc_response, parse, + [State#state.max_header_size, Relaxed]}, + {noreply, State#state{mfa = MFA, + status_line = undefined, + headers = undefined, + body = undefined}}; + %% Ignore unexpected 100-continue response and receive the %% actual response that the server will send right away. {ignore, Data} -> + ?hcrd("handle response - ignore", [{data, Data}]), Relaxed = (Request#request.settings)#http_options.relaxed, - NewState = State#state{mfa = - {httpc_response, parse, - [State#state.max_header_size, - Relaxed]}, + MFA = {httpc_response, parse, + [State#state.max_header_size, Relaxed]}, + NewState = State#state{mfa = MFA, status_line = undefined, - headers = undefined, - body = undefined}, + headers = undefined, + body = undefined}, handle_info({httpc_handler, dummy, Data}, NewState); + %% On a redirect or retry the current request becomes %% obsolete and the manager will create a new request %% with the same id as the current. {redirect, NewRequest, Data} -> - ?hcrt("handle response - redirect", [{new_request, NewRequest}, {data, Data}]), + ?hcrt("handle response - redirect", + [{new_request, NewRequest}, {data, Data}]), ok = httpc_manager:redirect_request(NewRequest, ProfileName), handle_queue(State#state{request = undefined}, Data); {retry, TimeNewRequest, Data} -> - ?hcrt("handle response - retry", [{time_new_request, TimeNewRequest}, {data, Data}]), + ?hcrt("handle response - retry", + [{time_new_request, TimeNewRequest}, {data, Data}]), ok = httpc_manager:retry_request(TimeNewRequest, ProfileName), handle_queue(State#state{request = undefined}, Data); {ok, Msg, Data} -> - ?hcrt("handle response - result ok", [{msg, Msg}, {data, Data}]), + ?hcrd("handle response - ok", []), end_stream(StatusLine, Request), NewState = answer_request(Request, Msg, State), handle_queue(NewState, Data); {stop, Msg} -> - ?hcrt("handle response - result stop", [{msg, Msg}]), + ?hcrd("handle response - stop", [{msg, Msg}]), end_stream(StatusLine, Request), NewState = answer_request(Request, Msg, State), {stop, normal, NewState} @@ -990,60 +1155,67 @@ handle_cookies(_,_, #options{cookies = verify}, _) -> ok; handle_cookies(Headers, Request, #options{cookies = enabled}, ProfileName) -> {Host, _ } = Request#request.address, - Cookies = http_cookie:cookies(Headers#http_response_h.other, + Cookies = httpc_cookie:cookies(Headers#http_response_h.other, Request#request.path, Host), httpc_manager:store_cookies(Cookies, Request#request.address, ProfileName). %% This request could not be pipelined or used as sequential keept alive %% queue -handle_queue(State = #state{status = close}, _) -> +handle_queue(#state{status = close} = State, _) -> {stop, normal, State}; -handle_queue(State = #state{status = keep_alive}, Data) -> +handle_queue(#state{status = keep_alive} = State, Data) -> handle_keep_alive_queue(State, Data); -handle_queue(State = #state{status = pipeline}, Data) -> +handle_queue(#state{status = pipeline} = State, Data) -> handle_pipeline(State, Data). -handle_pipeline(State = - #state{status = pipeline, session = Session, +handle_pipeline(#state{status = pipeline, + session = Session, profile_name = ProfileName, - options = #options{pipeline_timeout = TimeOut}}, - Data) -> + options = #options{pipeline_timeout = TimeOut}} = + State, + Data) -> + + ?hcrd("handle pipeline", [{profile, ProfileName}, + {session, Session}, + {timeout, TimeOut}]), + case queue:out(State#state.pipeline) of {empty, _} -> + ?hcrd("epmty pipeline queue", []), + %% The server may choose too teminate an idle pipeline %% in this case we want to receive the close message %% at once and not when trying to pipeline the next %% request. - http_transport:setopts(socket_type(Session#tcp_session.scheme), - Session#tcp_session.socket, - [{active, once}]), + activate_once(Session), + %% If a pipeline that has been idle for some time is not %% closed by the server, the client may want to close it. - NewState = activate_queue_timeout(TimeOut, State), + NewState = activate_queue_timeout(TimeOut, State), NewSession = Session#tcp_session{queue_length = 0}, httpc_manager:insert_session(NewSession, ProfileName), %% Note mfa will be initilized when a new request %% arrives. {noreply, - NewState#state{request = undefined, - mfa = undefined, + NewState#state{request = undefined, + mfa = undefined, status_line = undefined, - headers = undefined, - body = undefined - } - }; + headers = undefined, + body = undefined}}; {{value, NextRequest}, Pipeline} -> case lists:member(NextRequest#request.id, State#state.canceled) of true -> + ?hcrv("next request had been cancelled", []), %% See comment for handle_cast({cancel, RequestId}) {stop, normal, State#state{request = NextRequest#request{from = answer_sent}}}; false -> + ?hcrv("next request", [{request, NextRequest}]), NewSession = Session#tcp_session{queue_length = %% Queue + current @@ -1051,21 +1223,19 @@ handle_pipeline(State = httpc_manager:insert_session(NewSession, ProfileName), Relaxed = (NextRequest#request.settings)#http_options.relaxed, + MFA = {httpc_response, + parse, + [State#state.max_header_size, Relaxed]}, NewState = - State#state{pipeline = Pipeline, - request = NextRequest, - mfa = {httpc_response, parse, - [State#state.max_header_size, - Relaxed]}, + State#state{pipeline = Pipeline, + request = NextRequest, + mfa = MFA, status_line = undefined, - headers = undefined, - body = undefined}, + headers = undefined, + body = undefined}, case Data of <<>> -> - http_transport:setopts( - socket_type(Session#tcp_session.scheme), - Session#tcp_session.socket, - [{active, once}]), + activate_once(Session), {noreply, NewState}; _ -> %% If we already received some bytes of @@ -1076,22 +1246,25 @@ handle_pipeline(State = end end. -handle_keep_alive_queue(State = #state{status = keep_alive, - session = Session, - profile_name = ProfileName, - options = #options{keep_alive_timeout - = TimeOut} - }, - Data) -> +handle_keep_alive_queue( + #state{status = keep_alive, + session = Session, + profile_name = ProfileName, + options = #options{keep_alive_timeout = TimeOut}} = State, + Data) -> + + ?hcrd("handle keep_alive", [{profile, ProfileName}, + {session, Session}, + {timeout, TimeOut}]), + case queue:out(State#state.keep_alive) of {empty, _} -> + ?hcrd("empty keep_alive queue", []), %% The server may choose too terminate an idle keep_alive session %% in this case we want to receive the close message %% at once and not when trying to send the next %% request. - http_transport:setopts(socket_type(Session#tcp_session.scheme), - Session#tcp_session.socket, - [{active, once}]), + activate_once(Session), %% If a keep_alive session has been idle for some time is not %% closed by the server, the client may want to close it. NewState = activate_queue_timeout(TimeOut, State), @@ -1111,25 +1284,25 @@ handle_keep_alive_queue(State = #state{status = keep_alive, case lists:member(NextRequest#request.id, State#state.canceled) of true -> - handle_keep_alive_queue(State#state{keep_alive = - KeepAlive}, Data); + ?hcrv("next request has already been canceled", []), + handle_keep_alive_queue( + State#state{keep_alive = KeepAlive}, Data); false -> + ?hcrv("next request", [{request, NextRequest}]), Relaxed = (NextRequest#request.settings)#http_options.relaxed, + MFA = {httpc_response, parse, + [State#state.max_header_size, Relaxed]}, NewState = - State#state{request = NextRequest, - keep_alive = KeepAlive, - mfa = {httpc_response, parse, - [State#state.max_header_size, - Relaxed]}, + State#state{request = NextRequest, + keep_alive = KeepAlive, + mfa = MFA, status_line = undefined, - headers = undefined, - body = undefined}, + headers = undefined, + body = undefined}, case Data of <<>> -> - http_transport:setopts( - socket_type(Session#tcp_session.scheme), - Session#tcp_session.socket, [{active, once}]), + activate_once(Session), {noreply, NewState}; _ -> %% If we already received some bytes of @@ -1140,11 +1313,6 @@ handle_keep_alive_queue(State = #state{status = keep_alive, end end. -call(Msg, Pid, Timeout) -> - gen_server:call(Pid, Msg, Timeout). - -cast(Msg, Pid) -> - gen_server:cast(Pid, Msg). case_insensitive_header(Str) when is_list(Str) -> http_util:to_lower(Str); @@ -1152,20 +1320,34 @@ case_insensitive_header(Str) when is_list(Str) -> case_insensitive_header(Str) -> Str. -activate_request_timeout(State = #state{request = Request}) -> - Time = (Request#request.settings)#http_options.timeout, - case Time of +activate_once(#tcp_session{scheme = Scheme, socket = Socket}) -> + SocketType = socket_type(Scheme), + http_transport:setopts(SocketType, Socket, [{active, once}]). + +activate_request_timeout( + #state{request = #request{timer = undefined} = Request} = State) -> + Timeout = (Request#request.settings)#http_options.timeout, + case Timeout of infinity -> State; _ -> - Ref = erlang:send_after(Time, self(), - {timeout, Request#request.id}), - State#state - {timers = - #timers{request_timers = - [{Request#request.id, Ref}| - (State#state.timers)#timers.request_timers]}} - end. + ReqId = Request#request.id, + ?hcrt("activate request timer", + [{request_id, ReqId}, + {time_consumed, t() - Request#request.started}, + {timeout, Timeout}]), + Msg = {timeout, ReqId}, + Ref = erlang:send_after(Timeout, self(), Msg), + Request2 = Request#request{timer = Ref}, + ReqTimers = [{Request#request.id, Ref} | + (State#state.timers)#timers.request_timers], + Timers = #timers{request_timers = ReqTimers}, + State#state{request = Request2, timers = Timers} + end; + +%% Timer is already running! This is the case for a redirect or retry +activate_request_timeout(State) -> + State. activate_queue_timeout(infinity, State) -> State; @@ -1187,18 +1369,21 @@ is_keep_alive_enabled_server("HTTP/1.0", is_keep_alive_enabled_server(_,_) -> false. -is_keep_alive_connection(Headers, Session) -> - (not ((Session#tcp_session.client_close) or - httpc_response:is_server_closing(Headers))). - -try_to_enable_pipeline_or_keep_alive(State = - #state{session = Session, - request = #request{method = Method}, - status_line = {Version, _, _}, - headers = Headers, - profile_name = ProfileName}) -> - case (is_keep_alive_enabled_server(Version, Headers) andalso - is_keep_alive_connection(Headers, Session)) of +is_keep_alive_connection(Headers, #tcp_session{client_close = ClientClose}) -> + (not ((ClientClose) orelse httpc_response:is_server_closing(Headers))). + +try_to_enable_pipeline_or_keep_alive( + #state{session = Session, + request = #request{method = Method}, + status_line = {Version, _, _}, + headers = Headers, + profile_name = ProfileName} = State) -> + ?hcrd("try to enable pipeline or keep-alive", + [{version, Version}, + {headers, Headers}, + {session, Session}]), + case is_keep_alive_enabled_server(Version, Headers) andalso + is_keep_alive_connection(Headers, Session) of true -> case (is_pipeline_enabled_client(Session) andalso httpc_request:is_idempotent(Method)) of @@ -1209,15 +1394,16 @@ try_to_enable_pipeline_or_keep_alive(State = httpc_manager:insert_session(Session, ProfileName), %% Make sure type is keep_alive in session %% as it in this case might be pipeline - State#state{status = keep_alive, - session = - Session#tcp_session{type = keep_alive}} + NewSession = Session#tcp_session{type = keep_alive}, + State#state{status = keep_alive, + session = NewSession} end; false -> State#state{status = close} end. -answer_request(Request, Msg, #state{timers = Timers} = State) -> +answer_request(Request, Msg, #state{timers = Timers} = State) -> + ?hcrt("answer request", [{request, Request}]), httpc_response:send(Request#request.from, Msg), RequestTimers = Timers#timers.request_timers, TimerRef = @@ -1253,14 +1439,14 @@ retry_pipeline([Request | PipeLine], case (catch httpc_manager:retry_request(Request, ProfileName)) of ok -> RequestTimers = Timers#timers.request_timers, + ReqId = Request#request.id, TimerRef = - proplists:get_value(Request#request.id, RequestTimers, - undefined), - cancel_timer(TimerRef, {timeout, Request#request.id}), - State#state{timers = Timers#timers{request_timers = - lists:delete({Request#request.id, - TimerRef}, - RequestTimers)}}; + proplists:get_value(ReqId, RequestTimers, undefined), + cancel_timer(TimerRef, {timeout, ReqId}), + NewReqsTimers = lists:delete({ReqId, TimerRef}, RequestTimers), + NewTimers = Timers#timers{request_timers = NewReqsTimers}, + State#state{timers = NewTimers}; + Error -> answer_request(Request#request.from, httpc_response:error(Request, Error), State) @@ -1345,12 +1531,14 @@ socket_type(#request{scheme = https, settings = Settings}) -> socket_type(http) -> ip_comm; socket_type(https) -> - {ssl, []}. %% Dummy value ok for ex setops that does not use this value + {ssl, []}. %% Dummy value ok for ex setopts that does not use this value -start_stream({_Version, _Code, _ReasonPhrase}, _Headers, #request{stream = none} = Request) -> +start_stream({_Version, _Code, _ReasonPhrase}, _Headers, + #request{stream = none} = Request) -> ?hcrt("start stream - none", []), {ok, Request}; -start_stream({_Version, Code, _ReasonPhrase}, Headers, #request{stream = self} = Request) +start_stream({_Version, Code, _ReasonPhrase}, Headers, + #request{stream = self} = Request) when (Code =:= 200) orelse (Code =:= 206) -> ?hcrt("start stream - self", [{code, Code}]), Msg = httpc_response:stream_start(Headers, Request, ignore), @@ -1363,7 +1551,8 @@ start_stream({_Version, Code, _ReasonPhrase}, Headers, Msg = httpc_response:stream_start(Headers, Request, self()), httpc_response:send(Request#request.from, Msg), {ok, Request}; -start_stream({_Version, Code, _ReasonPhrase}, _Headers, #request{stream = Filename} = Request) +start_stream({_Version, Code, _ReasonPhrase}, _Headers, + #request{stream = Filename} = Request) when ((Code =:= 200) orelse (Code =:= 206)) andalso is_list(Filename) -> ?hcrt("start stream", [{code, Code}, {filename, Filename}]), case file:open(Filename, [write, raw, append, delayed_write]) of @@ -1436,6 +1625,7 @@ handle_verbose(trace) -> handle_verbose(_) -> ok. + %%% Normaly I do not comment out code, I throw it away. But this might %%% actually be used one day if ssl is improved. %% send_ssl_tunnel_request(Address, Request = #request{address = {Host, Port}}, @@ -1497,3 +1687,21 @@ handle_verbose(_) -> %% d(_, _, _) -> %% ok. + +call(Msg, Pid) -> + Timeout = infinity, + call(Msg, Pid, Timeout). +call(Msg, Pid, Timeout) -> + gen_server:call(Pid, Msg, Timeout). + +cast(Msg, Pid) -> + gen_server:cast(Pid, Msg). + + +%% to(To, Start) when is_integer(Start) andalso (Start >= 0) -> +%% http_util:timeout(To, Start); +%% to(To, _Start) -> +%% http_util:timeout(To, t()). + +t() -> + http_util:timestamp(). diff --git a/lib/inets/src/http_client/httpc_handler_sup.erl b/lib/inets/src/http_client/httpc_handler_sup.erl index d9edaa0599..2a69fd15d0 100644 --- a/lib/inets/src/http_client/httpc_handler_sup.erl +++ b/lib/inets/src/http_client/httpc_handler_sup.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -23,7 +23,7 @@ %% API -export([start_link/0]). --export([start_child/1]). +-export([start_child/2]). %% Supervisor callback -export([init/1]). @@ -34,25 +34,28 @@ start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []). -start_child(Args) -> +start_child(Options, Profile) -> + Args = [Options, Profile], supervisor:start_child(?MODULE, Args). - + + %%%========================================================================= %%% Supervisor callback %%%========================================================================= init(Args) -> + RestartStrategy = simple_one_for_one, MaxR = 0, MaxT = 3600, - Name = undefined, % As simple_one_for_one is used. + Name = undefined, % As simple_one_for_one is used. StartFunc = {httpc_handler, start_link, Args}, - Restart = temporary, % E.g. should not be restarted - Shutdown = 4000, - Modules = [httpc_handler], - Type = worker, - + Restart = temporary, % E.g. should not be restarted + Shutdown = 4000, + Modules = [httpc_handler], + Type = worker, ChildSpec = {Name, StartFunc, Restart, Shutdown, Type, Modules}, + {ok, {{RestartStrategy, MaxR, MaxT}, [ChildSpec]}}. diff --git a/lib/inets/src/http_client/httpc_internal.hrl b/lib/inets/src/http_client/httpc_internal.hrl index ec709b9860..4d76c4beb3 100644 --- a/lib/inets/src/http_client/httpc_internal.hrl +++ b/lib/inets/src/http_client/httpc_internal.hrl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -46,7 +46,7 @@ %% bool() - true if auto redirect on 30x response autoredirect = true, - %% Ssl socket options + %% ssl socket options ssl = [], %% {User, Password} = {string(), string()} @@ -63,41 +63,45 @@ %%% HTTP Client per profile setting. -record(options, { - proxy = {undefined, []}, % {{ProxyHost, ProxyPort}, [NoProxy]}, - %% 0 means persistent connections are used without pipelining - pipeline_timeout = ?HTTP_PIPELINE_TIMEOUT, - max_pipeline_length = ?HTTP_PIPELINE_LENGTH, - max_keep_alive_length = ?HTTP_KEEP_ALIVE_LENGTH, - keep_alive_timeout = ?HTTP_KEEP_ALIVE_TIMEOUT, % Used when pipeline_timeout = 0 - max_sessions = ?HTTP_MAX_TCP_SESSIONS, - cookies = disabled, % enabled | disabled | verify - verbose = false, - ipfamily = inet, % inet | inet6 | inet6fb4 - ip = default, % specify local interface - port = default % specify local port - } + proxy = {undefined, []}, % {{ProxyHost, ProxyPort}, [NoProxy]}, + %% 0 means persistent connections are used without pipelining + pipeline_timeout = ?HTTP_PIPELINE_TIMEOUT, + max_pipeline_length = ?HTTP_PIPELINE_LENGTH, + max_keep_alive_length = ?HTTP_KEEP_ALIVE_LENGTH, + keep_alive_timeout = ?HTTP_KEEP_ALIVE_TIMEOUT, % Used when pipeline_timeout = 0 + max_sessions = ?HTTP_MAX_TCP_SESSIONS, + cookies = disabled, % enabled | disabled | verify + verbose = false, + ipfamily = inet, % inet | inet6 | inet6fb4 + ip = default, % specify local interface + port = default, % specify local port + socket_opts = [] % other socket options + } ). %%% All data associated to a specific HTTP request -record(request, { - id, % ref() - Request Id - from, % pid() - Caller - redircount = 0,% Number of redirects made for this request - scheme, % http | https - address, % ({Host,Port}) Destination Host and Port - path, % string() - Path of parsed URL - pquery, % string() - Rest of parsed URL - method, % atom() - HTTP request Method - headers, % #http_request_h{} - content, % {ContentType, Body} - Current HTTP request - settings, % #http_options{} - User defined settings - abs_uri, % string() ex: "http://www.erlang.org" - userinfo, % string() - optinal "<userinfo>@<host>:<port>" - stream, % Boolean() - stream async reply? - headers_as_is % Boolean() - workaround for servers that does - %% not honor the http standard, can also be used for testing purposes. - } + id, % ref() - Request Id + from, % pid() - Caller + redircount = 0,% Number of redirects made for this request + scheme, % http | https + address, % ({Host,Port}) Destination Host and Port + path, % string() - Path of parsed URL + pquery, % string() - Rest of parsed URL + method, % atom() - HTTP request Method + headers, % #http_request_h{} + content, % {ContentType, Body} - Current HTTP request + settings, % #http_options{} - User defined settings + abs_uri, % string() ex: "http://www.erlang.org" + userinfo, % string() - optinal "<userinfo>@<host>:<port>" + stream, % Boolean() - stream async reply? + headers_as_is, % Boolean() - workaround for servers that does + % not honor the http standard, can also be used for testing purposes. + started, % integer() > 0 - When we started processing the request + timer, % undefined | ref() + socket_opts % undefined | [socket_option()] + } ). -record(tcp_session, @@ -107,7 +111,7 @@ scheme, % http (HTTP/TCP) | https (HTTP/SSL/TCP) socket, % Open socket, used by connection queue_length = 1, % Current length of pipeline or keep alive queue - type % pipeline | keep_alive (wait for response before sending new request) + type % pipeline | keep_alive (wait for response before sending new request) }). -record(http_cookie, diff --git a/lib/inets/src/http_client/httpc_manager.erl b/lib/inets/src/http_client/httpc_manager.erl index 63b00c7dce..f8fc6322ed 100644 --- a/lib/inets/src/http_client/httpc_manager.erl +++ b/lib/inets/src/http_client/httpc_manager.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2002-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2002-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -25,51 +25,85 @@ -include("http_internal.hrl"). %% Internal Application API --export([start_link/1, start_link/2, request/2, cancel_request/2, - request_canceled/2, retry_request/2, redirect_request/2, - insert_session/2, delete_session/2, set_options/2, store_cookies/3, - cookies/2, session_type/1]). +-export([ + start_link/3, + request/2, + cancel_request/2, + request_canceled/2, + retry_request/2, + redirect_request/2, + insert_session/2, + delete_session/2, + set_options/2, + store_cookies/3, + which_cookies/1, which_cookies/2, + reset_cookies/1, + session_type/1, + info/1 + ]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --record(state, { +-record(state, + { cancel = [], % [{RequestId, HandlerPid, ClientPid}] - handler_db, % ets() - Entry: {Requestid, HandlerPid, ClientPid} - cookie_db, % {ets(), dets()} - {session_cookie_db, cookie_db} + handler_db, % ets() - Entry: #handler_info{} + cookie_db, % cookie_db() session_db, % ets() - Entry: #tcp_session{} profile_name, % atom() options = #options{} }). +-record(handler_info, + { + id, % Id of the request: request_id() + starter, % Pid of the handler starter process (temp): pid() + handler, % Pid of the handler process: pid() + from, % From for the request: from() + state % State of the handler: initiating | operational | canceled + }). + +%% Entries in the handler / request cross-ref table +%% -record(request_info, +%% { +%% id, % Id of the request +%% handler, % Pid of the handler process +%% from, % The From value for the caller +%% mref % Monitor ref for the caller +%% }). + %%==================================================================== %% Internal Application API %%==================================================================== %%-------------------------------------------------------------------- -%% Function: start_link({ProfileName, CookieDir}) -> {ok, Pid} +%% Function: start_link(ProfileName, CookieDir, ManagedHow) -> {ok, Pid} %% %% ProfileName - httpc_manager_<Profile> %% CookieDir - directory() +%% ManagedHow - stand_alone | inets %% -%% Description: Starts the http request manger process. (Started by -%% the intes supervisor.) -%%-------------------------------------------------------------------- -start_link({default, CookieDir}) -> - gen_server:start_link({local, ?MODULE}, ?MODULE, - [?MODULE, {http_default_cookie_db, CookieDir}], - []); -start_link({Profile, CookieDir}) -> - ProfileName = list_to_atom("httpc_manager_" ++ atom_to_list(Profile)), - gen_server:start_link({local, ProfileName}, ?MODULE, - [ProfileName, - {http_default_cookie_db, CookieDir}], []). -start_link({Profile, CookieDir}, stand_alone) -> - ProfileName = list_to_atom("stand_alone_" ++ atom_to_list(Profile)), - gen_server:start_link(?MODULE, [ProfileName, - {http_default_cookie_db, CookieDir}], - []). +%% Description: Starts the http request manager process. +%% (If ManagedHow = inets then started by the inets supervisor.) +%%-------------------------------------------------------------------- + +start_link(Profile, CookieDir, stand_alone) -> + ProfileName = httpc:profile_name("stand_alone_", Profile), + Args = [ProfileName, CookieDir], + Opts = [], + %% Opts = [{debug, [log, statistics]}], + gen_server:start_link(?MODULE, Args, Opts); +start_link(Profile, CookieDir, _) -> + ProfileName = httpc:profile_name(Profile), + Server = {local, ProfileName}, + Args = [ProfileName, CookieDir], + Opts = [], + %% Opts = [{debug, [log, statistics]}], + gen_server:start_link(Server, ?MODULE, Args, Opts). + + %%-------------------------------------------------------------------- %% Function: request(Request, ProfileName) -> %% {ok, Requestid} | {error, Reason} @@ -78,8 +112,10 @@ start_link({Profile, CookieDir}, stand_alone) -> %% %% Description: Sends a request to the httpc manager process. %%-------------------------------------------------------------------- + request(Request, ProfileName) -> - call(ProfileName, {request, Request}, infinity). + call(ProfileName, {request, Request}). + %%-------------------------------------------------------------------- %% Function: retry_request(Request, ProfileName) -> _ @@ -90,9 +126,11 @@ request(Request, ProfileName) -> %% to be called by the httpc handler process if it has to terminate with %% a non empty pipeline. %%-------------------------------------------------------------------- + retry_request(Request, ProfileName) -> cast(ProfileName, {retry_or_redirect_request, Request}). + %%-------------------------------------------------------------------- %% Function: redirect_request(Request, ProfileName) -> _ %% Request = #request{} @@ -102,9 +140,11 @@ retry_request(Request, ProfileName) -> %% manager process, intended to be called by the httpc handler process %% when the automatic redirect option is set. %%-------------------------------------------------------------------- + redirect_request(Request, ProfileName) -> cast(ProfileName, {retry_or_redirect_request, Request}). + %%-------------------------------------------------------------------- %% Function: cancel_request(RequestId, ProfileName) -> ok %% RequestId - ref() @@ -112,8 +152,10 @@ redirect_request(Request, ProfileName) -> %% %% Description: Cancels the request with <RequestId>. %%-------------------------------------------------------------------- + cancel_request(RequestId, ProfileName) -> - call(ProfileName, {cancel_request, RequestId}, infinity). + call(ProfileName, {cancel_request, RequestId}). + %%-------------------------------------------------------------------- %% Function: request_canceled(RequestId, ProfileName) -> ok @@ -123,9 +165,11 @@ cancel_request(RequestId, ProfileName) -> %% Description: Confirms that a request has been canceld. Intended to %% be called by the httpc handler process. %%-------------------------------------------------------------------- + request_canceled(RequestId, ProfileName) -> cast(ProfileName, {request_canceled, RequestId}). + %%-------------------------------------------------------------------- %% Function: insert_session(Session, ProfileName) -> _ %% Session - #tcp_session{} @@ -135,9 +179,12 @@ request_canceled(RequestId, ProfileName) -> %% table <ProfileName>_session_db. Intended to be called by %% the httpc request handler process. %%-------------------------------------------------------------------- + insert_session(Session, ProfileName) -> - Db = list_to_atom(atom_to_list(ProfileName) ++ "_session_db"), - ets:insert(Db, Session). + SessionDbName = session_db_name(ProfileName), + ?hcrt("insert session", [{session, Session}, {profile, ProfileName}]), + ets:insert(SessionDbName, Session). + %%-------------------------------------------------------------------- %% Function: delete_session(SessionId, ProfileName) -> _ @@ -148,9 +195,12 @@ insert_session(Session, ProfileName) -> %% table httpc_manager_session_db_<Profile>. Intended to be called by %% the httpc request handler process. %%-------------------------------------------------------------------- + delete_session(SessionId, ProfileName) -> - Db = list_to_atom(atom_to_list(ProfileName) ++ "_session_db"), - ets:delete(Db, SessionId). + SessionDbName = session_db_name(ProfileName), + ?hcrt("delete session", [{session_is, SessionId}, {profile, ProfileName}]), + ets:delete(SessionDbName, SessionId). + %%-------------------------------------------------------------------- %% Function: set_options(Options, ProfileName) -> ok @@ -166,9 +216,11 @@ delete_session(SessionId, ProfileName) -> %% %% Description: Sets the options to be used by the client. %%-------------------------------------------------------------------- + set_options(Options, ProfileName) -> cast(ProfileName, {set_options, Options}). + %%-------------------------------------------------------------------- %% Function: store_cookies(Cookies, Address, ProfileName) -> ok %% @@ -183,8 +235,22 @@ store_cookies([], _, _) -> store_cookies(Cookies, Address, ProfileName) -> cast(ProfileName, {store_cookies, {Cookies, Address}}). + +%%-------------------------------------------------------------------- +%% Function: reset_cookies(ProfileName) -> void() +%% +%% Url = string() +%% ProfileName = atom() +%% +%% Description: Resets the cookie database +%%-------------------------------------------------------------------- + +reset_cookies(ProfileName) -> + call(ProfileName, reset_cookies). + + %%-------------------------------------------------------------------- -%% Function: cookies(Url, ProfileName) -> ok +%% Function: which_cookies(Url, ProfileName) -> [cookie()] %% %% Url = string() %% ProfileName = atom() @@ -192,8 +258,25 @@ store_cookies(Cookies, Address, ProfileName) -> %% Description: Retrieves the cookies that would be sent when %% requesting <Url>. %%-------------------------------------------------------------------- -cookies(Url, ProfileName) -> - call(ProfileName, {cookies, Url}, infinity). + +which_cookies(ProfileName) -> + call(ProfileName, which_cookies). +which_cookies(Url, ProfileName) -> + call(ProfileName, {which_cookies, Url}). + + +%%-------------------------------------------------------------------- +%% Function: info(ProfileName) -> list() +%% +%% ProfileName = atom() +%% +%% Description: Retrieves various info about the manager and the +%% handlers it manages +%%-------------------------------------------------------------------- + +info(ProfileName) -> + call(ProfileName, info). + %%-------------------------------------------------------------------- %% Function: session_type(Options) -> ok @@ -202,11 +285,13 @@ cookies(Url, ProfileName) -> %% %% Description: Determines if to use pipelined sessions or not. %%-------------------------------------------------------------------- + session_type(#options{pipeline_timeout = 0}) -> keep_alive; session_type(_) -> pipeline. + %%==================================================================== %% gen_server callback functions %%==================================================================== @@ -216,19 +301,46 @@ session_type(_) -> %% {ok, State, Timeout} | ignore |{stop, Reason} %% Description: Initiates the httpc_manger process %%-------------------------------------------------------------------- -init([ProfileName, CookiesConf | _]) -> +init([ProfileName, CookiesDir]) -> process_flag(trap_exit, true), - SessionDb = list_to_atom(atom_to_list(ProfileName) ++ "_session_db"), - ets:new(SessionDb, + ?hcrv("starting", [{profile, ProfileName}]), + case (catch do_init(ProfileName, CookiesDir)) of + {ok, _} = OK -> + ?hcrd("started", [OK]), + OK; + {error, Reason} -> + {stop, Reason}; + Crap -> + {stop, Crap} + end. + + +do_init(ProfileName, CookiesDir) -> + %% Create session db + ?hcrt("create session db", []), + SessionDbName = session_db_name(ProfileName), + ets:new(SessionDbName, [public, set, named_table, {keypos, #tcp_session.id}]), - ?hcri("starting", [{profile, ProfileName}]), - {ok, #state{handler_db = ets:new(handler_db, [protected, set]), - cookie_db = - http_cookie:open_cookie_db({CookiesConf, - http_session_cookie_db}), - session_db = SessionDb, - profile_name = ProfileName - }}. + + %% Create handler db + ?hcrt("create handler/request db", []), + HandlerDbName = handler_db_name(ProfileName), + ets:new(HandlerDbName, + [protected, set, named_table, {keypos, #handler_info.id}]), + + %% Cookie DB + ?hcrt("create cookie db", []), + SessionCookieDbName = session_cookie_db_name(ProfileName), + CookieDbName = cookie_db_name(ProfileName), + CookieDb = httpc_cookie:open_db(CookieDbName, CookiesDir, + SessionCookieDbName), + + State = #state{handler_db = HandlerDbName, + cookie_db = CookieDb, + session_db = SessionDbName, + profile_name = ProfileName}, + {ok, State}. + %%-------------------------------------------------------------------- %% Function: handle_call(Request, From, State) -> {reply, Reply, State} | @@ -239,45 +351,80 @@ init([ProfileName, CookiesConf | _]) -> %% {stop, Reason, State} (terminate/2 is called) %% Description: Handling call messages %%-------------------------------------------------------------------- -handle_call({request, Request}, _, State) -> - ?hcri("request", [{request, Request}]), +handle_call({request, Request}, _From, State) -> + ?hcrv("request", [{request, Request}]), case (catch handle_request(Request, State)) of - {reply, Msg, NewState} -> - {reply, Msg, NewState}; + {ok, ReqId, NewState} -> + {reply, {ok, ReqId}, NewState}; + Error -> - {stop, Error, httpc_response:error(Request, Error), State} + NewError = {error, {failed_process_request, Error}}, + {reply, NewError, State} end; -handle_call({cancel_request, RequestId}, From, State) -> - ?hcri("cancel_request", [{request_id, RequestId}]), +handle_call({cancel_request, RequestId}, From, + #state{handler_db = HandlerDb} = State) -> + ?hcrv("cancel_request", [{request_id, RequestId}]), case ets:lookup(State#state.handler_db, RequestId) of [] -> - ok, %% Nothing to cancel - {reply, ok, State}; - [{_, Pid, _}] -> + ?hcrd("nothing to cancel", []), + Reply = ok, %% Nothing to cancel + {reply, Reply, State}; + + [#handler_info{handler = Pid}] when is_pid(Pid) -> + ?hcrd("found operational handler for this request", + [{handler, Pid}]), httpc_handler:cancel(RequestId, Pid), {noreply, State#state{cancel = - [{RequestId, Pid, From} | + [{RequestId, Pid, From} | + State#state.cancel]}}; + + [#handler_info{starter = Pid, state = HandlerState}] + when is_pid(Pid) -> + ?hcri("found *initiating* handler for this request", + [{starter, Pid}, {state, HandlerState}]), + ets:update_element(HandlerDb, RequestId, + {#handler_info.state, canceled}), + {noreply, State#state{cancel = + [{RequestId, Pid, From} | State#state.cancel]}} + end; -handle_call({cookies, Url}, _, State) -> +handle_call(reset_cookies, _, #state{cookie_db = CookieDb} = State) -> + ?hcrv("reset cookies", []), + httpc_cookie:reset_db(CookieDb), + {reply, ok, State}; + +handle_call(which_cookies, _, #state{cookie_db = CookieDb} = State) -> + ?hcrv("which cookies", []), + CookieHeaders = httpc_cookie:which_cookies(CookieDb), + {reply, CookieHeaders, State}; + +handle_call({which_cookies, Url}, _, #state{cookie_db = CookieDb} = State) -> + ?hcrv("which cookies", [{url, Url}]), case http_uri:parse(Url) of {Scheme, _, Host, Port, Path, _} -> CookieHeaders = - http_cookie:header(Scheme, {Host, Port}, - Path, State#state.cookie_db), + httpc_cookie:header(CookieDb, Scheme, {Host, Port}, Path), {reply, CookieHeaders, State}; Msg -> {reply, Msg, State} end; -handle_call(Msg, From, State) -> - Report = io_lib:format("HTTPC_MANAGER recived unkown call: ~p" - "from: ~p~n", [Msg, From]), - error_logger:error_report(Report), +handle_call(info, _, State) -> + ?hcrv("info", []), + Info = get_manager_info(State), + {reply, Info, State}; + +handle_call(Req, From, #state{profile_name = ProfileName} = State) -> + error_report(ProfileName, + "received unkown request" + "~n Req: ~p" + "~n From: ~p", [Req, From]), {reply, {error, 'API_violation'}, State}. + %%-------------------------------------------------------------------- %% Function: handle_cast(Msg, State) -> {noreply, State} | %% {noreply, State, Timeout} | @@ -286,29 +433,61 @@ handle_call(Msg, From, State) -> %%-------------------------------------------------------------------- handle_cast({retry_or_redirect_request, {Time, Request}}, #state{profile_name = ProfileName} = State) -> - {ok, _} = timer:apply_after(Time, ?MODULE, retry_request, [Request, ProfileName]), - {noreply, State}; + ?hcrv("retry or redirect request", [{time, Time}, {request, Request}]), + case timer:apply_after(Time, ?MODULE, retry_request, + [Request, ProfileName]) of + {ok, _} -> + {noreply, State}; + {error, Reason} -> + error_report(ProfileName, + "failed scheduling retry/redirect request" + "~n Time: ~p" + "~n Request: ~p" + "~n Reason: ~p", [Time, Request, Reason]), + {noreply, State} + end; -handle_cast({retry_or_redirect_request, Request}, State) -> +handle_cast({retry_or_redirect_request, Request}, + #state{profile_name = Profile, + handler_db = HandlerDb} = State) -> + ?hcrv("retry or redirect request", [{request, Request}]), case (catch handle_request(Request, State)) of - {reply, {ok, _}, NewState} -> + {ok, _, NewState} -> {noreply, NewState}; + Error -> - httpc_response:error(Request, Error), - {stop, Error, State} + ReqId = Request#request.id, + error_report(Profile, + "failed to retry or redirect request ~p" + "~n Error: ~p", [ReqId, Error]), + case ets:lookup(HandlerDb, ReqId) of + [#handler_info{from = From}] -> + Error2 = httpc_response:error(Request, Error), + httpc_response:send(From, Error2), + ok; + + _ -> + ok + end, + {noreply, State} end; handle_cast({request_canceled, RequestId}, State) -> + ?hcrv("request canceled", [{request_id, RequestId}]), ets:delete(State#state.handler_db, RequestId), case lists:keysearch(RequestId, 1, State#state.cancel) of {value, Entry = {RequestId, _, From}} -> + ?hcrt("found in cancel", [{from, From}]), gen_server:reply(From, ok), {noreply, State#state{cancel = lists:delete(Entry, State#state.cancel)}}; - _ -> + Else -> + ?hcrt("not found in cancel", [{else, Else}]), {noreply, State} end; + handle_cast({set_options, Options}, State = #state{options = OldOptions}) -> + ?hcrv("set options", [{options, Options}, {old_options, OldOptions}]), NewOptions = #options{proxy = get_proxy(Options, OldOptions), pipeline_timeout = get_pipeline_timeout(Options, OldOptions), @@ -320,7 +499,8 @@ handle_cast({set_options, Options}, State = #state{options = OldOptions}) -> ipfamily = get_ipfamily(Options, OldOptions), ip = get_ip(Options, OldOptions), port = get_port(Options, OldOptions), - verbose = get_verbose(Options, OldOptions) + verbose = get_verbose(Options, OldOptions), + socket_opts = get_socket_opts(Options, OldOptions) }, case {OldOptions#options.verbose, NewOptions#options.verbose} of {Same, Same} -> @@ -345,10 +525,10 @@ handle_cast({store_cookies, {Cookies, _}}, State) -> ok = do_store_cookies(Cookies, State), {noreply, State}; -handle_cast(Msg, State) -> - Report = io_lib:format("HTTPC_MANAGER recived unkown cast: ~p", - [Msg]), - error_logger:error_report(Report), +handle_cast(Msg, #state{profile_name = ProfileName} = State) -> + error_report(ProfileName, + "recived unknown message" + "~n Msg: ~p", [Msg]), {noreply, State}. @@ -359,17 +539,32 @@ handle_cast(Msg, State) -> %% {stop, Reason, State} (terminate/2 is called) %% Description: Handling all non call/cast messages %%--------------------------------------------------------- -handle_info({'EXIT', _, _}, State) -> - %% Handled in DOWN +handle_info({connect_and_send, StarterPid, ReqId, HandlerPid, Res}, State) -> + handle_connect_and_send(StarterPid, ReqId, HandlerPid, Res, State), + {noreply, State}; + +handle_info({failed_starting_handler, StarterPid, ReqId, Res}, State) -> + handle_failed_starting_handler(StarterPid, ReqId, Res, State), + {noreply, State}; + +handle_info({'EXIT', Pid, Reason}, #state{handler_db = HandlerDb} = State) -> + maybe_handle_terminating_starter(Pid, Reason, HandlerDb), {noreply, State}; + handle_info({'DOWN', _, _, Pid, _}, State) -> - ets:match_delete(State#state.handler_db, {'_', Pid, '_'}), + + %% + %% Check what happens to waiting requests! Chall we not send a reply? + %% + + Pattern = #handler_info{handler = Pid, _ = '_'}, + ets:match_delete(State#state.handler_db, Pattern), %% If there where any canceled request, handled by the %% the process that now has terminated, the %% cancelation can be viewed as sucessfull! - NewCanceldList = - lists:foldl(fun(Entry = {_, HandlerPid, From}, Acc) -> + NewCanceledList = + lists:foldl(fun({_, HandlerPid, From} = Entry, Acc) -> case HandlerPid of Pid -> gen_server:reply(From, ok), @@ -378,21 +573,25 @@ handle_info({'DOWN', _, _, Pid, _}, State) -> Acc end end, State#state.cancel, State#state.cancel), - {noreply, State#state{cancel = NewCanceldList}}; -handle_info(Info, State) -> - Report = io_lib:format("Unknown message in " - "httpc_manager:handle_info ~p~n", [Info]), - error_logger:error_report(Report), + {noreply, State#state{cancel = NewCanceledList}}; + +handle_info(Info, #state{profile_name = ProfileName} = State) -> + error_report(ProfileName, + "received unknown info" + "~n Info: ~p", [Info]), {noreply, State}. + + %%-------------------------------------------------------------------- %% Function: terminate(Reason, State) -> _ (ignored by gen_server) %% Description: Shutdown the httpc_handler %%-------------------------------------------------------------------- terminate(_, State) -> - http_cookie:close_cookie_db(State#state.cookie_db), + httpc_cookie:close_db(State#state.cookie_db), ets:delete(State#state.session_db), ets:delete(State#state.handler_db). + %%-------------------------------------------------------------------- %% Func: code_change(_OldVsn, State, Extra) -> {ok, NewState} %% Purpose: Convert process state when code is changed @@ -400,70 +599,217 @@ terminate(_, State) -> code_change(_OldVsn, State, _Extra) -> {ok, State}. + %%-------------------------------------------------------------------- %% Internal functions %%-------------------------------------------------------------------- -handle_request(#request{settings = - #http_options{version = "HTTP/0.9"}} = Request, - State) -> - %% Act as an HTTP/0.9 client that does not know anything - %% about persistent connections - NewRequest = handle_cookies(generate_request_id(Request), State), - NewHeaders = - (NewRequest#request.headers)#http_request_h{connection - = undefined}, - start_handler(NewRequest#request{headers = NewHeaders}, State), - {reply, {ok, NewRequest#request.id}, State}; +get_manager_info(#state{handler_db = HDB, + cookie_db = CDB} = _State) -> + HandlerInfo = get_handler_info(HDB), + CookieInfo = httpc_cookie:which_cookies(CDB), + [{handlers, HandlerInfo}, {cookies, CookieInfo}]. + +get_handler_info(Tab) -> + Pattern = #handler_info{handler = '$1', + state = '$2', + _ = '_'}, + Handlers1 = [{Pid, State} || [Pid, State] <- ets:match(Tab, Pattern)], + F = fun({Pid, State} = Elem, Acc) when State =/= canceled -> + case lists:keymember(Pid, 1, Acc) of + true -> + Acc; + false -> + [Elem | Acc] + end; + (_, Acc) -> + Acc + end, + Handlers2 = lists:foldl(F, [], Handlers1), + Handlers3 = [{Pid, State, httpc_handler:info(Pid)} || + {Pid, State} <- Handlers2], + Handlers3. + + +%% +%% The request handler process is started asynchronously by a +%% "starter process". When that process terminates it sends +%% one of two messages. These ara handled by the two functions +%% below. +%% + +handle_connect_and_send(_StarterPid, ReqId, HandlerPid, Result, + #state{profile_name = Profile, + handler_db = HandlerDb}) -> + case ets:lookup(HandlerDb, ReqId) of + [#handler_info{state = initiating} = HandlerInfo] when Result =:= ok -> + ?hcri("received connect-and-send ack for initiating handler", []), + HandlerInfo2 = HandlerInfo#handler_info{starter = undefined, + handler = HandlerPid, + state = operational}, + ets:insert(HandlerDb, HandlerInfo2), + ok; + + [#handler_info{state = canceled} = HandlerInfo] when Result =:= ok -> + ?hcri("received connect-and-send ack for canceled handler", []), + httpc_handler:cancel(ReqId, HandlerPid), + HandlerInfo2 = HandlerInfo#handler_info{starter = undefined, + handler = HandlerPid}, + ets:insert(HandlerDb, HandlerInfo2), + ok; + + [#handler_info{from = From}] -> + error_report(Profile, + "handler (~p) failed to connect and/or " + "send request ~p" + "~n Error: ~p", [HandlerPid, ReqId, Result]), + ?hcri("received connect-and-send error", [{result, Result}]), + Reason2 = + case Result of + {error, Reason} -> + {failed_connecting, Reason}; + _ -> + {failed_connecting, Result} + end, + DummyReq = #request{id = ReqId}, + httpc_response:send(From, httpc_response:error(DummyReq, Reason2)), + %% gen_server:reply(From, Error), + ets:delete(HandlerDb, ReqId), + ok; + + [] -> + error_report(Profile, + "handler successfully (~p) started for unknown request ~p", + [HandlerPid, ReqId]), + httpc_handler:cancel(ReqId, HandlerPid) + end. + +handle_failed_starting_handler(_StarterPid, ReqId, Error, + #state{profile_name = Profile, + handler_db = HandlerDb}) -> + case ets:lookup(HandlerDb, ReqId) of + [#handler_info{state = canceled, + from = From}] -> + error_report(Profile, + "failed starting handler for request ~p" + "~n Error: ~p", [ReqId, Error]), + request_canceled(Profile, ReqId), % Fake signal from handler + gen_server:reply(From, Error), + ets:delete(HandlerDb, ReqId), + ok; + + [#handler_info{from = From}] -> + error_report(Profile, + "failed starting handler for request ~p" + "~n Error: ~p", [ReqId, Error]), + gen_server:reply(From, Error), + ets:delete(HandlerDb, ReqId), + ok; + + [] -> + error_report(Profile, + "failed starting handler for unknown request ~p" + "~n Error: ~p", [ReqId, Error]), + ok + end. + + +maybe_handle_terminating_starter(MeybeStarterPid, Reason, HandlerDb) -> + Pattern = #handler_info{starter = MeybeStarterPid, _ = '_'}, + case ets:match_object(HandlerDb, Pattern) of + [#handler_info{id = ReqId, from = From, state = initiating}] -> + Error = {error, {failed_starting_request_handler, Reason}}, + gen_server:reply(From, Error), + ets:delete(HandlerDb, ReqId), + ok; + _ -> + ok + end. + + +%% ----- +%% Act as an HTTP/0.9 client that does not know anything +%% about persistent connections handle_request(#request{settings = - #http_options{version = "HTTP/1.0"}} = Request, + #http_options{version = "HTTP/0.9"}} = Request0, State) -> - %% Act as an HTTP/1.0 client that does not - %% use persistent connections - - NewRequest = handle_cookies(generate_request_id(Request), State), - NewHeaders = - (NewRequest#request.headers)#http_request_h{connection - = "close"}, - start_handler(NewRequest#request{headers = NewHeaders}, State), - {reply, {ok, NewRequest#request.id}, State}; - -handle_request(Request, State = #state{options = Options}) -> - - NewRequest = handle_cookies(generate_request_id(Request), State), - SessionType = session_type(Options), - case select_session(Request#request.method, - Request#request.address, - Request#request.scheme, SessionType, State) of + Request1 = handle_cookies(generate_request_id(Request0), State), + Hdrs0 = Request1#request.headers, + Hdrs1 = Hdrs0#http_request_h{connection = undefined}, + Request2 = Request1#request{headers = Hdrs1}, + create_handler_starter(Request2, State), + {ok, Request2#request.id, State}; + +%% ----- +%% Act as an HTTP/1.0 client that does not +%% use persistent connections +handle_request(#request{settings = + #http_options{version = "HTTP/1.0"}} = Request0, + State) -> + Request1 = handle_cookies(generate_request_id(Request0), State), + Hdrs0 = Request1#request.headers, + Hdrs1 = Hdrs0#http_request_h{connection = "close"}, + Request2 = Request1#request{headers = Hdrs1}, + create_handler_starter(Request2, State), + {ok, Request2#request.id, State}; + + +%% ----- +handle_request(#request{method = Method, + address = Address, + scheme = Scheme} = Request0, + #state{options = Opts} = State) -> + Request1 = handle_cookies(generate_request_id(Request0), State), + SessionType = session_type(Opts), + case select_session(Method, Address, Scheme, SessionType, State) of {ok, HandlerPid} -> - pipeline_or_keep_alive(NewRequest, HandlerPid, State); + pipeline_or_keep_alive(Request1, HandlerPid, State); no_connection -> - start_handler(NewRequest, State); - {no_session, OpenSessions} when OpenSessions - < Options#options.max_sessions -> - start_handler(NewRequest, State); + create_handler_starter(Request1, State); + {no_session, OpenSessions} + when OpenSessions < Opts#options.max_sessions -> + create_handler_starter(Request1, State); {no_session, _} -> %% Do not start any more persistent connections %% towards this server. - NewHeaders = - (NewRequest#request.headers)#http_request_h{connection - = "close"}, - start_handler(NewRequest#request{headers = NewHeaders}, State) + Hdrs0 = Request1#request.headers, + Hdrs1 = Hdrs0#http_request_h{connection = "close"}, + Request2 = Request1#request{headers = Hdrs1}, + create_handler_starter(Request2, State) end, - {reply, {ok, NewRequest#request.id}, State}. + {ok, Request1#request.id, State}. -select_session(Method, HostPort, Scheme, SessionTyp, - #state{options = #options{max_pipeline_length = - MaxPipe, + +select_session(Method, HostPort, Scheme, SessionType, + #state{options = #options{max_pipeline_length = MaxPipe, max_keep_alive_length = MaxKeepAlive}, session_db = SessionDb}) -> - case httpc_request:is_idempotent(Method) or (SessionTyp == keep_alive) of + ?hcrd("select session", [{session_type, SessionType}, + {max_pipeline_length, MaxPipe}, + {max_keep_alive_length, MaxKeepAlive}]), + case httpc_request:is_idempotent(Method) orelse + (SessionType =:= keep_alive) of true -> - Candidates = ets:match(SessionDb, - {'_', {HostPort, '$1'}, - false, Scheme, '_', '$2', SessionTyp}), - select_session(Candidates, MaxKeepAlive, MaxPipe, SessionTyp); + %% Look for handlers connecting to this host (HostPort) + %% tcp_session with record name field (tcp_session) and + %% socket fields ignored. The fields id (part of: HostPort), + %% client_close, scheme and type specified. + %% The fields id (part of: HandlerPid) and queue_length + %% specified. + Pattern = #tcp_session{id = {HostPort, '$1'}, + client_close = false, + scheme = Scheme, + socket = '_', + queue_length = '$2', + type = SessionType}, + %% {'_', {HostPort, '$1'}, false, Scheme, '_', '$2', SessionTyp}, + Candidates = ets:match(SessionDb, Pattern), + ?hcrd("select session", [{host_port, HostPort}, + {scheme, Scheme}, + {type, SessionType}, + {candidates, Candidates}]), + select_session(Candidates, MaxKeepAlive, MaxPipe, SessionType); false -> no_connection end. @@ -473,51 +819,102 @@ select_session(Candidates, Max, _, keep_alive) -> select_session(Candidates, _, Max, pipeline) -> select_session(Candidates, Max). +select_session([] = _Candidates, _Max) -> + ?hcrd("select session - no candicate", []), + no_connection; select_session(Candidates, Max) -> - case Candidates of + NewCandidates = + [{Pid, Length} || [Pid, Length] <- Candidates, Length =< Max], + case lists:keysort(2, NewCandidates) of [] -> - no_connection; - _ -> - NewCandidates = - lists:foldl( - fun([Pid, Length], Acc) when Length =< Max -> - [{Pid, Length} | Acc]; - (_, Acc) -> - Acc - end, [], Candidates), - - case lists:keysort(2, NewCandidates) of - [] -> - {no_session, length(Candidates)}; - [{HandlerPid, _} | _] -> - {ok, HandlerPid} - end + {no_session, length(Candidates)}; + [{HandlerPid, _} | _] -> + ?hcrd("select session - found one", [{handler, HandlerPid}]), + {ok, HandlerPid} end. -pipeline_or_keep_alive(Request, HandlerPid, State) -> +pipeline_or_keep_alive(#request{id = Id} = Request, HandlerPid, State) -> + ?hcrd("pipeline of keep-alive", [{id, Id}, {handler, HandlerPid}]), case (catch httpc_handler:send(Request, HandlerPid)) of ok -> - ets:insert(State#state.handler_db, {Request#request.id, - HandlerPid, - Request#request.from}); - _ -> %timeout pipelining failed - start_handler(Request, State) + ?hcrd("pipeline or keep-alive - successfully sent", []), + Entry = #handler_info{id = Id, + handler = HandlerPid, + state = operational}, + ets:insert(State#state.handler_db, Entry); + + _ -> %% timeout pipelining failed + ?hcrd("pipeline or keep-alive - failed sending -> " + "start a new handler", []), + create_handler_starter(Request, State) end. -start_handler(Request, State) -> - {ok, Pid} = - case is_inets_manager() of - true -> - httpc_handler_sup:start_child([Request, State#state.options, - State#state.profile_name]); - false -> - httpc_handler:start_link(Request, State#state.options, - State#state.profile_name) - end, - ets:insert(State#state.handler_db, {Request#request.id, - Pid, Request#request.from}), - erlang:monitor(process, Pid). +create_handler_starter(#request{socket_opts = SocketOpts} = Request, + #state{options = Options} = State) + when is_list(SocketOpts) -> + %% The user provided us with (override) socket options + ?hcrt("create handler starter", [{socket_opts, SocketOpts}, {options, Options}]), + Options2 = Options#options{socket_opts = SocketOpts}, + create_handler_starter(Request#request{socket_opts = undefined}, + State#state{options = Options2}); + +create_handler_starter(#request{id = Id, + from = From} = Request, + #state{profile_name = ProfileName, + options = Options, + handler_db = HandlerDb} = _State) -> + ?hcrv("create handler starter", [{id, Id}, {profile, ProfileName}]), + IsInetsManager = is_inets_manager(), + ManagerPid = self(), + StarterFun = + fun() -> + ?hcrd("handler starter - start", + [{id, Id}, + {profile, ProfileName}, + {inets_manager, IsInetsManager}]), + Result1 = + case IsInetsManager of + true -> + httpc_handler_sup:start_child(Options, + ProfileName); + false -> + httpc_handler:start_link(Options, + ProfileName) + end, + ?hcrd("handler starter - maybe connect and send", + [{id, Id}, {profile, ProfileName}, {result, Result1}]), + case Result1 of + {ok, HandlerPid} -> + Result2 = httpc_handler:connect_and_send(Request, + HandlerPid), + ?hcrd("handler starter - connected and sent", + [{id, Id}, {profile, ProfileName}, + {handler, HandlerPid}, {result, Result2}]), + ConnAndSendMessage = + {connect_and_send, + self(), Id, HandlerPid, Result2}, + ManagerPid ! ConnAndSendMessage; + {error, Reason} -> + StartFailureMessage = + {failed_starting_handler, self(), Id, Reason}, + ManagerPid ! StartFailureMessage; + _ -> + StartFailureMessage = + {failed_starting_handler, self(), Id, Result1}, + ManagerPid ! StartFailureMessage + end + end, + Starter = erlang:spawn_link(StarterFun), + ?hcrd("create handler starter - started", [{id, Id}, {starter, Starter}]), + Entry = #handler_info{id = Id, + starter = Starter, + from = From, + state = initiating}, + ets:insert(HandlerDb, Entry), + ok. + + is_inets_manager() -> case get('$ancestors') of [httpc_profile_sup | _] -> @@ -532,32 +929,55 @@ generate_request_id(Request) -> RequestId = make_ref(), Request#request{id = RequestId}; _ -> - %% This is an automatic redirect or a retryed pipelined - %% request keep the old id. + %% This is an automatic redirect or a retryed pipelined request + %% => keep the old id. Request end. handle_cookies(Request, #state{options = #options{cookies = disabled}}) -> Request; -handle_cookies(Request = #request{scheme = Scheme, address = Address, - path = Path, headers = - Headers = #http_request_h{other = Other}}, - #state{cookie_db = Db}) -> - case http_cookie:header(Scheme, Address, Path, Db) of +handle_cookies( + #request{scheme = Scheme, + address = Address, + path = Path, + headers = #http_request_h{other = Other} = Hdrs} = Request, + #state{cookie_db = CookieDb}) -> + case httpc_cookie:header(CookieDb, Scheme, Address, Path) of {"cookie", ""} -> Request; CookieHeader -> - NewHeaders = - Headers#http_request_h{other = [CookieHeader | Other]}, + NewHeaders = Hdrs#http_request_h{other = [CookieHeader | Other]}, Request#request{headers = NewHeaders} end. do_store_cookies([], _) -> ok; -do_store_cookies([Cookie | Cookies], State) -> - ok = http_cookie:insert(Cookie, State#state.cookie_db), +do_store_cookies([Cookie | Cookies], #state{cookie_db = CookieDb} = State) -> + ok = httpc_cookie:insert(CookieDb, Cookie), do_store_cookies(Cookies, State). + + +session_db_name(ProfileName) -> + make_db_name(ProfileName, "__session_db"). + +cookie_db_name(ProfileName) -> + make_db_name(ProfileName, "__cookie_db"). + +session_cookie_db_name(ProfileName) -> + make_db_name(ProfileName, "__session_cookie_db"). + +handler_db_name(ProfileName) -> + make_db_name(ProfileName, "__handler_db"). + +make_db_name(ProfileName, Post) -> + list_to_atom(atom_to_list(ProfileName) ++ Post). + + + +call(ProfileName, Msg) -> + Timeout = infinity, + call(ProfileName, Msg, Timeout). call(ProfileName, Msg, Timeout) -> gen_server:call(ProfileName, Msg, Timeout). @@ -611,6 +1031,9 @@ get_port(Opts, #options{port = Default}) -> get_verbose(Opts, #options{verbose = Default}) -> proplists:get_value(verbose, Opts, Default). +get_socket_opts(Opts, #options{socket_opts = Default}) -> + proplists:get_value(socket_opts, Opts, Default). + handle_verbose(debug) -> dbg:p(self(), [call]), @@ -621,6 +1044,12 @@ handle_verbose(trace) -> handle_verbose(_) -> ok. + +error_report(Profile, F, A) -> + Report = io_lib:format("HTTPC-MANAGER<~p> " ++ F ++ "~n", [Profile | A]), + error_logger:error_report(Report). + + %% d(F) -> %% d(F, []). diff --git a/lib/inets/src/http_client/httpc_profile_sup.erl b/lib/inets/src/http_client/httpc_profile_sup.erl index 2351083435..29f86aa373 100644 --- a/lib/inets/src/http_client/httpc_profile_sup.erl +++ b/lib/inets/src/http_client/httpc_profile_sup.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -28,6 +28,7 @@ %% Supervisor callback -export([init/1]). + %%%========================================================================= %%% API %%%========================================================================= @@ -39,7 +40,8 @@ start_child(PropList) -> undefined -> {error, no_profile}; Profile -> - Dir = proplists:get_value(data_dir, PropList, only_session_cookies), + Dir = + proplists:get_value(data_dir, PropList, only_session_cookies), Spec = httpc_child_spec(Profile, Dir), supervisor:start_child(?MODULE, Spec) end. @@ -63,12 +65,12 @@ stop_child(Profile) -> end. id(Profile) -> - DefaultProfile = http:default_profile(), + DefaultProfile = httpc:default_profile(), case Profile of DefaultProfile -> httpc_manager; _ -> - {http, Profile} + {httpc, Profile} end. @@ -98,7 +100,7 @@ child_spec([{httpc, PropList} | Rest], Acc) when is_list(PropList) -> httpc_child_spec(Profile, Dir) -> Name = id(Profile), - StartFunc = {httpc_manager, start_link, [{Profile, Dir}]}, + StartFunc = {httpc_manager, start_link, [Profile, Dir, inets]}, Restart = permanent, Shutdown = 4000, Modules = [httpc_manager], diff --git a/lib/inets/src/http_client/httpc_request.erl b/lib/inets/src/http_client/httpc_request.erl index 3d66638d66..55e0af4b42 100644 --- a/lib/inets/src/http_client/httpc_request.erl +++ b/lib/inets/src/http_client/httpc_request.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -39,14 +39,47 @@ %% %% Description: Composes and sends a HTTP-request. %%------------------------------------------------------------------------- -send(SendAddr, #request{method = Method, scheme = Scheme, - path = Path, pquery = Query, headers = Headers, - content = Content, address = Address, - abs_uri = AbsUri, headers_as_is = HeadersAsIs, - settings = HttpOptions, - userinfo = UserInfo}, - Socket) -> +send(SendAddr, #request{scheme = Scheme, socket_opts = SocketOpts} = Request, + Socket) + when is_list(SocketOpts) -> + SocketType = socket_type(Scheme), + case http_transport:setopts(SocketType, Socket, SocketOpts) of + ok -> + send(SendAddr, Socket, SocketType, + Request#request{socket_opts = undefined}); + {error, Reason} -> + {error, {setopts_failed, Reason}} + end; +send(SendAddr, #request{scheme = Scheme} = Request, Socket) -> + SocketType = socket_type(Scheme), + send(SendAddr, Socket, SocketType, Request). + +send(SendAddr, Socket, SocketType, + #request{method = Method, + path = Path, + pquery = Query, + headers = Headers, + content = Content, + address = Address, + abs_uri = AbsUri, + headers_as_is = HeadersAsIs, + settings = HttpOptions, + userinfo = UserInfo}) -> + ?hcrt("send", + [{send_addr, SendAddr}, + {socket, Socket}, + {method, Method}, + {path, Path}, + {pquery, Query}, + {headers, Headers}, + {content, Content}, + {address, Address}, + {abs_uri, AbsUri}, + {headers_as_is, HeadersAsIs}, + {settings, HttpOptions}, + {userinfo, UserInfo}]), + TmpHeaders = handle_user_info(UserInfo, Headers), {TmpHeaders2, Body} = @@ -70,9 +103,14 @@ send(SendAddr, #request{method = Method, scheme = Scheme, Version = HttpOptions#http_options.version, Message = [method(Method), " ", Uri, " ", - version(Version), ?CRLF, headers(FinalHeaders, Version), ?CRLF, Body], + version(Version), ?CRLF, + headers(FinalHeaders, Version), ?CRLF, Body], + + ?hcrd("send", [{message, Message}]), - http_transport:send(socket_type(Scheme), Socket, lists:append(Message)). + http_transport:send(SocketType, Socket, lists:append(Message)). + + %%------------------------------------------------------------------------- %% is_idempotent(Method) -> @@ -123,7 +161,7 @@ is_client_closing(Headers) -> %%% Internal functions %%%======================================================================== post_data(Method, Headers, {ContentType, Body}, HeadersAsIs) - when Method == post; Method == put -> + when (Method =:= post) orelse (Method =:= put) -> ContentLength = body_length(Body), NewBody = case Headers#http_request_h.expect of "100-continue" -> diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl index e2ba66f730..df7d40a33e 100644 --- a/lib/inets/src/http_client/httpc_response.erl +++ b/lib/inets/src/http_client/httpc_response.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -132,8 +132,13 @@ result(Response = {{_,Code,_}, _, _}, Request) when (Code div 100) =:= 5 -> result(Response, Request) -> transparent(Response, Request). -send(To, Msg) -> - To ! {http, Msg}. +send(Receiver, Msg) when is_pid(Receiver) -> + Receiver ! {http, Msg}; +send(Receiver, Msg) when is_function(Receiver) -> + (catch Receiver(Msg)); +send({Module, Function, Args}, Msg) -> + (catch apply(Module, Function, [Msg | Args])). + %%%======================================================================== %%% Internal functions diff --git a/lib/inets/src/http_lib/Makefile b/lib/inets/src/http_lib/Makefile index 27e7ee65c5..7f4c92861c 100644 --- a/lib/inets/src/http_lib/Makefile +++ b/lib/inets/src/http_lib/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # @@ -22,6 +22,7 @@ include $(ERL_TOP)/make/target.mk EBIN = ../../ebin include $(ERL_TOP)/make/$(TARGET)/otp.mk + # ---------------------------------------------------- # Application version # ---------------------------------------------------- @@ -29,10 +30,12 @@ include ../../vsn.mk VSN = $(INETS_VSN) + # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + # ---------------------------------------------------- # Target Specs @@ -50,10 +53,12 @@ ERL_FILES = $(MODULES:%=%.erl) TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' + # ---------------------------------------------------- # FLAGS @@ -82,6 +87,7 @@ clean: docs: + # ---------------------------------------------------- # Release Target # ---------------------------------------------------- @@ -96,6 +102,8 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" + diff --git a/lib/inets/src/http_lib/http_chunk.erl b/lib/inets/src/http_lib/http_chunk.erl index cd20dce9d5..621bc68eae 100644 --- a/lib/inets/src/http_lib/http_chunk.erl +++ b/lib/inets/src/http_lib/http_chunk.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% Description: Implements chunked transfer encoding see RFC2616 section @@ -186,13 +186,6 @@ decode_data(ChunkSize, TotalChunk, Info = {MaxBodySize, BodySoFar, AccLength, MaxHeaderSize, Stream}) when ChunkSize =< size(TotalChunk) -> case TotalChunk of - %% Potential last chunk - <<_:ChunkSize/binary, ?CR, ?LF, "0">> -> - {?MODULE, decode_data, [ChunkSize, TotalChunk, Info]}; - <<_:ChunkSize/binary, ?CR, ?LF, "0", ?CR>> -> - {?MODULE, decode_data, [ChunkSize, TotalChunk, Info]}; - <<_:ChunkSize/binary, ?CR, ?LF>> -> - {?MODULE, decode_data, [ChunkSize, TotalChunk, Info]}; %% Last chunk <<Data:ChunkSize/binary, ?CR, ?LF, "0", ";">> -> %% Note ignore_extensions will call decode_trailer/1 @@ -223,6 +216,10 @@ decode_data(ChunkSize, TotalChunk, NewBody, integer_to_list(AccLength)); %% There are more chunks, so here we go agin... + <<Data:ChunkSize/binary, ?CR, ?LF>> -> + {NewBody, NewStream} = + stream(<<BodySoFar/binary, Data/binary>>, Stream), + {?MODULE, decode_size, [<<>>, [], {MaxBodySize, NewBody, AccLength, MaxHeaderSize, NewStream}]}; <<Data:ChunkSize/binary, ?CR, ?LF, Rest/binary>> when (AccLength < MaxBodySize) or (MaxBodySize == nolimit) -> {NewBody, NewStream} = diff --git a/lib/inets/src/http_lib/http_transport.erl b/lib/inets/src/http_lib/http_transport.erl index 8100d7183a..7c2ac626e6 100644 --- a/lib/inets/src/http_lib/http_transport.erl +++ b/lib/inets/src/http_lib/http_transport.erl @@ -1,32 +1,48 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -% + -module(http_transport). % Internal application API --export([start/1, connect/3, connect/4, listen/2, listen/3, - accept/2, accept/3, close/2, - send/3, controlling_process/3, setopts/3, - peername/2, resolve/0]). +-export([ + start/1, + connect/3, connect/4, + listen/2, listen/3, + accept/2, accept/3, + close/2, + send/3, + controlling_process/3, + setopts/3, getopts/2, getopts/3, + getstat/2, + peername/2, sockname/2, + resolve/0 + ]). -export([negotiate/3]). +-include("inets_internal.hrl"). +-define(SERVICE, httpl). +-define(hlri(Label, Content), ?report_important(Label, ?SERVICE, Content)). +-define(hlrv(Label, Content), ?report_verbose(Label, ?SERVICE, Content)). +-define(hlrd(Label, Content), ?report_debug(Label, ?SERVICE, Content)). +-define(hlrt(Label, Content), ?report_trace(Label, ?SERVICE, Content)). + %%%========================================================================= %%% Internal application API @@ -77,14 +93,22 @@ connect(SocketType, Address, Opts) -> connect(ip_comm = _SocketType, {Host, Port}, Opts0, Timeout) when is_list(Opts0) -> Opts = [binary, {packet, 0}, {active, false}, {reuseaddr, true} | Opts0], + ?hlrt("connect using gen_tcp", + [{host, Host}, {port, Port}, {opts, Opts}, {timeout, Timeout}]), gen_tcp:connect(Host, Port, Opts, Timeout); connect({ssl, SslConfig}, {Host, Port}, _, Timeout) -> Opts = [binary, {active, false}] ++ SslConfig, + ?hlrt("connect using ssl", + [{host, Host}, {port, Port}, {ssl_config, SslConfig}, + {timeout, Timeout}]), ssl:connect(Host, Port, Opts, Timeout); connect({erl_ssl, SslConfig}, {Host, Port}, _, Timeout) -> Opts = [binary, {active, false}, {ssl_imp, new}] ++ SslConfig, + ?hlrt("connect using erl_ssl", + [{host, Host}, {port, Port}, {ssl_config, SslConfig}, + {timeout, Timeout}]), ssl:connect(Host, Port, Opts, Timeout). @@ -209,6 +233,7 @@ accept(ip_comm, ListenSocket, Timeout) -> accept({ssl,_SSLConfig}, ListenSocket, Timeout) -> ssl:transport_accept(ListenSocket, Timeout). + %%------------------------------------------------------------------------- %% controlling_process(SocketType, Socket, NewOwner) -> ok | {error, Reason} %% SocketType = ip_comm | {ssl, _} @@ -222,6 +247,7 @@ controlling_process(ip_comm, Socket, NewOwner) -> controlling_process({ssl, _}, Socket, NewOwner) -> ssl:controlling_process(Socket, NewOwner). + %%------------------------------------------------------------------------- %% setopts(SocketType, Socket, Options) -> ok | {error, Reason} %% SocketType = ip_comm | {ssl, _} @@ -231,10 +257,62 @@ controlling_process({ssl, _}, Socket, NewOwner) -> %% gen_tcp or ssl. %%------------------------------------------------------------------------- setopts(ip_comm, Socket, Options) -> - inet:setopts(Socket,Options); + ?hlrt("ip_comm setopts", [{socket, Socket}, {options, Options}]), + inet:setopts(Socket, Options); setopts({ssl, _}, Socket, Options) -> + ?hlrt("ssl setopts", [{socket, Socket}, {options, Options}]), ssl:setopts(Socket, Options). + +%%------------------------------------------------------------------------- +%% getopts(SocketType, Socket [, Opts]) -> ok | {error, Reason} +%% SocketType = ip_comm | {ssl, _} +%% Socket = socket() +%% Opts = socket_options() +%% Description: Gets the values for some options. +%%------------------------------------------------------------------------- +getopts(SocketType, Socket) -> + Opts = [packet, packet_size, recbuf, sndbuf, priority, tos, send_timeout], + getopts(SocketType, Socket, Opts). + +getopts(ip_comm, Socket, Options) -> + ?hlrt("ip_comm getopts", [{socket, Socket}, {options, Options}]), + case inet:getopts(Socket, Options) of + {ok, SocketOpts} -> + SocketOpts; + {error, _} -> + [] + end; +getopts({ssl, _}, Socket, Options) -> + ?hlrt("ssl getopts", [{socket, Socket}, {options, Options}]), + case ssl:getopts(Socket, Options) of + {ok, SocketOpts} -> + SocketOpts; + {error, _} -> + [] + end. + + +%%------------------------------------------------------------------------- +%% getstat(SocketType, Socket) -> socket_stats() +%% SocketType = ip_comm | {ssl, _} +%% Socket = socket() +%% socket_stats() = list() +%% Description: Gets the socket stats values for the socket +%%------------------------------------------------------------------------- +getstat(ip_comm = _SocketType, Socket) -> + ?hlrt("ip_comm getstat", [{socket, Socket}]), + case inet:getstat(Socket) of + {ok, Stats} -> + Stats; + {error, _} -> + [] + end; +getstat({ssl, _} = _SocketType, _Socket) -> + %% ?hlrt("ssl getstat", [{socket, Socket}]), + []. + + %%------------------------------------------------------------------------- %% send(RequestOrSocketType, Socket, Message) -> ok | {error, Reason} %% SocketType = ip_comm | {ssl, _} @@ -247,6 +325,7 @@ send(ip_comm, Socket, Message) -> send({ssl, _}, Socket, Message) -> ssl:send(Socket, Message). + %%------------------------------------------------------------------------- %% close(SocketType, Socket) -> ok | {error, Reason} %% SocketType = ip_comm | {ssl, _} @@ -260,9 +339,11 @@ close({ssl, _}, Socket) -> ssl:close(Socket). %%------------------------------------------------------------------------- -%% peername(SocketType, Socket) -> ok | {error, Reason} +%% peername(SocketType, Socket) -> {Port, SockName} %% SocketType = ip_comm | {ssl, _} %% Socket = socket() +%% Port = integer() (-1 if error occured) +%% PeerName = string() %% %% Description: Returns the address and port for the other end of a %% connection, usning either gen_tcp or ssl. @@ -297,6 +378,48 @@ peername({ssl, _}, Socket) -> {-1, "unknown"} end. + +%%------------------------------------------------------------------------- +%% sockname(SocketType, Socket) -> {Port, SockName} +%% SocketType = ip_comm | {ssl, _} +%% Socket = socket() +%% Port = integer() (-1 if error occured) +%% SockName = string() +%% +%% Description: Returns the address and port for the local (our) end +%% other end of connection, using either gen_tcp or ssl. +%%------------------------------------------------------------------------- +sockname(ip_comm, Socket) -> + case inet:sockname(Socket) of + {ok,{{A, B, C, D}, Port}} -> + SockName = integer_to_list(A)++"."++integer_to_list(B)++"."++ + integer_to_list(C)++"."++integer_to_list(D), + {Port, SockName}; + {ok,{{A, B, C, D, E, F, G, H}, Port}} -> + SockName = http_util:integer_to_hexlist(A) ++ ":"++ + http_util:integer_to_hexlist(B) ++ ":" ++ + http_util:integer_to_hexlist(C) ++ ":" ++ + http_util:integer_to_hexlist(D) ++ ":" ++ + http_util:integer_to_hexlist(E) ++ ":" ++ + http_util:integer_to_hexlist(F) ++ ":" ++ + http_util:integer_to_hexlist(G) ++":"++ + http_util:integer_to_hexlist(H), + {Port, SockName}; + {error, _} -> + {-1, "unknown"} + end; + +sockname({ssl, _}, Socket) -> + case ssl:sockname(Socket) of + {ok,{{A, B, C, D}, Port}} -> + SockName = integer_to_list(A)++"."++integer_to_list(B)++"."++ + integer_to_list(C)++"."++integer_to_list(D), + {Port, SockName}; + {error, _} -> + {-1, "unknown"} + end. + + %%------------------------------------------------------------------------- %% resolve() -> HostName %% HostName = string() diff --git a/lib/inets/src/http_lib/http_util.erl b/lib/inets/src/http_lib/http_util.erl index b03b780cf8..ddb58c7116 100644 --- a/lib/inets/src/http_lib/http_util.erl +++ b/lib/inets/src/http_lib/http_util.erl @@ -1,27 +1,33 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% -module(http_util). --export([to_upper/1, to_lower/1, convert_netscapecookie_date/1, +-export([ + to_upper/1, to_lower/1, + convert_netscapecookie_date/1, hexlist_to_integer/1, integer_to_hexlist/1, - convert_month/1, is_hostname/1]). + convert_month/1, + is_hostname/1, + timestamp/0, timeout/2 + ]). + %%%========================================================================= %%% Internal application API @@ -100,6 +106,21 @@ convert_month("Dec") -> 12. is_hostname(Dest) -> inet_parse:domain(Dest). + +timestamp() -> + {A,B,C} = os:timestamp(), + A*1000000000+B*1000+(C div 1000). + +timeout(Timeout, Started) -> + %% NewTimeout = Timeout - (timestamp() - Started), + case Timeout - (timestamp() - Started) of + NewTimeout when Timeout > 0 -> + NewTimeout; + _ -> + 0 + end. + + %%%======================================================================== %%% Internal functions %%%======================================================================== diff --git a/lib/inets/src/http_server/Makefile b/lib/inets/src/http_server/Makefile index 4bbd23df3f..ce1405011e 100644 --- a/lib/inets/src/http_server/Makefile +++ b/lib/inets/src/http_server/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # @@ -33,7 +33,7 @@ VSN = $(INETS_VSN) # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) # ---------------------------------------------------- @@ -92,7 +92,7 @@ TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' # ---------------------------------------------------- @@ -133,6 +133,7 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" diff --git a/lib/inets/src/http_server/httpd.erl b/lib/inets/src/http_server/httpd.erl index 554f162fc5..8fe54ccef6 100644 --- a/lib/inets/src/http_server/httpd.erl +++ b/lib/inets/src/http_server/httpd.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -358,7 +358,7 @@ foreach([KeyValue|Rest]) -> get_addr_and_port(ConfigFile) -> case httpd_conf:load(ConfigFile) of {ok, ConfigList} -> - case httpd_conf:validate_properties(ConfigList) of + case (catch httpd_conf:validate_properties(ConfigList)) of {ok, Config} -> Address = proplists:get_value(bind_address, Config, any), Port = proplists:get_value(port, Config, 80), @@ -506,7 +506,7 @@ get_status(Addr,Port,Timeout) when is_integer(Port) -> end. do_reload_config(ConfigList, Mode) -> - case httpd_conf:validate_properties(ConfigList) of + case (catch httpd_conf:validate_properties(ConfigList)) of {ok, Config} -> Address = proplists:get_value(bind_address, Config, any), Port = proplists:get_value(port, Config, 80), diff --git a/lib/inets/src/http_server/httpd_conf.erl b/lib/inets/src/http_server/httpd_conf.erl index 9c93e2c5fe..3e498d1db7 100644 --- a/lib/inets/src/http_server/httpd_conf.erl +++ b/lib/inets/src/http_server/httpd_conf.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -864,17 +864,22 @@ load_traverse(Line, [Context|Contexts], [Module|Modules], NewContexts, {'EXIT', {undef, _}} -> ?hdrt("does not implement load", []), load_traverse(Line, Contexts, Modules, - [Context|NewContexts], ConfigList,yes); + [Context|NewContexts], ConfigList, yes); {'EXIT', Reason} -> error_logger:error_report({'EXIT', Reason}), load_traverse(Line, Contexts, Modules, [Context|NewContexts], ConfigList, State); + ok -> + ?hdrt("line processed", []), + load_traverse(Line, Contexts, Modules, + [Context|NewContexts], ConfigList, yes); + {ok, NewContext} -> ?hdrt("line processed", [{new_context, NewContext}]), load_traverse(Line, Contexts, Modules, - [NewContext|NewContexts], ConfigList,yes); + [NewContext|NewContexts], ConfigList, yes); {ok, NewContext, ConfigEntry} when is_tuple(ConfigEntry) -> ?hdrt("line processed", diff --git a/lib/inets/src/http_server/httpd_instance_sup.erl b/lib/inets/src/http_server/httpd_instance_sup.erl index 3b5464132c..0aaeb838c2 100644 --- a/lib/inets/src/http_server/httpd_instance_sup.erl +++ b/lib/inets/src/http_server/httpd_instance_sup.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2001-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2001-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -37,7 +37,7 @@ %%% Internal Application API %%%========================================================================= start_link([{_, _}| _] = Config, AcceptTimeout, Debug) -> - case httpd_conf:validate_properties(Config) of + case (catch httpd_conf:validate_properties(Config)) of {ok, Config2} -> Address = proplists:get_value(bind_address, Config2), Port = proplists:get_value(port, Config2), @@ -66,7 +66,7 @@ start_link(ConfigFile, AcceptTimeout, Debug) -> start_link([{_, _}| _] = Config, AcceptTimeout, ListenInfo, Debug) -> - case httpd_conf:validate_properties(Config) of + case (catch httpd_conf:validate_properties(Config)) of {ok, Config2} -> Address = proplists:get_value(bind_address, Config2), Port = proplists:get_value(port, Config2), @@ -154,7 +154,7 @@ make_name(Address,Port) -> file_2_config(ConfigFile) -> case httpd_conf:load(ConfigFile) of {ok, ConfigList} -> - case httpd_conf:validate_properties(ConfigList) of + case (catch httpd_conf:validate_properties(ConfigList)) of {ok, Config} -> Address = proplists:get_value(bind_address, ConfigList), Port = proplists:get_value(port, ConfigList), diff --git a/lib/inets/src/http_server/httpd_request.erl b/lib/inets/src/http_server/httpd_request.erl index ad2cc4bda3..8eee08e766 100644 --- a/lib/inets/src/http_server/httpd_request.erl +++ b/lib/inets/src/http_server/httpd_request.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -68,10 +68,11 @@ body_data(Headers, Body) -> {binary_to_list(BodyThisReq), Next} end. + %%------------------------------------------------------------------------- %% validate(Method, Uri, Version) -> ok | {error, {bad_request, Reason} | %% {error, {not_supported, {Method, Uri, Version}} -%% Method = "HEAD" | "GET" | "POST" | "TRACE" +%% Method = "HEAD" | "GET" | "POST" | "TRACE" | "PUT" | "DELETE" %% Uri = uri() %% Version = "HTTP/N.M" %% Description: Checks that HTTP-request-line is valid. @@ -84,6 +85,10 @@ validate("GET", Uri, "HTTP/0.9") -> validate_uri(Uri); validate("GET", Uri, "HTTP/1." ++ _N) -> validate_uri(Uri); +validate("PUT", Uri, "HTTP/1." ++ _N) -> + validate_uri(Uri); +validate("DELETE", Uri, "HTTP/1." ++ _N) -> + validate_uri(Uri); validate("POST", Uri, "HTTP/1." ++ _N) -> validate_uri(Uri); validate("TRACE", Uri, "HTTP/1." ++ N) when hd(N) >= $1 -> diff --git a/lib/inets/src/http_server/httpd_sup.erl b/lib/inets/src/http_server/httpd_sup.erl index fc41994727..3399f78b53 100644 --- a/lib/inets/src/http_server/httpd_sup.erl +++ b/lib/inets/src/http_server/httpd_sup.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -169,7 +169,7 @@ httpd_child_spec([Value| _] = Config, AcceptTimeout, Debug) httpd_child_spec(ConfigFile, AcceptTimeout, Debug) -> case httpd_conf:load(ConfigFile) of {ok, ConfigList} -> - case httpd_conf:validate_properties(ConfigList) of + case (catch httpd_conf:validate_properties(ConfigList)) of {ok, Config} -> Address = proplists:get_value(bind_address, Config, any), Port = proplists:get_value(port, Config, 80), diff --git a/lib/inets/src/http_server/mod_alias.erl b/lib/inets/src/http_server/mod_alias.erl index 7073f5405d..ec0a12242f 100644 --- a/lib/inets/src/http_server/mod_alias.erl +++ b/lib/inets/src/http_server/mod_alias.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -28,44 +28,51 @@ path/3]). -include("httpd.hrl"). +-include("httpd_internal.hrl"). -define(VMODULE,"ALIAS"). %% do -do(Info) -> - case proplists:get_value(status, Info#mod.data) of +do(#mod{data = Data} = Info) -> + ?hdrt("do", []), + case proplists:get_value(status, Data) of %% A status code has been generated! {_StatusCode, _PhraseArgs, _Reason} -> - {proceed,Info#mod.data}; + {proceed, Data}; %% No status code has been generated! undefined -> - case proplists:get_value(response, Info#mod.data) of + case proplists:get_value(response, Data) of %% No response has been generated! undefined -> do_alias(Info); %% A response has been generated or sent! _Response -> - {proceed, Info#mod.data} + {proceed, Data} end end. -do_alias(Info) -> - {ShortPath, Path, AfterPath} = - real_name(Info#mod.config_db, - Info#mod.request_uri, - httpd_util:multi_lookup(Info#mod.config_db,alias)), +do_alias(#mod{config_db = ConfigDB, + request_uri = ReqURI, + data = Data}) -> + {ShortPath, Path, AfterPath} = + real_name(ConfigDB, ReqURI, which_alias(ConfigDB)), + ?hdrt("real name", + [{request_uri, ReqURI}, + {short_path, ShortPath}, + {path, Path}, + {after_path, AfterPath}]), %% Relocate if a trailing slash is missing else proceed! LastChar = lists:last(ShortPath), case file:read_file_info(ShortPath) of - {ok, FileInfo} when FileInfo#file_info.type == directory, - LastChar /= $/ -> - ServerName = httpd_util:lookup(Info#mod.config_db, server_name), - Port = port_string(httpd_util:lookup(Info#mod.config_db,port, 80)), - URL = "http://" ++ ServerName ++ Port ++ - Info#mod.request_uri ++ "/", + {ok, FileInfo} when ((FileInfo#file_info.type =:= directory) andalso + (LastChar =/= $/)) -> + ?hdrt("directory and last-char is a /", []), + ServerName = which_server_name(ConfigDB), + Port = port_string( which_port(ConfigDB) ), + URL = "http://" ++ ServerName ++ Port ++ ReqURI ++ "/", ReasonPhrase = httpd_util:reason_phrase(301), - Message = httpd_util:message(301, URL, Info#mod.config_db), + Message = httpd_util:message(301, URL, ConfigDB), {proceed, [{response, {301, ["Location: ", URL, "\r\n" @@ -76,25 +83,26 @@ do_alias(Info) -> "<BODY>\n<H1>",ReasonPhrase, "</H1>\n", Message, "\n</BODY>\n</HTML>\n"]}}| - [{real_name, {Path, AfterPath}} | Info#mod.data]]}; + [{real_name, {Path, AfterPath}} | Data]]}; _NoFile -> - {proceed,[{real_name, {Path, AfterPath}} | Info#mod.data]} + {proceed, [{real_name, {Path, AfterPath}} | Data]} end. port_string(80) -> ""; port_string(Port) -> - ":"++integer_to_list(Port). + ":" ++ integer_to_list(Port). %% real_name real_name(ConfigDB, RequestURI, []) -> - DocumentRoot = httpd_util:lookup(ConfigDB, document_root, ""), + DocumentRoot = which_document_root(ConfigDB), RealName = DocumentRoot ++ RequestURI, {ShortPath, _AfterPath} = httpd_util:split_path(RealName), - {Path, AfterPath} = httpd_util:split_path(default_index(ConfigDB, - RealName)), + {Path, AfterPath} = + httpd_util:split_path(default_index(ConfigDB, RealName)), {ShortPath, Path, AfterPath}; + real_name(ConfigDB, RequestURI, [{FakeName,RealName}|Rest]) -> case inets_regexp:match(RequestURI, "^" ++ FakeName) of {match, _, _} -> @@ -105,7 +113,7 @@ real_name(ConfigDB, RequestURI, [{FakeName,RealName}|Rest]) -> httpd_util:split_path(default_index(ConfigDB, ActualName)), {ShortPath, Path, AfterPath}; nomatch -> - real_name(ConfigDB,RequestURI,Rest) + real_name(ConfigDB, RequestURI, Rest) end. %% real_script_name @@ -113,20 +121,21 @@ real_name(ConfigDB, RequestURI, [{FakeName,RealName}|Rest]) -> real_script_name(_ConfigDB, _RequestURI, []) -> not_a_script; real_script_name(ConfigDB, RequestURI, [{FakeName,RealName} | Rest]) -> - case inets_regexp:match(RequestURI,"^"++FakeName) of + case inets_regexp:match(RequestURI, "^" ++ FakeName) of {match,_,_} -> - {ok,ActualName,_}=inets_regexp:sub(RequestURI,"^"++FakeName,RealName), - httpd_util:split_script_path(default_index(ConfigDB,ActualName)); + {ok, ActualName, _} = + inets_regexp:sub(RequestURI, "^" ++ FakeName, RealName), + httpd_util:split_script_path(default_index(ConfigDB, ActualName)); nomatch -> - real_script_name(ConfigDB,RequestURI,Rest) + real_script_name(ConfigDB, RequestURI, Rest) end. %% default_index default_index(ConfigDB, Path) -> case file:read_file_info(Path) of - {ok, FileInfo} when FileInfo#file_info.type == directory -> - DirectoryIndex = httpd_util:lookup(ConfigDB, directory_index, []), + {ok, FileInfo} when FileInfo#file_info.type =:= directory -> + DirectoryIndex = which_directory_index(ConfigDB), append_index(Path, DirectoryIndex); _ -> Path @@ -147,9 +156,9 @@ append_index(RealName, [Index | Rest]) -> path(Data, ConfigDB, RequestURI) -> case proplists:get_value(real_name, Data) of undefined -> - DocumentRoot = httpd_util:lookup(ConfigDB, document_root, ""), + DocumentRoot = which_document_root(ConfigDB), {Path, _AfterPath} = - httpd_util:split_path(DocumentRoot++RequestURI), + httpd_util:split_path(DocumentRoot ++ RequestURI), Path; {Path, _AfterPath} -> Path @@ -164,7 +173,7 @@ path(Data, ConfigDB, RequestURI) -> load("DirectoryIndex " ++ DirectoryIndex, []) -> {ok, DirectoryIndexes} = inets_regexp:split(DirectoryIndex," "), {ok,[], {directory_index, DirectoryIndexes}}; -load("Alias " ++ Alias,[]) -> +load("Alias " ++ Alias, []) -> case inets_regexp:split(Alias," ") of {ok, [FakeName, RealName]} -> {ok,[],{alias,{FakeName,RealName}}}; @@ -191,13 +200,13 @@ store({directory_index, Value} = Conf, _) when is_list(Value) -> end; store({directory_index, Value}, _) -> {error, {wrong_type, {directory_index, Value}}}; -store({alias, {Fake, Real}} = Conf, _) when is_list(Fake), - is_list(Real) -> +store({alias, {Fake, Real}} = Conf, _) + when is_list(Fake) andalso is_list(Real) -> {ok, Conf}; store({alias, Value}, _) -> {error, {wrong_type, {alias, Value}}}; -store({script_alias, {Fake, Real}} = Conf, _) when is_list(Fake), - is_list(Real) -> +store({script_alias, {Fake, Real}} = Conf, _) + when is_list(Fake) andalso is_list(Real) -> {ok, Conf}; store({script_alias, Value}, _) -> {error, {wrong_type, {script_alias, Value}}}. @@ -208,3 +217,21 @@ is_directory_index_list([Head | Tail]) when is_list(Head) -> is_directory_index_list(Tail); is_directory_index_list(_) -> false. + + +%% --------------------------------------------------------------------- + +which_alias(ConfigDB) -> + httpd_util:multi_lookup(ConfigDB, alias). + +which_server_name(ConfigDB) -> + httpd_util:lookup(ConfigDB, server_name). + +which_port(ConfigDB) -> + httpd_util:lookup(ConfigDB, port, 80). + +which_document_root(ConfigDB) -> + httpd_util:lookup(ConfigDB, document_root, ""). + +which_directory_index(ConfigDB) -> + httpd_util:lookup(ConfigDB, directory_index, []). diff --git a/lib/inets/src/http_server/mod_cgi.erl b/lib/inets/src/http_server/mod_cgi.erl index ab12a3b57b..33605b9698 100644 --- a/lib/inets/src/http_server/mod_cgi.erl +++ b/lib/inets/src/http_server/mod_cgi.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -335,6 +335,8 @@ script_elements(#mod{method = "GET"}, {PathInfo, QueryString}) -> [{query_string, QueryString}, {path_info, PathInfo}]; script_elements(#mod{method = "POST", entity_body = Body}, _) -> [{entity_body, Body}]; +script_elements(#mod{method = "PUT", entity_body = Body}, _) -> + [{entity_body, Body}]; script_elements(_, _) -> []. diff --git a/lib/inets/src/http_server/mod_esi.erl b/lib/inets/src/http_server/mod_esi.erl index dd6f62ae2d..484d4b3fb4 100644 --- a/lib/inets/src/http_server/mod_esi.erl +++ b/lib/inets/src/http_server/mod_esi.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -249,7 +249,24 @@ erl(#mod{method = Method} = ModData, ESIBody, Modules) {proceed, [{status,{400, none, BadRequest}} | ModData#mod.data]} end; -erl(#mod{method = "POST", entity_body = Body} = ModData, ESIBody, Modules) -> +erl(#mod{request_uri = ReqUri, + method = "PUT", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> + {proceed, [{status,{501,{"PUT", ReqUri, Version}, + ?NICE("Erl mechanism doesn't support method PUT")}}| + Data]}; + +erl(#mod{request_uri = ReqUri, + method = "DELETE", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> + {proceed,[{status,{501,{"DELETE", ReqUri, Version}, + ?NICE("Erl mechanism doesn't support method DELETE")}}| + Data]}; + +erl(#mod{method = "POST", + entity_body = Body} = ModData, ESIBody, Modules) -> case httpd_util:split(ESIBody,":|%3A|/",2) of {ok,[ModuleName, Function]} -> generate_webpage(ModData, ESIBody, Modules, @@ -444,8 +461,26 @@ input_type([_First|Rest]) -> %%------------------------ Eval mechanism -------------------------------- -eval(#mod{request_uri = ReqUri, method = "POST", - http_version = Version, data = Data}, _ESIBody, _Modules) -> +eval(#mod{request_uri = ReqUri, + method = "PUT", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> + {proceed,[{status,{501,{"PUT", ReqUri, Version}, + ?NICE("Eval mechanism doesn't support method PUT")}}| + Data]}; + +eval(#mod{request_uri = ReqUri, + method = "DELETE", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> + {proceed,[{status,{501,{"DELETE", ReqUri, Version}, + ?NICE("Eval mechanism doesn't support method DELETE")}}| + Data]}; + +eval(#mod{request_uri = ReqUri, + method = "POST", + http_version = Version, + data = Data}, _ESIBody, _Modules) -> {proceed,[{status,{501,{"POST", ReqUri, Version}, ?NICE("Eval mechanism doesn't support method POST")}}| Data]}; diff --git a/lib/inets/src/inets_app/Makefile b/lib/inets/src/inets_app/Makefile index 2dab99386a..33c9e34a3a 100644 --- a/lib/inets/src/inets_app/Makefile +++ b/lib/inets/src/inets_app/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # @@ -22,6 +22,7 @@ include $(ERL_TOP)/make/target.mk EBIN = ../../ebin include $(ERL_TOP)/make/$(TARGET)/otp.mk + # ---------------------------------------------------- # Application version # ---------------------------------------------------- @@ -32,12 +33,13 @@ VSN = $(INETS_VSN) # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) # ---------------------------------------------------- # Target Specs # ---------------------------------------------------- + MODULES = \ inets_service \ inets \ @@ -49,7 +51,8 @@ HRL_FILES = inets_internal.hrl ERL_FILES = $(MODULES:%=%.erl) -TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) \ +TARGET_FILES= \ + $(MODULES:%=$(EBIN)/%.$(EMULATOR)) \ $(APP_TARGET) \ $(APPUP_TARGET) @@ -66,7 +69,7 @@ APPUP_TARGET = $(EBIN)/$(APPUP_FILE) # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' # ---------------------------------------------------- @@ -108,14 +111,15 @@ $(APPUP_TARGET): $(APPUP_SRC) ../../vsn.mk include $(ERL_TOP)/make/otp_release_targets.mk release_spec: opt - $(INSTALL_DIR) $(RELSYSDIR)/src + $(INSTALL_DIR) $(RELSYSDIR)/src $(INSTALL_DATA) $(HRL_FILES) $(ERL_FILES) $(RELSYSDIR)/src - $(INSTALL_DIR) $(RELSYSDIR)/ebin + $(INSTALL_DIR) $(RELSYSDIR)/ebin $(INSTALL_DATA) $(TARGET_FILES) $(RELSYSDIR)/ebin release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" diff --git a/lib/inets/src/inets_app/inets.app.src b/lib/inets/src/inets_app/inets.app.src index 6524c3b19b..04f6365b98 100644 --- a/lib/inets/src/inets_app/inets.app.src +++ b/lib/inets/src/inets_app/inets.app.src @@ -1,19 +1,19 @@ %% This is an -*- erlang -*- file. %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -34,7 +34,8 @@ ftp_sup, %% HTTP client: - http, + http, %% Old client API module + httpc, %% New client API module httpc_handler, httpc_handler_sup, httpc_manager, @@ -42,7 +43,7 @@ httpc_request, httpc_response, httpc_sup, - http_cookie, + httpc_cookie, http_uri, %% Proably will by used by server also in the future diff --git a/lib/inets/src/inets_app/inets.appup.src b/lib/inets/src/inets_app/inets.appup.src index 0112a64239..2efa7ccb60 100644 --- a/lib/inets/src/inets_app/inets.appup.src +++ b/lib/inets/src/inets_app/inets.appup.src @@ -1,34 +1,31 @@ %% This is an -*- erlang -*- file. %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% {"%VSN%", [ {"5.2", [ - {load_module, inets, soft_purge, soft_purge, []} + {restart_application, inets} ] }, {"5.1.3", [ - {load_module, httpd_response, soft_purge, soft_purge, []}, - {update, ftp, {advanced, upgrade_from_pre_5_12}, - soft_purge, soft_purge, []}, - {update, httpc_handler, soft, soft_purge, soft_purge, []} + {restart_application, inets} ] }, {"5.1.2", @@ -40,15 +37,12 @@ [ {"5.2", [ - {load_module, inets, soft_purge, soft_purge, []} + {restart_application, inets} ] }, {"5.1.3", [ - {load_module, httpd_response, soft_purge, soft_purge, []}, - {update, ftp, {advanced, downgrade_to_pre_5_12}, - soft_purge, soft_purge, []}, - {update, httpc_handler, soft, soft_purge, soft_purge, []} + {restart_application, inets} ] }, {"5.1.2", diff --git a/lib/inets/src/inets_app/inets.erl b/lib/inets/src/inets_app/inets.erl index 77cb14cc20..7e3f862ee7 100644 --- a/lib/inets/src/inets_app/inets.erl +++ b/lib/inets/src/inets_app/inets.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -522,9 +522,7 @@ change_pattern({Mod, Service, Pattern}) catch exit:{Where, Reason} -> {error, {Where, Reason}} - end; - _ -> - exit({bad_pattern, Pattern}) + end end, ok. @@ -728,7 +726,7 @@ call_service(Service, Call, Args) -> service_module(tftpd) -> tftp; service_module(httpc) -> - http; + httpc; service_module(ftpc) -> ftp; service_module(Service) -> diff --git a/lib/inets/src/tftp/Makefile b/lib/inets/src/tftp/Makefile index 63f70f7943..b4339da1e2 100644 --- a/lib/inets/src/tftp/Makefile +++ b/lib/inets/src/tftp/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2005-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2005-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # @@ -33,7 +33,8 @@ VSN = $(INETS_VSN) # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- -RELSYSDIR = $(RELEASE_PATH)/lib/inets-$(VSN) +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + # ---------------------------------------------------- # Target Specs @@ -53,10 +54,12 @@ ERL_FILES = $(MODULES:%=%.erl) TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + # ---------------------------------------------------- # INETS FLAGS # ---------------------------------------------------- -INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ +INETS_FLAGS = -D'SERVER_SOFTWARE="$(APPLICATION)/$(VSN)"' + # ---------------------------------------------------- # FLAGS @@ -64,6 +67,8 @@ INETS_FLAGS = -D'SERVER_SOFTWARE="inets/$(VSN)"' \ ERL_COMPILE_FLAGS += $(INETS_FLAGS) \ +'{parse_transform,sys_pre_attributes}' \ +'{attribute,insert,app_vsn,$(APP_VSN)}' + + # ---------------------------------------------------- # Targets # ---------------------------------------------------- @@ -90,6 +95,7 @@ release_spec: opt release_docs_spec: info: + @echo "APPLICATION = $(APPLICATION)" @echo "INETS_DEBUG = $(INETS_DEBUG)" @echo "INETS_FLAGS = $(INETS_FLAGS)" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" diff --git a/lib/inets/test/Makefile b/lib/inets/test/Makefile new file mode 100644 index 0000000000..668752da9e --- /dev/null +++ b/lib/inets/test/Makefile @@ -0,0 +1,343 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1997-2010. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# +# For an outline of how this all_SUITE_data stuff works, see the +# make file ../../ssl/test/Makefile. +# +include $(ERL_TOP)/make/target.mk + +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN = $(INETS_VSN) + + +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) + + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +INCLUDES = -I. \ + -I$(ERL_TOP)/lib/test_server/include/ \ + -I$(ERL_TOP)/lib/inets/src/inets_app \ + -I$(ERL_TOP)/lib/inets/src/http_lib \ + -I$(ERL_TOP)/lib/inets/src/http_client \ + -I$(ERL_TOP)/lib/inets/src/ftp + +CP = cp + +ifeq ($(TESTROOT_DIR),) +TESTROOT_DIR = /ldisk/tests/$(USER)/inets +endif + +ifeq ($(INETS_DATA_DIR),) +INETS_DATA_DIR = $(TESTROOT_DIR)/data_dir +endif + +ifeq ($(INETS_PRIV_DIR),) +INETS_PRIV_DIR = $(TESTROOT_DIR)/priv_dir +endif + +INETS_FLAGS = -Dinets_data_dir='"$(INETS_DATA_DIR)"' \ + -Dinets_priv_dir='"$(INETS_PRIV_DIR)"' + + +### +### test suite debug flags +### +ifeq ($(FTP_DEBUG_CLIENT),) + FTP_DEBUG_CLIENT = y +endif + +ifeq ($(FTP_DEBUG_CLIENT),) + FTP_FLAGS += -Dftp_debug_client +endif + +ifeq ($(FTP_TRACE_CLIENT),) + FTP_DEBUG_CLIENT = y +endif + +ifeq ($(FTP_TRACE_CLIENT),y) + FTP_FLAGS += -Dftp_trace_client +endif + +ifneq ($(FTP_DEBUG),) + FTP_DEBUG = s +endif + +ifeq ($(FTP_DEBUG),l) + FTP_FLAGS += -Dftp_log +endif + +ifeq ($(FTP_DEBUG),d) + FTP_FLAGS += -Dftp_debug -Dftp_log +endif + +ifeq ($(INETS_DEBUG),) + INETS_DEBUG = d +endif + +ifeq ($(INETS_DEBUG),l) + INETS_FLAGS += -Dinets_log +endif + +ifeq ($(INETS_DEBUG),d) + INETS_FLAGS += -Dinets_debug -Dinets_log +endif + + +### +### HTTPD verbosity flags +### + +ifneq ($(MANV),) + INETS_FLAGS += -Dhttpd_manager_verbosity=$(MANV) +else + INETS_FLAGS += -Dhttpd_manager_verbosity=trace +endif + +ifneq ($(REQV),) + INETS_FLAGS += -Dhttpd_request_handler_verbosity=$(REQV) +else + INETS_FLAGS += -Dhttpd_request_handler_verbosity=trace +endif + +ifneq ($(ACCV),) + INETS_FLAGS += -Dhttpd_acceptor_verbosity=$(ACCV) +else + INETS_FLAGS += -Dhttpd_acceptor_verbosity=trace +endif + +ifneq ($(AUTHV),) + INETS_FLAGS += -Dhttpd_auth_verbosity=$(AUTHV) +else + INETS_FLAGS += -Dhttpd_auth_verbosity=log +endif + +ifneq ($(SECV),) + INETS_FLAGS += -Dhttpd_security_verbosity=$(SECV) +else + INETS_FLAGS += -Dhttpd_security_verbosity=log +endif + +INETS_ROOT = ../../inets + +MODULES = \ + inets_test_lib \ + ftp_SUITE \ + ftp_format_SUITE \ + ftp_solaris8_sparc_test \ + ftp_solaris9_sparc_test \ + ftp_solaris10_sparc_test \ + ftp_solaris10_x86_test \ + ftp_linux_x86_test \ + ftp_linux_ppc_test \ + ftp_macosx_x86_test \ + ftp_macosx_ppc_test \ + ftp_openbsd_x86_test \ + ftp_freebsd_x86_test \ + ftp_netbsd_x86_test \ + ftp_windows_xp_test \ + ftp_windows_2003_server_test \ + ftp_suite_lib \ + ftp_ticket_test \ + http_format_SUITE \ + httpc_SUITE \ + httpc_cookie_SUITE \ + httpd_SUITE \ + httpd_basic_SUITE \ + httpd_mod \ + httpd_block \ + httpd_load \ + httpd_time_test \ + httpd_1_1 \ + httpd_test_lib \ + inets_sup_SUITE \ + inets_SUITE \ + inets_app_test \ + inets_appup_test \ + tftp_test_lib \ + tftp_SUITE + + +EBIN = . + +HRL_FILES = inets_test_lib.hrl \ + inets_internal.hrl \ + ftp_internal.hrl \ + httpc_internal.hrl \ + http_internal.hrl \ + tftp_test_lib.hrl + +ERL_FILES = $(MODULES:%=%.erl) + +SOURCE = $(ERL_FILES) $(HRL_FILES) + +TARGET_FILES = $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + +INETS_SPECS = inets.spec inets.spec.vxworks +INETS_FILES = inets.config $(INETS_SPECS) + +# SUB_SUITES = \ +# inets_sup_suite \ +# inets_httpd_suite \ +# inets_httpc_suite \ +# inets_ftp_suite \ +# inets_tftp_suite + +INETS_DATADIRS = inets_SUITE_data inets_sup_SUITE_data +HTTPD_DATADIRS = httpd_test_data httpd_SUITE_data +HTTPC_DATADIRS = httpc_SUITE_data +FTP_DATADIRS = ftp_SUITE_data + +DATADIRS = $(INETS_DATADIRS) $(HTTPD_DATADIRS) $(HTTPC_DATADIRS) $(FTP_DATADIRS) + +EMAKEFILE = Emakefile +MAKE_EMAKE = $(wildcard $(ERL_TOP)/make/make_emakefile) + +ifeq ($(MAKE_EMAKE),) +BUILDTARGET = $(TARGET_FILES) +RELTEST_FILES = $(INETS_SPECS) $(SOURCE) +else +BUILDTARGET = emakebuild +RELTEST_FILES = $(EMAKEFILE) $(INETS_SPECS) $(SOURCE) +endif + + +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- + +RELTESTSYSDIR = $(RELEASE_PATH)/inets_test +RELTESTSYSALLDATADIR = $(RELTESTSYSDIR)/all_SUITE_data +RELTESTSYSBINDIR = $(RELTESTSYSALLDATADIR)/bin + + +# ---------------------------------------------------- +# FLAGS +# The path to the test_server ebin dir is needed when +# running the target "targets". +# ---------------------------------------------------- +ERL_COMPILE_FLAGS += -pa ../../../internal_tools/test_server/ebin \ + $(INCLUDES) $(FTP_FLAGS) $(INETS_FLAGS) + +# ---------------------------------------------------- +# Targets +# erl -sname kalle -pa ../ebin +# If you intend to run the test suite locally (private), then +# there is some requirements: +# 1) INETS_PRIV_DIR must be created +# ---------------------------------------------------- + +tests debug opt: $(BUILDTARGET) + +targets: $(TARGET_FILES) + +.PHONY: emakebuild + +emakebuild: $(EMAKEFILE) + +$(EMAKEFILE): + $(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) '*_SUITE_make' | grep -v Warning > $(EMAKEFILE) + $(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) | grep -v Warning >> $(EMAKEFILE) + +clean: + rm -f $(EMAKEFILE) + rm -f $(TARGET_FILES) + rm -f core *~ + +docs: + + +# ---------------------------------------------------- +# Release Target +# ---------------------------------------------------- +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: opt + $(INSTALL_DIR) $(RELSYSDIR)/test + $(INSTALL_DATA) $(HRL_FILES) $(ERL_FILES) $(RELSYSDIR)/test + $(INSTALL_DATA) $(INETS_FILES) $(RELSYSDIR)/test + @for d in $(DATADIRS); do \ + echo "installing data dir $$d"; \ + echo $$d/TAR.exclude2 > $$d/TAR.exclude2; \ + cat $$d/TAR.exclude >> $$d/TAR.exclude2; \ + find $$d -name '*.contrib*' >> $$d/TAR.exclude2; \ + find $$d -name '*.keep*' >> $$d/TAR.exclude2; \ + find $$d -name '*.mkelem*' >> $$d/TAR.exclude2; \ + find $$d -name '*~' >> $$d/TAR.exclude2; \ + find $$d -name 'erl_crash.dump' >> $$d/TAR.exclude2; \ + find $$d -name 'core' >> $$d/TAR.exclude2; \ + find $$d -name '.cmake.state' >> $$d/TAR.exclude2; \ + tar cfX - $$d/TAR.exclude2 $$d | (cd $(RELSYSDIR)/test; tar xf -); \ + done + +release_tests_spec: opt + $(INSTALL_DIR) $(RELTESTSYSDIR) + $(INSTALL_DATA) $(RELTEST_FILES) $(RELTESTSYSDIR) + chmod -f -R u+w $(RELTESTSYSDIR) + tar chf - $(DATADIRS) | (cd $(RELTESTSYSDIR); tar xf -) + $(INSTALL_DIR) $(RELTESTSYSALLDATADIR) + $(INSTALL_DIR) $(RELTESTSYSBINDIR) + chmod -f -R +x $(RELTESTSYSBINDIR) + $(INSTALL_DIR) $(RELTESTSYSALLDATADIR)/win32/lib + +release_docs_spec: + +info: + @echo "MAKE_EMAKE = $(MAKE_EMAKE)" + @echo "EMAKEFILE = $(EMAKEFILE)" + @echo "BUILDTARGET = $(BUILDTARGET)" + @echo "" + @echo "MODULES = $(MODULES)" + @echo "ERL_FILES = $(ERL_FILES)" + @echo "SOURCE = $(SOURCE)" + @echo "TARGET_FILES = $(TARGET_FILES)" + @echo "" + @echo "INETS_SPECS = $(INETS_SPECS)" + @echo "INETS_FILES = $(INETS_FILES)" + @echo "" + @echo "RELEASE_PATH = $(RELEASE_PATH)" + @echo "RELSYSDIR = $(RELSYSDIR)" + @echo "RELTESTSYSDIR = $(RELTESTSYSDIR)" + @echo "RELTESTSYSALLDATADIR = $(RELTESTSYSALLDATADIR)" + @echo "RELTESTSYSBINDIR = $(RELTESTSYSBINDIR)" + @echo "" + @echo "DATADIRS = $(DATADIRS)" + @echo "REL_DATADIRS = $(REL_DATADIRS)" + @echo "" + @echo "INETS_DATA_DIR = $(INETS_DATA_DIR)" + @echo "INETS_PRIV_DIR = $(INETS_PRIV_DIR)" + @echo "INETS_ROOT = $(INETS_ROOT)" + @echo "INETS_FLAGS = $(INETS_FLAGS)" + @echo "FTP_FLAGS = $(FTP_FLAGS)" + +tftp: + erlc $(ERL_COMPILE_FLAGS) tftp_test_lib.erl tftp_SUITE.erl && erl -pa ../../inets/ebin -s tftp_SUITE t -s erlang halt + +tftp_work: + echo "tftp_test_lib:t([{tftp_SUITE, all}])." + erlc $(ERL_COMPILE_FLAGS) tftp_test_lib.erl tftp_SUITE.erl && erl -pa ../../inets/ebin diff --git a/lib/inets/test/ftp_SUITE.erl b/lib/inets/test/ftp_SUITE.erl new file mode 100644 index 0000000000..e7404f945b --- /dev/null +++ b/lib/inets/test/ftp_SUITE.erl @@ -0,0 +1,143 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_SUITE). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +%% Test server specific exports +-export([all/1]). +% -export([init_per_testcase/2, end_per_testcase/2]). +-export([init_per_suite/1, end_per_suite/1]). + +%% Test cases must be exported. +-export([solaris8_test/1, + solaris9_test/1, + solaris10_test/1, + linux_x86_test/1, + linux_ppc_test/1, + macosx_x86_test/1, + macosx_ppc_test/1, + openbsd_test/1, + freebsd_test/1, + netbsd_test/1, + windows_xp_test/1, + windows_2003_server_test/1, + ticket_tests/1]). + +-define(FTP_USER, "anonymous"). +-define(FTP_PASS, passwd()). +-define(FTP_PORT, 21). + +-define(BAD_HOST, "badhostname"). +-define(BAD_USER, "baduser"). +-define(BAD_DIR, "baddirectory"). + +-ifdef(ftp_debug_client). +-define(ftp_open(Host, Flags), do_ftp_open(Host, [debug] ++ Flags)). +-else. +-ifdef(ftp_trace_client). +-define(ftp_open(Host, Flags), do_ftp_open(Host, [trace] ++ Flags)). +-else. +-define(ftp_open(Host, Flags), do_ftp_open(Host, [verbose] ++ Flags)). +-endif. +-endif. + + +%%-------------------------------------------------------------------- +%% all(Arg) -> [Doc] | [Case] | {skip, Comment} +%% Arg - doc | suite +%% Doc - string() +%% Case - atom() +%% Name of a test case function. +%% Comment - string() +%% Description: Returns documentation/test cases in this test suite +%% or a skip tuple if the platform is not supported. +%%-------------------------------------------------------------------- +all(doc) -> + ["Test the ftp client in the inets application."]; +all(suite) -> + [ + solaris8_test, + solaris9_test, + solaris10_test, + linux_x86_test, + linux_ppc_test, + macosx_x86_test, + macosx_ppc_test, + openbsd_test, + freebsd_test, + netbsd_test, + windows_xp_test, + windows_2003_server_test, + ticket_tests + ]. + +solaris8_test(suite) -> + [{ftp_solaris8_sparc_test,all}]. +solaris9_test(suite) -> + [{ftp_solaris9_sparc_test,all}]. +solaris10_test(suite) -> + [{ftp_solaris10_sparc_test,all}, {ftp_solaris10_x86_test,all}]. +linux_x86_test(suite) -> + [{ftp_linux_x86_test,all}]. +linux_ppc_test(suite) -> + [{ftp_linux_ppc_test,all}]. +macosx_x86_test(suite) -> + [{ftp_macosx_x86_test,all}]. +macosx_ppc_test(suite) -> + [{ftp_macosx_ppc_test,all}]. +openbsd_test(suite) -> + [{ftp_openbsd_x86_test,all}]. +freebsd_test(suite) -> + [{ftp_freebsd_x86_test,all}]. +netbsd_test(suite) -> + [{ftp_netbsd_x86_test,all}]. +windows_xp_test(suite) -> + [{ftp_windows_xp_test,all}]. +windows_2003_server_test(suite) -> + [{ftp_windows_2003_server_test,all}]. + +ticket_tests(suite) -> + [{ftp_ticket_test, all}]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + inets:start(), + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + inets:stop(), + ok. diff --git a/lib/inets/test/ftp_SUITE_data/ftpd_hosts.skel b/lib/inets/test/ftp_SUITE_data/ftpd_hosts.skel new file mode 100644 index 0000000000..75096ce687 --- /dev/null +++ b/lib/inets/test/ftp_SUITE_data/ftpd_hosts.skel @@ -0,0 +1,18 @@ +%% Add a host name in the appropriate list +%% Each "platform" contains a list of hostnames (a string) that can +%% be used for testing the ftp client. +%% The definition below are an example!! +[{solaris8_sparc, ["solaris8_sparc_dummy1", "solaris8_sparc_dummy2"]}, + {solaris9_sparc, ["solaris9_sparc_dummy1"]}, + {solaris10_sparc, ["solaris10_sparc_dummy1"]}, + {solaris10_x86, ["solaris10_x86_dummy1", "solaris10_x86_dummy2"]}, + {linux_x86, ["linux_x86_dummy1", "linux_x86_dummy2"]}, + {linux_ppc, ["linux_ppc_dummy1"]}, + {macosx_ppc, ["macosx_ppc_dummy1"]}, + {macosx_x86, ["macosx_x86_dummy1", "macosx_x86_dummy2"]}, + {openbsd_x86, []}, + {freebsd_x86, ["freebsd_x86_dummy1"]}, + {netbsd_x86, []}, + {windows_xp, []}, + {windows_2003_server, ["win2003_dummy1"]}, + {ticket_test, ["solaris8_x86_dummy1", "linux_x86_dummy1"]}]. diff --git a/lib/inets/test/ftp_format_SUITE.erl b/lib/inets/test/ftp_format_SUITE.erl new file mode 100644 index 0000000000..9ca6575b2d --- /dev/null +++ b/lib/inets/test/ftp_format_SUITE.erl @@ -0,0 +1,341 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(ftp_format_SUITE). +-author('[email protected]'). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include("ftp_internal.hrl"). + +%% Test server specific exports +-export([all/1, init_per_testcase/2, end_per_testcase/2]). + +%% Test cases must be exported. +-export([ftp_response/1, ftp_150/1, + ftp_200/1, ftp_220/1, ftp_226/1, ftp_257/1, ftp_331/1, ftp_425/1, + ftp_other_status_codes/1, ftp_multiple_lines/1, + ftp_multipel_ctrl_messages/1, format_error/1]). + +all(doc) -> + ["Test library functions for the ftp client."]; +all(suite) -> + [ftp_response, format_error]. + +init_per_testcase(_, Config) -> + Dog = test_server:timetrap(?t:minutes(1)), + NewConfig = lists:keydelete(watchdog, 1, Config), + [{watchdog, Dog} | NewConfig]. + +end_per_testcase(_, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +ftp_response(doc) -> + ["Test ftp_response:parse_lines/3 and ftp_response:interpret/1." + " This test case will simulate that the " + "message will be recived a little at the time on a socket and the " + "package may be broken up into smaller parts at arbitrary point."]; +ftp_response(suite) -> + [ftp_150, ftp_200, ftp_220, ftp_226, ftp_257, ftp_331, ftp_425, + ftp_other_status_codes, ftp_multiple_lines, ftp_multipel_ctrl_messages]. + +ftp_150(doc) -> + ["Especially check that respons can be devided in a random place."]; +ftp_150(suite) -> + []; +ftp_150(Config) when is_list(Config) -> + FtpResponse = ["150 ASCII data conn", "ection for /bin/ls ", + "(134.138.177", ".89,50434) (0 bytes).\r\n"], + + "150 ASCII data connection for /bin/ls " + "(134.138.177.89,50434) (0 bytes).\r\n" = Msg = + parse(ftp_response, parse_lines, [[], start], FtpResponse), + {pos_prel, _} = ftp_response:interpret(Msg), + ok. + +ftp_200(doc) -> + ["Especially check that respons can be devided after the first status " + "code character and in the end delimiter."]; +ftp_200(suite) -> + []; +ftp_200(Config) when is_list(Config) -> + FtpResponse = ["2", "00 PORT command successful.", [?CR], [?LF]], + + "200 PORT command successful.\r\n" = Msg = + parse(ftp_response, parse_lines, [[], start], FtpResponse), + {pos_compl, _} = ftp_response:interpret(Msg), + ok. + +ftp_220(doc) -> + ["Especially check that respons can be devided after the " + "first with space "]; +ftp_220(suite) -> + []; +ftp_220(Config) when is_list(Config) -> + FtpResponse = ["220 ","fingon FTP server (SunOS 5.8) ready.\r\n"], + + "220 fingon FTP server (SunOS 5.8) ready.\r\n" = Msg = + parse(ftp_response, parse_lines, [[], start], FtpResponse), + {pos_compl, _} = ftp_response:interpret(Msg), + ok. + +ftp_226(doc) -> + ["Especially check that respons can be devided after second status code" + " character and in the end delimiter."]; +ftp_226(suite) -> + []; +ftp_226(Config) when is_list(Config) -> + FtpResponse = ["22" "6 Transfer complete.\r", [?LF]], + + "226 Transfer complete.\r\n" = Msg = + parse(ftp_response, parse_lines, [[], start], FtpResponse), + {pos_compl, _} = ftp_response:interpret(Msg), + ok. + +ftp_257(doc) -> + ["Especially check that quoted chars do not cause a problem."]; +ftp_257(suite) -> + []; +ftp_257(Config) when is_list(Config) -> + FtpResponse = ["257 \"/\" is current directory.\r\n"], + + "257 \"/\" is current directory.\r\n" = Msg = + parse(ftp_response, parse_lines, [[], start], FtpResponse), + {pos_compl, _} = ftp_response:interpret(Msg), + ok. + +ftp_331(doc) -> + ["Especially check that respons can be devided after the third status " + " status code character."]; +ftp_331(suite) -> + []; +ftp_331(Config) when is_list(Config) -> + %% Brake before white space after code + FtpResponse = + ["331"," Guest login ok, send ient as password.\r\n"], + + "331 Guest login ok, send ient as password.\r\n" = Msg = + parse(ftp_response, parse_lines, [[], start], FtpResponse), + {pos_interm, _} = ftp_response:interpret(Msg), + ok. + +ftp_425(doc) -> + ["Especially check a message that was received in only one part."]; +ftp_425(suite) -> + []; +ftp_425(Config) when is_list(Config) -> + FtpResponse = + ["425 Can't build data connection: Connection refused.\r\n"], + + "425 Can't build data connection: Connection refused.\r\n" + = Msg = parse(ftp_response, parse_lines, [[], start], FtpResponse), + {trans_neg_compl, _} = ftp_response:interpret(Msg), + ok. + +ftp_multiple_lines(doc) -> + ["Especially check multiple lines devided in significant places"]; +ftp_multiple_lines(suite) -> + []; +ftp_multiple_lines(Config) when is_list(Config) -> + FtpResponse = ["21", "4","-The", + " following commands are recognized:\r\n" + " USER EPRT STRU MAIL* ALLO CWD", + " STAT* XRMD \r\n" + " PASS LPRT MODE MSND* " + " REST* XCWD HELP PWD ", [?CRLF], + " ACCT* EPSV RETR MSOM* RNFR LIST " + " NOOP XPWD \r\n", + " REIN* LPSV STOR MSAM* RNTO NLST " + " MKD CDUP \r\n" + " QUIT PASV APPE MRSQ* ABOR SITE* " + " XMKD XCUP \r\n" + " PORT TYPE MLFL* MRCP* DELE SYST " + " RMD STOU \r\n" + "214 (*'s => unimplemented)", [?CR], [?LF]], + + + FtpResponse1 = ["214-", "The", + " following commands are recognized:\r\n" + " USER EPRT STRU MAIL* ALLO CWD", + " STAT* XRMD \r\n" + " PASS LPRT MODE MSND* " + " REST* XCWD HELP PWD ", [?CRLF], + " ACCT* EPSV RETR MSOM* RNFR LIST " + " NOOP XPWD \r\n", + " REIN* LPSV STOR MSAM* RNTO NLST " + " MKD CDUP \r\n" + " QUIT PASV APPE MRSQ* ABOR SITE* " + " XMKD XCUP \r\n" + " PORT TYPE MLFL* MRCP* DELE SYST " + " RMD STOU \r\n" + "2", "14 (*'s => unimplemented)", [?CR], [?LF]], + + FtpResponse2 = ["214-", "The", + " following commands are recognized:\r\n" + " USER EPRT STRU MAIL* ALLO CWD", + " STAT* XRMD \r\n" + " PASS LPRT MODE MSND* " + " REST* XCWD HELP PWD ", [?CRLF], + " ACCT* EPSV RETR MSOM* RNFR LIST " + " NOOP XPWD \r\n", + " REIN* LPSV STOR MSAM* RNTO NLST " + " MKD CDUP \r\n" + " QUIT PASV APPE MRSQ* ABOR SITE* " + " XMKD XCUP \r\n" + " PORT TYPE MLFL* MRCP* DELE SYST " + " RMD STOU \r\n" + "21", "4"," (*'s => unimplemented)", [?CR], [?LF]], + + MultiLineResultStr = + "214-The following commands are recognized:\r\n" + " USER EPRT STRU MAIL* ALLO CWD STAT* " + "XRMD \r\n" + " PASS LPRT MODE MSND* REST* XCWD HELP " + "PWD \r\n" + " ACCT* EPSV RETR MSOM* RNFR LIST NOOP " + "XPWD \r\n" + " REIN* LPSV STOR MSAM* RNTO NLST MKD " + "CDUP \r\n" + " QUIT PASV APPE MRSQ* ABOR SITE* XMKD " + "XCUP \r\n" + " PORT TYPE MLFL* MRCP* DELE SYST RMD " + "STOU \r\n" + "214 (*'s => unimplemented)\r\n", + + MultiLineResultStr = + parse(ftp_response, parse_lines, [[], start], FtpResponse), + {pos_compl, _} = ftp_response:interpret(MultiLineResultStr), + + MultiLineResultStr = parse(ftp_response, parse_lines, [[], start], + FtpResponse1), + + MultiLineResultStr = parse(ftp_response, parse_lines, [[], start], + FtpResponse2), + ok. + +ftp_other_status_codes(doc) -> + ["Check that other valid status codes, than the ones above, are handled" + "by ftp_response:interpret/1. Note there are som ftp status codes" + "that will not be received with the current ftp instruction support," + "they are not included here."]; +ftp_other_status_codes(suite) -> + []; +ftp_other_status_codes(Config) when is_list(Config) -> + + %% 1XX + {pos_prel, _ } = ftp_response:interpret("120 Foobar\r\n"), + + %% 2XX + {pos_compl, _ } = ftp_response:interpret("202 Foobar\r\n"), + {pos_compl, _ } = ftp_response:interpret("221 Foobar\r\n"), + {pos_compl, _ } = ftp_response:interpret("227 Foobar\r\n"), + {pos_compl, _ } = ftp_response:interpret("230 Foobar\r\n"), + {pos_compl, _ } = ftp_response:interpret("250 Foobar\r\n"), + + %% 3XX + {pos_interm_acct, _ } = ftp_response:interpret("332 Foobar\r\n"), + {pos_interm, _ } = ftp_response:interpret("350 Foobar\r\n"), + + %% 4XX + {trans_neg_compl, _ } = ftp_response:interpret("421 Foobar\r\n"), + {trans_neg_compl, _ } = ftp_response:interpret("426 Foobar\r\n"), + {trans_neg_compl, _ } = ftp_response:interpret("450 Foobar\r\n"), + {trans_neg_compl, _ } = ftp_response:interpret("451 Foobar\r\n"), + {etnospc, _ } = ftp_response:interpret("452 Foobar\r\n"), + + %% 5XX + {perm_neg_compl, _ } = ftp_response:interpret("500 Foobar\r\n"), + {perm_neg_compl, _ } = ftp_response:interpret("501 Foobar\r\n"), + {perm_neg_compl, _ } = ftp_response:interpret("503 Foobar\r\n"), + {perm_neg_compl, _ } = ftp_response:interpret("504 Foobar\r\n"), + {perm_neg_compl, _ } = ftp_response:interpret("530 Foobar\r\n"), + {perm_neg_compl, _ } = ftp_response:interpret("532 Foobar\r\n"), + {epath, _ } = ftp_response:interpret("550 Foobar\r\n"), + {epnospc, _ } = ftp_response:interpret("552 Foobar\r\n"), + {efnamena, _ } = ftp_response:interpret("553 Foobar\r\n"), + ok. + +ftp_multipel_ctrl_messages(doc) -> + ["The ftp server may send more than one control message as a reply," + "check that they are handled one at the time."]; +ftp_multipel_ctrl_messages(suite) -> + []; +ftp_multipel_ctrl_messages(Config) when is_list(Config) -> + FtpResponse = ["200 PORT command successful.\r\n200 Foobar\r\n"], + + {"200 PORT command successful.\r\n" = Msg, NextMsg} = + parse(ftp_response, parse_lines, [[], start], FtpResponse), + {pos_compl, _} = ftp_response:interpret(Msg), + NewMsg = parse(ftp_response, parse_lines, [[], start], NextMsg), + {pos_compl, _} = ftp_response:interpret(NewMsg), + ok. + + +%%------------------------------------------------------------------------- +format_error(doc) -> + [""]; +format_error(suite) -> + []; +format_error(Config) when is_list(Config) -> + "Synchronisation error during chunk sending." = + ftp:formaterror(echunk), + "Session has been closed." = ftp:formaterror(eclosed), + "Connection to remote server prematurely closed." = + ftp:formaterror(econn), + "File or directory already exists." = ftp:formaterror(eexists), + "Host not found, FTP server not found, or connection rejected." = + ftp:formaterror(ehost), + "User not logged in." = ftp:formaterror(elogin), + "Term is not a binary." = ftp:formaterror(enotbinary), + "No such file or directory, already exists, or permission denied." + = ftp:formaterror(epath), + "No such type." = ftp:formaterror(etype), + "User name or password not valid." = ftp:formaterror(euser), + "Insufficient storage space in system." = ftp:formaterror(etnospc), + "Exceeded storage allocation (for current directory or dataset)." + = ftp:formaterror(epnospc), + "File name not allowed." = ftp:formaterror(efnamena), + "Unknown error: foobar" = ftp:formaterror({error, foobar}). + +%%-------------------------------------------------------------------- +%%% Internal functions +%%-------------------------------------------------------------------- +parse(Module, Function, Args, Bin) when is_binary(Bin) -> + parse(Module, Function, Args, [binary_to_list(Bin)]); + +parse(Module, Function, [AccLines, StatusCode], [Data | Rest]) -> + case Module:Function(list_to_binary(Data), AccLines, StatusCode) of + {ok, Result, <<>>} -> + Result; + {ok, Result, Next} -> + {Result, Next}; + {continue, {NewData, NewAccLines, NewStatusCode}} -> + case Rest of + [] -> + test_server:fail({wrong_input, Data, Rest}); + [_ | _] -> + parse(Module, Function, [NewAccLines, NewStatusCode], + [binary_to_list(NewData) ++ hd(Rest) | tl(Rest)]) + end + end. diff --git a/lib/inets/test/ftp_freebsd_x86_test.erl b/lib/inets/test/ftp_freebsd_x86_test.erl new file mode 100644 index 0000000000..457e18ffbe --- /dev/null +++ b/lib/inets/test/ftp_freebsd_x86_test.erl @@ -0,0 +1,153 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_freebsd_x86_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Freebsd x86 "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(freebsd_x86, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_internal.hrl b/lib/inets/test/ftp_internal.hrl new file mode 120000 index 0000000000..af57081f14 --- /dev/null +++ b/lib/inets/test/ftp_internal.hrl @@ -0,0 +1 @@ +../src/ftp/ftp_internal.hrl
\ No newline at end of file diff --git a/lib/inets/test/ftp_linux_ppc_test.erl b/lib/inets/test/ftp_linux_ppc_test.erl new file mode 100644 index 0000000000..ad38137678 --- /dev/null +++ b/lib/inets/test/ftp_linux_ppc_test.erl @@ -0,0 +1,151 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_linux_ppc_test). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Linux ppc "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(linux_ppc, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). diff --git a/lib/inets/test/ftp_linux_x86_test.erl b/lib/inets/test/ftp_linux_x86_test.erl new file mode 100644 index 0000000000..b9c88d121a --- /dev/null +++ b/lib/inets/test/ftp_linux_x86_test.erl @@ -0,0 +1,160 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_linux_x86_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Linux x86 "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(linux_x86, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [ + open, + open_port, + passive, + active, + api_missuse, + not_owner, + progress_report + ]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_macosx_ppc_test.erl b/lib/inets/test/ftp_macosx_ppc_test.erl new file mode 100644 index 0000000000..cf548a73c0 --- /dev/null +++ b/lib/inets/test/ftp_macosx_ppc_test.erl @@ -0,0 +1,152 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_macosx_ppc_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Macosx ppc "). + + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(macosx_ppc, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(_X) -> {skipped,"unknown error"}.%?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(_X) -> {skipped,"unknown error"}.%%?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_macosx_x86_test.erl b/lib/inets/test/ftp_macosx_x86_test.erl new file mode 100644 index 0000000000..c59a992421 --- /dev/null +++ b/lib/inets/test/ftp_macosx_x86_test.erl @@ -0,0 +1,152 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_macosx_x86_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Macosx x86 "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(macosx_x86, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_netbsd_x86_test.erl b/lib/inets/test/ftp_netbsd_x86_test.erl new file mode 100644 index 0000000000..a5711b7bde --- /dev/null +++ b/lib/inets/test/ftp_netbsd_x86_test.erl @@ -0,0 +1,152 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_netbsd_x86_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Netbsd x86 "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(netbsd_x86, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_openbsd_x86_test.erl b/lib/inets/test/ftp_openbsd_x86_test.erl new file mode 100644 index 0000000000..4833b6332b --- /dev/null +++ b/lib/inets/test/ftp_openbsd_x86_test.erl @@ -0,0 +1,151 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_openbsd_x86_test). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Openbsd x86 "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(openbsd_x86, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). diff --git a/lib/inets/test/ftp_solaris10_sparc_test.erl b/lib/inets/test/ftp_solaris10_sparc_test.erl new file mode 100644 index 0000000000..6066195f9b --- /dev/null +++ b/lib/inets/test/ftp_solaris10_sparc_test.erl @@ -0,0 +1,154 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_solaris10_sparc_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Solaris 10 sparc "). + + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(solaris10_sparc, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_solaris10_x86_test.erl b/lib/inets/test/ftp_solaris10_x86_test.erl new file mode 100644 index 0000000000..3bd99fc3f2 --- /dev/null +++ b/lib/inets/test/ftp_solaris10_x86_test.erl @@ -0,0 +1,155 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_solaris10_x86_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD, ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_), ?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM, "Solaris 10 x86 "). + + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(solaris10_x86, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_solaris8_sparc_test.erl b/lib/inets/test/ftp_solaris8_sparc_test.erl new file mode 100644 index 0000000000..9764071cd9 --- /dev/null +++ b/lib/inets/test/ftp_solaris8_sparc_test.erl @@ -0,0 +1,152 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_solaris8_sparc_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Solaris 8 sparc "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(solaris8_sparc, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_solaris9_sparc_test.erl b/lib/inets/test/ftp_solaris9_sparc_test.erl new file mode 100644 index 0000000000..a9f77bbdac --- /dev/null +++ b/lib/inets/test/ftp_solaris9_sparc_test.erl @@ -0,0 +1,151 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_solaris9_sparc_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Solaris 9 sparc "). +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(solaris9_sparc, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_suite_lib.erl b/lib/inets/test/ftp_suite_lib.erl new file mode 100644 index 0000000000..75e1a5a7f9 --- /dev/null +++ b/lib/inets/test/ftp_suite_lib.erl @@ -0,0 +1,1593 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_suite_lib). + + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include("inets_test_lib.hrl"). + +%% Test server specific exports +% -export([init_per_testcase/2, end_per_testcase/2]). + +-compile(export_all). + + +-record(progress, { + current = 0, + total + }). + + + +-define(FTP_USER, "anonymous"). +-define(FTP_PASS, passwd()). +-define(FTP_PORT, 21). + +-define(BAD_HOST, "badhostname"). +-define(BAD_USER, "baduser"). +-define(BAD_DIR, "baddirectory"). + +-ifdef(ftp_debug_client). +-define(ftp_open(Host, Flags), + do_ftp_open(Host, [debug, {timeout, timer:seconds(15)}] ++ Flags)). +-else. +-ifdef(ftp_trace_client). +-define(ftp_open(Host, Flags), + do_ftp_open(Host, [trace, {timeout, timer:seconds(15)}] ++ Flags)). +-else. +-define(ftp_open(Host, Flags), + do_ftp_open(Host, [verbose, {timeout, timer:seconds(15)}] ++ Flags)). +-endif. +-endif. + +%% -- Tickets -- + +tickets(doc) -> + "Test cases for reported bugs"; +tickets(suite) -> + [ticket_6035]. + +%% -- + +ftpd_init(FtpdTag, Config) -> + %% Get the host name(s) of FTP server + Hosts = + case ?config(ftpd_hosts, Config) of + undefined -> + ftpd_hosts(data_dir(Config)); + H -> + H + end, + p("ftpd_init -> " + "~n Hosts: ~p" + "~n Config: ~p" + "~n FtpdTag: ~p", [Hosts, Config, FtpdTag]), + %% Get the first host that actually have a running FTP server + case lists:keysearch(FtpdTag, 1, Hosts) of + {value, {_, TagHosts}} when is_list(TagHosts) -> + inets:start(), + case (catch get_ftpd_host(TagHosts)) of + {ok, Host} -> + inets:stop(), + [{ftp_remote_host, Host}|Config]; + _ -> + inets:stop(), + Reason = lists:flatten( + io_lib:format("Could not find a valid " + "FTP server for ~p (~p)", + [FtpdTag, TagHosts])), + {skip, Reason} + end; + _ -> + Reason = lists:flatten( + io_lib:format("No host(s) running FTPD server " + "for ~p", [FtpdTag])), + {skip, Reason} + end. + +ftpd_fin(Config) -> + lists:keydelete(ftp_remote_host, 1, Config). + +get_ftpd_host([]) -> + {error, no_host}; +get_ftpd_host([Host|Hosts]) -> + p("get_ftpd_host -> entry with" + "~n Host: ~p" + "~n", [Host]), + case (catch ftp:open({option_list, + [{host, Host}, {port, ?FTP_PORT}, + {timeout, 20000}]})) of + {ok, Pid} -> + (catch ftp:close(Pid)), + {ok, Host}; + _ -> + get_ftpd_host(Hosts) + end. + + +%%-------------------------------------------------------------------- + +dirty_select_ftpd_host(Config) -> + Hosts = + case ?config(ftpd_hosts, Config) of + undefined -> + ftpd_hosts(data_dir(Config)); + H -> + H + end, + dirty_select_ftpd_host2(Hosts). + +dirty_select_ftpd_host2([]) -> + throw({error, not_found}); +dirty_select_ftpd_host2([{PlatformTag, Hosts} | PlatformHosts]) -> + case dirty_select_ftpd_host3(Hosts) of + none -> + dirty_select_ftpd_host2(PlatformHosts); + {ok, Host} -> + {PlatformTag, Host} + end. + +dirty_select_ftpd_host3([]) -> + none; +dirty_select_ftpd_host3([Host|Hosts]) when is_list(Host) -> + case dirty_select_ftpd_host4(Host) of + true -> + {ok, Host}; + false -> + dirty_select_ftpd_host3(Hosts) + end; +dirty_select_ftpd_host3([_|Hosts]) -> + dirty_select_ftpd_host3(Hosts). + +%% This is a very simple and dirty test that there is a +%% (FTP) deamon on the other end. +dirty_select_ftpd_host4(Host) -> + Port = 21, + IpFam = inet, + Opts = [IpFam, binary, {packet, 0}, {active, false}], + Timeout = ?SECS(5), + case gen_tcp:connect(Host, Port, Opts, Timeout) of + {ok, Sock} -> + gen_tcp:close(Sock), + true; + _Error -> + false + end. + + +%%-------------------------------------------------------------------- + +test_filenames() -> + {ok, Host} = inet:gethostname(), + File = Host ++ "_ftp_test.txt", + NewFile = "new_" ++ File, + {File, NewFile}. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(Case, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) + when (Case =:= open) orelse (Case =:= open_port) -> + io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE, Case]), + inets:start(), + NewConfig = data_dir(Config), + watch_dog(NewConfig); + +init_per_testcase(Case, Config) -> + put(ftp_testcase, Case), + inets:enable_trace(max, io, ftpc), + do_init_per_testcase(Case, Config). + +do_init_per_testcase(Case, Config) + when (Case =:= passive_user) -> + io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE,Case]), + inets:start(), + NewConfig = close_connection(watch_dog(Config)), + Host = ftp_host(Config), + case (catch ?ftp_open(Host, [])) of + {ok, Pid} -> + [{ftp, Pid} | data_dir(NewConfig)]; + {skip, _} = SKIP -> + SKIP + end; + +do_init_per_testcase(Case, Config) + when (Case =:= active_user) -> + io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE, Case]), + inets:start(), + NewConfig = close_connection(watch_dog(Config)), + Host = ftp_host(Config), + case (catch ?ftp_open(Host, [])) of + {ok, Pid} -> + ok = ftp:force_active(Pid), + [{ftp, Pid} | data_dir(NewConfig)]; + {skip, _} = SKIP -> + SKIP + end; + +do_init_per_testcase(Case, Config) + when (Case =:= progress_report_send) orelse + (Case =:= progress_report_recv) -> + inets:start(), + io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE, Case]), + NewConfig = close_connection(watch_dog(Config)), + Host = ftp_host(Config), + Opts = [{host, Host}, + {port, ?FTP_PORT}, + {flags, [verbose]}, + {progress, {?MODULE, progress, #progress{}}}], + case ftp:open({option_list, Opts}) of + {ok, Pid} -> + ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS), + [{ftp, Pid} | data_dir(NewConfig)]; + {skip, _} = SKIP -> + SKIP + end; + +do_init_per_testcase(Case, Config) -> + io:format(user,"~n~n*** INIT ~w:~w ***~n~n", [?MODULE, Case]), + inets:start(), + NewConfig = close_connection(watch_dog(Config)), + Host = ftp_host(Config), + Flags = + if + ((Case =:= passive_ip_v6_disabled) orelse + (Case =:= active_ip_v6_disabled)) -> + [ip_v6_disabled]; + true -> + [] + end, + case (catch ?ftp_open(Host, Flags)) of + {ok, Pid} -> + case string:tokens(atom_to_list(Case), [$_]) of + [_, "active"|_] -> + ok = ftp:force_active(Pid); + _ -> + ok + end, + ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS), + [{ftp, Pid} | data_dir(NewConfig)]; + {skip, _} = SKIP -> + SKIP + end. + + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(Case, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(_, Config) -> + NewConfig = close_connection(Config), + Dog = ?config(watchdog, NewConfig), + inets:stop(), + test_server:timetrap_cancel(Dog), + ok. + + +%%------------------------------------------------------------------------- +%% Suites similar for all hosts. +%%------------------------------------------------------------------------- + +passive(suite) -> + [ + passive_user, + passive_pwd, + passive_cd, + passive_lcd, + passive_ls, + passive_nlist, + passive_rename, + passive_delete, + passive_mkdir, + passive_send, + passive_send_bin, + passive_send_chunk, + passive_append, + passive_append_bin, + passive_append_chunk, + passive_recv, + passive_recv_bin, + passive_recv_chunk, + passive_type, + passive_quote, + passive_ip_v6_disabled + ]. + +active(suite) -> + [ + active_user, + active_pwd, + active_cd, + active_lcd, + active_ls, + active_nlist, + active_rename, + active_delete, + active_mkdir, + active_send, + active_send_bin, + active_send_chunk, + active_append, + active_append_bin, + active_append_chunk, + active_recv, + active_recv_bin, + active_recv_chunk, + active_type, + active_quote, + active_ip_v6_disabled + ]. + + + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- + +open(doc) -> + ["Open an ftp connection to a host and close the connection." + "Also check that !-messages does not disturbe the connection"]; +open(suite) -> + []; +open(Config) when is_list(Config) -> + Host = ftp_host(Config), + (catch tc_open(Host)). + +tc_open(Host) -> + {ok, Pid} = ?ftp_open(Host, []), + ok = ftp:close(Pid), + {ok, Pid1} = + ftp:open({option_list, [{host,Host}, + {port, ?FTP_PORT}, + {flags, [verbose]}, + {timeout, 30000}]}), + ok = ftp:close(Pid1), + {error, ehost} = ftp:open({option_list, [{port, ?FTP_PORT}, + {flags, [verbose]}]}), + {ok, Pid2} = ftp:open(Host), + ok = ftp:close(Pid2), + + {ok, NewHost} = inet:getaddr(Host, inet), + {ok, Pid3} = ftp:open(NewHost), + ftp:user(Pid3, ?FTP_USER, ?FTP_PASS), + Pid3 ! foobar, + test_server:sleep(5000), + {message_queue_len, 0} = process_info(self(), message_queue_len), + ["200" ++ _] = ftp:quote(Pid3, "NOOP"), + ok = ftp:close(Pid3), + + %% Bad input that has default values are ignored and the defult + %% is used. + {ok, Pid4} = + ftp:open({option_list, [{host, Host}, {port, badarg}, + {flags, [verbose]}, + {timeout, 30000}]}), + test_server:sleep(100), + ok = ftp:close(Pid4), + {ok, Pid5} = + ftp:open({option_list, [{host, Host}, {port, ?FTP_PORT}, + {flags, [verbose]}, + {timeout, -42}]}), + test_server:sleep(100), + ok = ftp:close(Pid5), + {ok, Pid6} = + ftp:open({option_list, [{host, Host}, {port, ?FTP_PORT}, + {flags, [verbose]}, + {mode, cool}]}), + test_server:sleep(100), + ok = ftp:close(Pid6), + ok. + + +%%------------------------------------------------------------------------- + +open_port(doc) -> + ["Open an ftp connection to a host with given port number " + "and close the connection."]; % See also OTP-3892 +open_port(suite) -> + []; +open_port(Config) when is_list(Config) -> + Host = ftp_host(Config), + {ok, Pid} = ftp:open(Host, ?FTP_PORT), + ok = ftp:close(Pid), + {error, ehost} = ftp:open(?BAD_HOST, []), + ok. + + +%%------------------------------------------------------------------------- + +passive_user(doc) -> + ["Open an ftp connection to a host, and logon as anonymous ftp."]; +passive_user(suite) -> + []; +passive_user(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + io:format("Pid: ~p~n",[Pid]), + do_user(Pid). + + +%%------------------------------------------------------------------------- + +passive_pwd(doc) -> + ["Test ftp:pwd/1 & ftp:lpwd/1"]; +passive_pwd(suite) -> + []; +passive_pwd(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_pwd(Pid). + + +%%------------------------------------------------------------------------- + +passive_cd(doc) -> + ["Open an ftp connection, log on as anonymous ftp, and cd to the" + "directory \"/pub\" and the to the non-existent directory."]; +passive_cd(suite) -> + []; +passive_cd(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_cd(Pid). + + +%%------------------------------------------------------------------------- + +passive_lcd(doc) -> + ["Test api function ftp:lcd/2"]; +passive_lcd(suite) -> + []; +passive_lcd(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + PrivDir = ?config(priv_dir, Config), + do_lcd(Pid, PrivDir). + + +%%------------------------------------------------------------------------- + +passive_ls(doc) -> + ["Open an ftp connection; ls the current directory, and the " + "\"incoming\" directory. We assume that ls never fails, since " + "it's output is meant to be read by humans. "]; +passive_ls(suite) -> + []; +passive_ls(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_ls(Pid). + + +%%------------------------------------------------------------------------- + +passive_nlist(doc) -> + ["Open an ftp connection; nlist the current directory, and the " + "\"incoming\" directory. Nlist does not behave consistenly over " + "operating systems. On some it is an error to have an empty " + "directory."]; +passive_nlist(suite) -> + []; +passive_nlist(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_nlist(Pid). + + +%%------------------------------------------------------------------------- + +passive_rename(doc) -> + ["Transfer a file to the server, and rename it; then remove it."]; +passive_rename(suite) -> + []; +passive_rename(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_rename(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_delete(doc) -> + ["Transfer a file to the server, and then delete it"]; +passive_delete(suite) -> + []; +passive_delete(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_delete(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_mkdir(doc) -> + ["Make a remote directory, cd to it, go to parent directory, and " + "remove the directory."]; +passive_mkdir(suite) -> + []; +passive_mkdir(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_mkdir(Pid). + + +%%------------------------------------------------------------------------- + +passive_send(doc) -> + ["Create a local file in priv_dir; open an ftp connection to a host; " + "logon as anonymous ftp; cd to the directory \"incoming\"; lcd to " + "priv_dir; send the file; get a directory listing and check that " + "the file is on the list;, delete the remote file; get another listing " + "and check that the file is not on the list; close the session; " + "delete the local file."]; +passive_send(suite) -> + []; +passive_send(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_send(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_append(doc) -> + ["Create a local file in priv_dir; open an ftp connection to a host; " + "logon as anonymous ftp; cd to the directory \"incoming\"; lcd to " + "priv_dir; append the file to a file at the remote side that not exits" + "this will create the file at the remote side. Then it append the file " + "again. When this is done it recive the remote file and control that" + "the content is doubled in it.After that it will remove the files"]; +passive_append(suite) -> + []; +passive_append(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_append(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_send_bin(doc) -> + ["Open a connection to a host; cd to the directory \"incoming\"; " + "send a binary; remove file; close the connection."]; +passive_send_bin(suite) -> + []; +passive_send_bin(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_send_bin(Pid, Config). + +%%------------------------------------------------------------------------- + +passive_append_bin(doc) -> + ["Open a connection to a host; cd to the directory \"incoming\"; " + "append a binary twice; get the file and compare the content" + "remove file; close the connection."]; +passive_append_bin(suite) -> + []; +passive_append_bin(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_append_bin(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_send_chunk(doc) -> + ["Open a connection to a host; cd to the directory \"incoming\"; " + "send chunks; remove file; close the connection."]; +passive_send_chunk(suite) -> + []; +passive_send_chunk(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_send_chunk(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_append_chunk(doc) -> + ["Open a connection to a host; cd to the directory \"incoming\"; " + "append chunks;control content remove file; close the connection."]; +passive_append_chunk(suite) -> + []; +passive_append_chunk(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_append_chunk(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_recv(doc) -> + ["Create a local file and transfer it to the remote host into the " + "the \"incoming\" directory, remove " + "the local file. Then open a new connection; cd to \"incoming\", " + "lcd to the private directory; receive the file; delete the " + "remote file; close connection; check that received file is in " + "the correct directory; cleanup." ]; +passive_recv(suite) -> + []; +passive_recv(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_recv(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_recv_bin(doc) -> + ["Send a binary to the remote host; and retreive " + "the file; then remove the file."]; +passive_recv_bin(suite) -> + []; +passive_recv_bin(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_recv_bin(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_recv_chunk(doc) -> + ["Send a binary to the remote host; Connect again, and retreive " + "the file; then remove the file."]; +passive_recv_chunk(suite) -> + []; +passive_recv_chunk(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_recv_chunk(Pid, Config). + + +%%------------------------------------------------------------------------- + +passive_type(doc) -> + ["Test that we can change btween ASCCI and binary transfer mode"]; +passive_type(suite) -> + []; +passive_type(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_type(Pid). + + +%%------------------------------------------------------------------------- + +passive_quote(doc) -> + [""]; +passive_quote(suite) -> + []; +passive_quote(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_quote(Pid). + + +%%------------------------------------------------------------------------- + +passive_ip_v6_disabled(doc) -> + ["Test ipv4 command PASV"]; +passive_ip_v6_disabled(suite) -> + []; +passive_ip_v6_disabled(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_send(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_user(doc) -> + ["Open an ftp connection to a host, and logon as anonymous ftp."]; +active_user(suite) -> + []; +active_user(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_user(Pid). + + +%%------------------------------------------------------------------------- + +active_pwd(doc) -> + ["Test ftp:pwd/1 & ftp:lpwd/1"]; +active_pwd(suite) -> + []; +active_pwd(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_pwd(Pid). + + +%%------------------------------------------------------------------------- + +active_cd(doc) -> + ["Open an ftp connection, log on as anonymous ftp, and cd to the" + "directory \"/pub\" and to a non-existent directory."]; +active_cd(suite) -> + []; +active_cd(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_cd(Pid). + + +%%------------------------------------------------------------------------- + +active_lcd(doc) -> + ["Test api function ftp:lcd/2"]; +active_lcd(suite) -> + []; +active_lcd(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + PrivDir = ?config(priv_dir, Config), + do_lcd(Pid, PrivDir). + + +%%------------------------------------------------------------------------- + +active_ls(doc) -> + ["Open an ftp connection; ls the current directory, and the " + "\"incoming\" directory. We assume that ls never fails, since " + "it's output is meant to be read by humans. "]; +active_ls(suite) -> + []; +active_ls(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_ls(Pid). + + +%%------------------------------------------------------------------------- + +active_nlist(doc) -> + ["Open an ftp connection; nlist the current directory, and the " + "\"incoming\" directory. Nlist does not behave consistenly over " + "operating systems. On some it is an error to have an empty " + "directory."]; +active_nlist(suite) -> + []; +active_nlist(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_nlist(Pid). + + +%%------------------------------------------------------------------------- + +active_rename(doc) -> + ["Transfer a file to the server, and rename it; then remove it."]; +active_rename(suite) -> + []; +active_rename(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_rename(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_delete(doc) -> + ["Transfer a file to the server, and then delete it"]; +active_delete(suite) -> + []; +active_delete(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_delete(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_mkdir(doc) -> + ["Make a remote directory, cd to it, go to parent directory, and " + "remove the directory."]; +active_mkdir(suite) -> + []; +active_mkdir(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_mkdir(Pid). + + +%%------------------------------------------------------------------------- + +active_send(doc) -> + ["Create a local file in priv_dir; open an ftp connection to a host; " + "logon as anonymous ftp; cd to the directory \"incoming\"; lcd to " + "priv_dir; send the file; get a directory listing and check that " + "the file is on the list;, delete the remote file; get another listing " + "and check that the file is not on the list; close the session; " + "delete the local file."]; +active_send(suite) -> + []; +active_send(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_send(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_append(doc) -> + ["Create a local file in priv_dir; open an ftp connection to a host; " + "logon as anonymous ftp; cd to the directory \"incoming\"; lcd to " + "priv_dir; append the file to a file at the remote side that not exits" + "this will create the file at the remote side. Then it append the file " + "again. When this is done it recive the remote file and control that" + "the content is doubled in it.After that it will remove the files"]; +active_append(suite) -> + []; +active_append(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_append(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_send_bin(doc) -> + ["Open a connection to a host; cd to the directory \"incoming\"; " + "send a binary; remove file; close the connection."]; +active_send_bin(suite) -> + []; +active_send_bin(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_send_bin(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_append_bin(doc) -> + ["Open a connection to a host; cd to the directory \"incoming\"; " + "append a binary twice; get the file and compare the content" + "remove file; close the connection."]; +active_append_bin(suite) -> + []; +active_append_bin(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_append_bin(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_send_chunk(doc) -> + ["Open a connection to a host; cd to the directory \"incoming\"; " + "send chunks; remove file; close the connection."]; +active_send_chunk(suite) -> + []; +active_send_chunk(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_send_chunk(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_append_chunk(doc) -> + ["Open a connection to a host; cd to the directory \"incoming\"; " + "append chunks;control content remove file; close the connection."]; +active_append_chunk(suite) -> + []; +active_append_chunk(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_append_chunk(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_recv(doc) -> + ["Create a local file and transfer it to the remote host into the " + "the \"incoming\" directory, remove " + "the local file. Then open a new connection; cd to \"incoming\", " + "lcd to the private directory; receive the file; delete the " + "remote file; close connection; check that received file is in " + "the correct directory; cleanup." ]; +active_recv(suite) -> + []; +active_recv(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_recv(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_recv_bin(doc) -> + ["Send a binary to the remote host; and retreive " + "the file; then remove the file."]; +active_recv_bin(suite) -> + []; +active_recv_bin(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_recv_bin(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_recv_chunk(doc) -> + ["Send a binary to the remote host; Connect again, and retreive " + "the file; then remove the file."]; +active_recv_chunk(suite) -> + []; +active_recv_chunk(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_recv_chunk(Pid, Config). + + +%%------------------------------------------------------------------------- + +active_type(doc) -> + ["Test that we can change btween ASCCI and binary transfer mode"]; +active_type(suite) -> + []; +active_type(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_type(Pid). + + +%%------------------------------------------------------------------------- + +active_quote(doc) -> + [""]; +active_quote(suite) -> + []; +active_quote(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_quote(Pid). + + +%%------------------------------------------------------------------------- + +active_ip_v6_disabled(doc) -> + ["Test ipv4 command PORT"]; +active_ip_v6_disabled(suite) -> + []; +active_ip_v6_disabled(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + do_send(Pid, Config). + + +%%------------------------------------------------------------------------- + +api_missuse(doc)-> + ["Test that behaviour of the ftp process if the api is abused"]; +api_missuse(suite) -> []; +api_missuse(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + Host = ftp_host(Config), + + %% Serious programming fault, connetion will be shut down + {error, {connection_terminated, 'API_violation'}} = + gen_server:call(Pid, {self(), foobar, 10}, infinity), + test_server:sleep(500), + undefined = process_info(Pid, status), + + {ok, Pid2} = ?ftp_open(Host, []), + %% Serious programming fault, connetion will be shut down + gen_server:cast(Pid2, {self(), foobar, 10}), + test_server:sleep(500), + undefined = process_info(Pid2, status), + + {ok, Pid3} = ?ftp_open(Host, []), + %% Could be an innocent misstake the connection lives. + Pid3 ! foobar, + test_server:sleep(500), + {status, _} = process_info(Pid3, status), + ok. + + +%%------------------------------------------------------------------------- + +not_owner(doc) -> + ["Test what happens if a process that not owns the connection tries " + "to use it"]; +not_owner(suite) -> + []; +not_owner(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + OtherPid = spawn_link(?MODULE, not_owner, [Pid, self()]), + + receive + {OtherPid, ok} -> + {ok, _} = ftp:pwd(Pid) + end, + ok. + +not_owner(FtpPid, Pid) -> + {error, not_connection_owner} = ftp:pwd(FtpPid), + ftp:close(FtpPid), + test_server:sleep(100), + Pid ! {self(), ok}. + + +%%------------------------------------------------------------------------- + + +progress_report(doc) -> + ["Solaris 8 sparc test the option progress."]; +progress_report(suite) -> + [progress_report_send, progress_report_recv]. + + +%% -- + +progress_report_send(doc) -> + ["Test the option progress for ftp:send/[2,3]"]; +progress_report_send(suite) -> + []; +progress_report_send(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + ReportPid = + spawn_link(?MODULE, progress_report_receiver_init, [self(), 1]), + do_send(Pid, Config), + receive + {ReportPid, ok} -> + ok + end. + + +%% -- + +progress_report_recv(doc) -> + ["Test the option progress for ftp:recv/[2,3]"]; +progress_report_recv(suite) -> + []; +progress_report_recv(Config) when is_list(Config) -> + Pid = ?config(ftp, Config), + ReportPid = + spawn_link(?MODULE, progress_report_receiver_init, [self(), 3]), + do_recv(Pid, Config), + receive + {ReportPid, ok} -> + ok + end, + ok. + +progress(#progress{} = Progress , _File, {file_size, Total}) -> + progress_report_receiver ! start, + Progress#progress{total = Total}; +progress(#progress{total = Total, current = Current} + = Progress, _File, {transfer_size, 0}) -> + progress_report_receiver ! finish, + case Total of + unknown -> + ok; + Current -> + ok; + _ -> + test_server:fail({error, {progress, {total, Total}, + {current, Current}}}) + end, + Progress; +progress(#progress{current = Current} = Progress, _File, + {transfer_size, Size}) -> + progress_report_receiver ! update, + Progress#progress{current = Current + Size}. + +progress_report_receiver_init(Pid, N) -> + register(progress_report_receiver, self()), + receive + start -> + ok + end, + progress_report_receiver_loop(Pid, N-1). + +progress_report_receiver_loop(Pid, N) -> + receive + update -> + progress_report_receiver_loop(Pid, N); + finish when N =:= 0 -> + Pid ! {self(), ok}; + finish -> + Pid ! {self(), ok}, + receive + start -> + ok + end, + progress_report_receiver_loop(Pid, N-1) + end. + + +%%------------------------------------------------------------------------- +%% Ticket test cases +%%------------------------------------------------------------------------- + +ticket_6035(doc) -> ["Test that owning process that exits with reason " + "'shutdown' does not cause an error message."]; +ticket_6035(suite) -> []; +ticket_6035(Config) -> + p("ticket_6035 -> entry with" + "~n Config: ~p", [Config]), + PrivDir = ?config(priv_dir, Config), + LogFile = filename:join([PrivDir,"ticket_6035.log"]), + try + begin + Host = dirty_select_ftpd_host(Config), + Pid = spawn(?MODULE, open_wait_6035, [Host, self()]), + error_logger:logfile({open, LogFile}), + ok = kill_ftp_proc_6035(Pid,LogFile), + error_logger:logfile(close), + p("ticket_6035 -> done", []), + ok + end + catch + throw:{error, not_found} -> + {skip, "No available FTP servers"} + end. + +kill_ftp_proc_6035(Pid, LogFile) -> + p("kill_ftp_proc_6035 -> entry"), + receive + open -> + p("kill_ftp_proc_6035 -> received open: send shutdown"), + exit(Pid, shutdown), + kill_ftp_proc_6035(Pid, LogFile); + {open_failed, Reason} -> + p("kill_ftp_proc_6035 -> received open_failed" + "~n Reason: ~p", [Reason]), + exit({skip, {failed_openening_server_connection, Reason}}) + after + 5000 -> + p("kill_ftp_proc_6035 -> timeout"), + is_error_report_6035(LogFile) + end. + +open_wait_6035(FtpServer, From) -> + p("open_wait_6035 -> try connect to ~s", [FtpServer]), + case ftp:open(FtpServer, [{timeout, timer:seconds(15)}]) of + {ok, Pid} -> + p("open_wait_6035 -> connected, now login"), + LoginResult = ftp:user(Pid,"anonymous","kldjf"), + p("open_wait_6035 -> login result: ~p", [LoginResult]), + From ! open, + receive + dummy -> + p("open_wait_6035 -> received dummy"), + ok + after + 10000 -> + p("open_wait_6035 -> timeout"), + ok + end, + p("open_wait_6035 -> done(ok)"), + ok; + {error, Reason} -> + p("open_wait_6035 -> open failed" + "~n Reason: ~p", [Reason]), + From ! {open_failed, {Reason, FtpServer}}, + p("open_wait_6035 -> done(error)"), + ok + end. + +is_error_report_6035(LogFile) -> + p("is_error_report_6035 -> entry"), + Res = + case file:read_file(LogFile) of + {ok, Bin} -> + p("is_error_report_6035 -> logfile read"), + read_log_6035(binary_to_list(Bin)); + _ -> + ok + end, + p("is_error_report_6035 -> logfile read result: " + "~n ~p", [Res]), + file:delete(LogFile), + Res. + +read_log_6035("=ERROR REPORT===="++_Rest) -> + error_report; +read_log_6035([_H|T]) -> + read_log_6035(T); +read_log_6035([]) -> + ok. + + +%%-------------------------------------------------------------------- +%% Internal functions +%%-------------------------------------------------------------------- +do_user(Pid) -> + {error, euser} = ftp:user(Pid, ?BAD_USER, ?FTP_PASS), + ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS), + ok. + +do_pwd(Pid) -> + {ok, "/"} = ftp:pwd(Pid), + {ok, Path} = ftp:lpwd(Pid), + {ok, Path} = file:get_cwd(), + ok. + +do_cd(Pid) -> + ok = ftp:cd(Pid, "/pub"), + {error, epath} = ftp:cd(Pid, ?BAD_DIR), + ok. + +do_lcd(Pid, Dir) -> + ok = ftp:lcd(Pid, Dir), + {error, epath} = ftp:lcd(Pid, ?BAD_DIR), + ok. + + +do_ls(Pid) -> + {ok, _} = ftp:ls(Pid), + {ok, _} = ftp:ls(Pid, "incoming"), + %% neither nlist nor ls operates on a directory + %% they operate on a pathname, which *can* be a + %% directory, but can also be a filename or a group + %% of files (including wildcards). + {ok, _} = ftp:ls(Pid, "incom*"), + ok. + +do_nlist(Pid) -> + {ok, _} = ftp:nlist(Pid), + {ok, _} = ftp:nlist(Pid, "incoming"), + %% neither nlist nor ls operates on a directory + %% they operate on a pathname, which *can* be a + %% directory, but can also be a filename or a group + %% of files (including wildcards). + {ok, _} = ftp:nlist(Pid, "incom*"), +%% {error, epath} = ftp:nlist(Pid, ?BAD_DIR), + ok. + +do_rename(Pid, Config) -> + PrivDir = ?config(priv_dir, Config), + LFile = ?config(file, Config), + NewLFile = ?config(new_file, Config), + AbsLFile = filename:absname(LFile, PrivDir), + Contents = "ftp_SUITE test ...", + ok = file:write_file(AbsLFile, list_to_binary(Contents)), + ok = ftp:cd(Pid, "incoming"), + ok = ftp:lcd(Pid, PrivDir), + ftp:delete(Pid, LFile), % reset + ftp:delete(Pid, NewLFile), % reset + ok = ftp:send(Pid, LFile), + {error, epath} = ftp:rename(Pid, NewLFile, LFile), + ok = ftp:rename(Pid, LFile, NewLFile), + ftp:delete(Pid, LFile), % cleanup + ftp:delete(Pid, NewLFile), % cleanup + ok. + +do_delete(Pid, Config) -> + PrivDir = ?config(priv_dir, Config), + LFile = ?config(file, Config), + AbsLFile = filename:absname(LFile, PrivDir), + Contents = "ftp_SUITE test ...", + ok = file:write_file(AbsLFile, list_to_binary(Contents)), + ok = ftp:cd(Pid, "incoming"), + ok = ftp:lcd(Pid, PrivDir), + ftp:delete(Pid,LFile), % reset + ok = ftp:send(Pid, LFile), + ok = ftp:delete(Pid,LFile), + ok. + +do_mkdir(Pid) -> + {A, B, C} = erlang:now(), + NewDir = "nisse_" ++ integer_to_list(A) ++ "_" ++ + integer_to_list(B) ++ "_" ++ integer_to_list(C), + ok = ftp:cd(Pid, "incoming"), + {ok, CurrDir} = ftp:pwd(Pid), + ok = ftp:mkdir(Pid, NewDir), + ok = ftp:cd(Pid, NewDir), + ok = ftp:cd(Pid, CurrDir), + ok = ftp:rmdir(Pid, NewDir), + ok. + +do_send(Pid, Config) -> + PrivDir = ?config(priv_dir, Config), + LFile = ?config(file, Config), + RFile = LFile ++ ".remote", + AbsLFile = filename:absname(LFile, PrivDir), + Contents = "ftp_SUITE test ...", + ok = file:write_file(AbsLFile, list_to_binary(Contents)), + ok = ftp:cd(Pid, "incoming"), + ok = ftp:lcd(Pid, PrivDir), + ok = ftp:send(Pid, LFile, RFile), + {ok, RFilesString} = ftp:nlist(Pid), + RFiles = split(RFilesString), + true = lists:member(RFile, RFiles), + ok = ftp:delete(Pid, RFile), + case ftp:nlist(Pid) of + {error, epath} -> + ok; % No files + {ok, RFilesString1} -> + RFiles1 = split(RFilesString1), + false = lists:member(RFile, RFiles1) + end, + ok = file:delete(AbsLFile). + +do_append(Pid, Config) -> + PrivDir = ?config(priv_dir, Config), + LFile = ?config(file, Config), + RFile = ?config(new_file, Config), + AbsLFile = filename:absname(LFile, PrivDir), + Contents = "ftp_SUITE test:appending\r\n", + + ok = file:write_file(AbsLFile, list_to_binary(Contents)), + ok = ftp:cd(Pid, "incoming"), + ok = ftp:lcd(Pid, PrivDir), + + %% remove files from earlier failed test case + ftp:delete(Pid, RFile), + ftp:delete(Pid, LFile), + + ok = ftp:append(Pid, LFile, RFile), + ok = ftp:append(Pid, LFile, RFile), + ok = ftp:append(Pid, LFile), + + %% Control the contents of the file + {ok, Bin1} = ftp:recv_bin(Pid, RFile), + ok = ftp:delete(Pid, RFile), + ok = file:delete(AbsLFile), + ok = check_content(binary_to_list(Bin1), Contents, double), + + {ok, Bin2} = ftp:recv_bin(Pid, LFile), + ok = ftp:delete(Pid, LFile), + ok = check_content(binary_to_list(Bin2), Contents, singel), + ok. + +do_send_bin(Pid, Config) -> + File = ?config(file, Config), + Contents = "ftp_SUITE test ...", + Bin = list_to_binary(Contents), + ok = ftp:cd(Pid, "incoming"), + {error, enotbinary} = ftp:send_bin(Pid, Contents, File), + ok = ftp:send_bin(Pid, Bin, File), + {ok, RFilesString} = ftp:nlist(Pid), + RFiles = split(RFilesString), + true = lists:member(File, RFiles), + ok = ftp:delete(Pid, File), + ok. + +do_append_bin(Pid, Config) -> + File = ?config(file, Config), + Contents = "ftp_SUITE test ...", + Bin = list_to_binary(Contents), + ok = ftp:cd(Pid, "incoming"), + {error, enotbinary} = ftp:append_bin(Pid, Contents, File), + ok = ftp:append_bin(Pid, Bin, File), + ok = ftp:append_bin(Pid, Bin, File), + %% Control the contents of the file + {ok, Bin2} = ftp:recv_bin(Pid, File), + ok = ftp:delete(Pid,File), + ok = check_content(binary_to_list(Bin2),binary_to_list(Bin), double). + +do_send_chunk(Pid, Config) -> + File = ?config(file, Config), + Contents = "ftp_SUITE test ...", + Bin = list_to_binary(Contents), + ok = ftp:cd(Pid, "incoming"), + ok = ftp:send_chunk_start(Pid, File), + {error, echunk} = ftp:cd(Pid, "incoming"), + {error, enotbinary} = ftp:send_chunk(Pid, Contents), + ok = ftp:send_chunk(Pid, Bin), + ok = ftp:send_chunk(Pid, Bin), + ok = ftp:send_chunk_end(Pid), + {ok, RFilesString} = ftp:nlist(Pid), + RFiles = split(RFilesString), + true = lists:member(File, RFiles), + ok = ftp:delete(Pid, File), + ok. + +do_append_chunk(Pid, Config) -> + File = ?config(file, Config), + Contents = ["ER","LE","RL"], + ok = ftp:cd(Pid, "incoming"), + ok = ftp:append_chunk_start(Pid, File), + {error, enotbinary} = ftp:append_chunk(Pid, lists:nth(1,Contents)), + ok = ftp:append_chunk(Pid,list_to_binary(lists:nth(1,Contents))), + ok = ftp:append_chunk(Pid,list_to_binary(lists:nth(2,Contents))), + ok = ftp:append_chunk(Pid,list_to_binary(lists:nth(3,Contents))), + ok = ftp:append_chunk_end(Pid), + %%Control the contents of the file + {ok, Bin2} = ftp:recv_bin(Pid, File), + ok = check_content(binary_to_list(Bin2),"ERL", double), + ok = ftp:delete(Pid, File), + ok. + +do_recv(Pid, Config) -> + PrivDir = ?config(priv_dir, Config), + File = ?config(file, Config), + Newfile = ?config(new_file, Config), + AbsFile = filename:absname(File, PrivDir), + Contents = "ftp_SUITE:recv test ...", + ok = file:write_file(AbsFile, list_to_binary(Contents)), + ok = ftp:cd(Pid, "incoming"), + ftp:delete(Pid, File), % reset + ftp:lcd(Pid, PrivDir), + ok = ftp:send(Pid, File), + ok = file:delete(AbsFile), % cleanup + test_server:sleep(100), + ok = ftp:lcd(Pid, PrivDir), + ok = ftp:recv(Pid, File), + {ok, Files} = file:list_dir(PrivDir), + true = lists:member(File, Files), + ok = file:delete(AbsFile), % cleanup + ok = ftp:recv(Pid, File, Newfile), + ok = ftp:delete(Pid, File), % cleanup + ok. + +do_recv_bin(Pid, Config) -> + File = ?config(file, Config), + Contents1 = "ftp_SUITE test ...", + Bin1 = list_to_binary(Contents1), + ok = ftp:cd(Pid, "incoming"), + ok = ftp:send_bin(Pid, Bin1, File), + test_server:sleep(100), + {ok, Bin2} = ftp:recv_bin(Pid, File), + ok = ftp:delete(Pid, File), % cleanup + Contents2 = binary_to_list(Bin2), + Contents1 = Contents2, + ok. + +do_recv_chunk(Pid, Config) -> + File = ?config(file, Config), + Data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" + "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" + "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" + "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG" + "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH" + "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII", + + Contents1 = lists:flatten(lists:duplicate(10, Data)), + Bin1 = list_to_binary(Contents1), + ok = ftp:cd(Pid, "incoming"), + ok = ftp:type(Pid, binary), + ok = ftp:send_bin(Pid, Bin1, File), + test_server:sleep(100), + {error, "ftp:recv_chunk_start/2 not called"} = recv_chunk(Pid, <<>>), + ok = ftp:recv_chunk_start(Pid, File), + {ok, Contents2} = recv_chunk(Pid, <<>>), + ok = ftp:delete(Pid, File), % cleanup + ok = find_diff(Contents2, Contents1, 1), + ok. + +do_type(Pid) -> + ok = ftp:type(Pid, ascii), + ok = ftp:type(Pid, binary), + ok = ftp:type(Pid, ascii), + {error, etype} = ftp:type(Pid, foobar), + ok. + +do_quote(Pid) -> + ["257 \"/\""++_Rest] = ftp:quote(Pid, "pwd"), %% 257 + [_| _] = ftp:quote(Pid, "help"), + %% This negativ test causes some ftp servers to hang. This test + %% is not important for the client, so we skip it for now. + %%["425 Can't build data connection: Connection refused."] + %% = ftp:quote(Pid, "list"), + ok. + + watch_dog(Config) -> + Dog = test_server:timetrap(inets_test_lib:minutes(1)), + NewConfig = lists:keydelete(watchdog, 1, Config), + [{watchdog, Dog} | NewConfig]. + + close_connection(Config) -> + case ?config(ftp, Config) of + Pid when is_pid(Pid) -> + ok = ftp:close(Pid), + lists:delete({ftp, Pid}, Config); + _ -> + Config + end. + +ftp_host(Config) -> + case ?config(ftp_remote_host, Config) of + undefined -> + exit({skip, "No host specified"}); + Host -> + Host + end. + +check_content(RContent, LContent, Amount) -> + LContent2 = case Amount of + double -> + LContent ++ LContent; + singel -> + LContent + end, + case string:equal(RContent, LContent2) of + true -> + ok; + false -> + %% Find where the diff is + Where = find_diff(RContent, LContent2, 1), + Where + end. + +find_diff(A, A, _) -> + ok; +find_diff([H|T1], [H|T2], Pos) -> + find_diff(T1, T2, Pos+1); +find_diff(RC, LC, Pos) -> + {error, {diff, Pos, RC, LC}}. + +recv_chunk(Pid, Acc) -> + case ftp:recv_chunk(Pid) of + ok -> + {ok, binary_to_list(Acc)}; + {ok, Bin} -> + recv_chunk(Pid, <<Acc/binary, Bin/binary>>); + Error -> + Error + end. + +split(Cs) -> + split(Cs, [], []). + +split([$\r, $\n| Cs], I, Is) -> + split(Cs, [], [lists:reverse(I)| Is]); +split([C| Cs], I, Is) -> + split(Cs, [C| I], Is); +split([], I, Is) -> + lists:reverse([lists:reverse(I)| Is]). + +do_ftp_open(Host, Flags) -> + io:format("do_ftp_open -> entry with" + "~n Host: ~p" + "~n Flags: ~p", [Host, Flags]), + case ftp:open(Host, Flags) of + {ok, _} = OK -> + OK; + {error, Reason} -> + Str = + lists:flatten( + io_lib:format("Unable to reach test FTP server ~p (~p)", + [Host, Reason])), + throw({skip, Str}) + end. + + +passwd() -> + Host = + case inet:gethostname() of + {ok, H} -> + H; + _ -> + "localhost" + end, + "ftp_SUITE@" ++ Host. + +ftpd_hosts(Config) -> + DataDir = ?config(data_dir, Config), + FileName = filename:join([DataDir, "../ftp_SUITE_data/", ftpd_hosts]), + io:format("FileName: ~p~n", [FileName]), + case file:consult(FileName) of + {ok, [Hosts]} when is_list(Hosts) -> + Hosts; + _ -> + [] + end. + +wrapper(Prefix,doc,Func) -> + Prefix++Func(doc); +wrapper(_,X,Func) -> + Func(X). + +data_dir(Config) -> + case ?config(data_dir, Config) of + List when (length(List) > 0) -> + PathList = filename:split(List), + {NewPathList,_} = lists:split((length(PathList)-1), PathList), + DataDir = filename:join(NewPathList ++ [ftp_SUITE_data]), + NewConfig = + lists:keyreplace(data_dir,1,Config, {data_dir,DataDir}), + NewConfig; + _ -> Config + end. + + + +p(F) -> + p(F, []). + +p(F, A) -> + case get(ftp_testcase) of + undefined -> + io:format("~w [~w] " ++ F ++ "~n", [?MODULE, self() | A]); + TC when is_atom(TC) -> + io:format("~w [~w] ~w:" ++ F ++ "~n", [?MODULE, self(), TC | A]) + end. diff --git a/lib/inets/test/ftp_ticket_test.erl b/lib/inets/test/ftp_ticket_test.erl new file mode 100644 index 0000000000..6748df03bb --- /dev/null +++ b/lib/inets/test/ftp_ticket_test.erl @@ -0,0 +1,51 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_ticket_test). + +-compile(export_all). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Solaris 8 sparc "). + + +%% Test server callbacks +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). + +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + + +all(suite) -> + {conf,init,tickets(),fin}. + +init(Config) -> + ?LIB_MOD:ftpd_init(ticket_test, Config). + +tickets() -> + [ticket_6035]. + + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +ticket_6035(X) -> ?LIB_MOD:ticket_6035(X). diff --git a/lib/inets/test/ftp_windows_2003_server_test.erl b/lib/inets/test/ftp_windows_2003_server_test.erl new file mode 100644 index 0000000000..d24318d04f --- /dev/null +++ b/lib/inets/test/ftp_windows_2003_server_test.erl @@ -0,0 +1,152 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_windows_2003_server_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Windows 2003 server "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(windows_2003_server, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +%% Test cases starts here. + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/ftp_windows_xp_test.erl b/lib/inets/test/ftp_windows_xp_test.erl new file mode 100644 index 0000000000..bc161e4f6a --- /dev/null +++ b/lib/inets/test/ftp_windows_xp_test.erl @@ -0,0 +1,150 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(ftp_windows_xp_test). + +-compile(export_all). + +-include("test_server.hrl"). + +-define(LIB_MOD,ftp_suite_lib). +-define(CASE_WRAPPER(_A_,_B_,_C_),?LIB_MOD:wrapper(_A_,_B_,_C_)). +-define(PLATFORM,"Windows xp "). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + {File, NewFile} = ?LIB_MOD:test_filenames(), + NewConfig = [{file, File}, {new_file, NewFile} | Config], + ?LIB_MOD:ftpd_init(windows_xp, NewConfig). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + ?LIB_MOD:ftpd_fin(Config). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + ftp_suite_lib:init_per_testcase(Case, Config). +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + ftp_suite_lib:end_per_testcase(Case, Config). + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test ftp client"]; + +all(suite) -> + [open, open_port, passive, active, api_missuse, + not_owner, progress_report]. + +open(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open/1). +open_port(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:open_port/1). +passive(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:passive/1). +active(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:active/1). +api_missuse(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:api_missuse/1). +not_owner(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:not_owner/1). +progress_report(X) -> ?CASE_WRAPPER(?PLATFORM,X,fun ?LIB_MOD:progress_report/1). + +passive_user(X) -> ?LIB_MOD:passive_user(X). +passive_pwd(X) -> ?LIB_MOD:passive_pwd(X). +passive_cd(X) -> ?LIB_MOD:passive_cd(X). +passive_lcd(X) -> ?LIB_MOD:passive_lcd(X). +passive_ls(X) -> ?LIB_MOD:passive_ls(X). +passive_nlist(X) -> ?LIB_MOD:passive_nlist(X). +passive_rename(X) -> ?LIB_MOD:passive_rename(X). +passive_delete(X) -> ?LIB_MOD:passive_delete(X). +passive_mkdir(X) -> ?LIB_MOD:passive_mkdir(X). +passive_send(X) -> ?LIB_MOD:passive_send(X). +passive_send_bin(X) -> ?LIB_MOD:passive_send_bin(X). +passive_send_chunk(X) -> ?LIB_MOD:passive_send_chunk(X). +passive_append(X) -> ?LIB_MOD:passive_append(X). +passive_append_bin(X) -> ?LIB_MOD:passive_append_bin(X). +passive_append_chunk(X) -> ?LIB_MOD:passive_append_chunk(X). +passive_recv(X) -> ?LIB_MOD:passive_recv(X). +passive_recv_bin(X) -> ?LIB_MOD:passive_recv_bin(X). +passive_recv_chunk(X) -> ?LIB_MOD:passive_recv_chunk(X). +passive_type(X) -> ?LIB_MOD:passive_type(X). +passive_quote(X) -> ?LIB_MOD:passive_quote(X). +passive_ip_v6_disabled(X) -> ?LIB_MOD:passive_ip_v6_disabled(X). +active_user(X) -> ?LIB_MOD:active_user(X). +active_pwd(X) -> ?LIB_MOD:active_pwd(X). +active_cd(X) -> ?LIB_MOD:active_cd(X). +active_lcd(X) -> ?LIB_MOD:active_lcd(X). +active_ls(X) -> ?LIB_MOD:active_ls(X). +active_nlist(X) -> ?LIB_MOD:active_nlist(X). +active_rename(X) -> ?LIB_MOD:active_rename(X). +active_delete(X) -> ?LIB_MOD:active_delete(X). +active_mkdir(X) -> ?LIB_MOD:active_mkdir(X). +active_send(X) -> ?LIB_MOD:active_send(X). +active_send_bin(X) -> ?LIB_MOD:active_send_bin(X). +active_send_chunk(X) -> ?LIB_MOD:active_send_chunk(X). +active_append(X) -> ?LIB_MOD:active_append(X). +active_append_bin(X) -> ?LIB_MOD:active_append_bin(X). +active_append_chunk(X) -> ?LIB_MOD:active_append_chunk(X). +active_recv(X) -> ?LIB_MOD:active_recv(X). +active_recv_bin(X) -> ?LIB_MOD:active_recv_bin(X). +active_recv_chunk(X) -> ?LIB_MOD:active_recv_chunk(X). +active_type(X) -> ?LIB_MOD:active_type(X). +active_quote(X) -> ?LIB_MOD:active_quote(X). +active_ip_v6_disabled(X) -> ?LIB_MOD:active_ip_v6_disabled(X). +progress_report_send(X) -> ?LIB_MOD:progress_report_send(X). +progress_report_recv(X) -> ?LIB_MOD:progress_report_recv(X). + +fin(Config) -> + ?LIB_MOD:ftpd_fin(Config). diff --git a/lib/inets/test/http_format_SUITE.erl b/lib/inets/test/http_format_SUITE.erl new file mode 100644 index 0000000000..9559317640 --- /dev/null +++ b/lib/inets/test/http_format_SUITE.erl @@ -0,0 +1,585 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(http_format_SUITE). +-author('[email protected]'). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include("http_internal.hrl"). + +%% Test server specific exports +-export([all/1, init_per_testcase/2, end_per_testcase/2]). + +%% Test cases must be exported. +-export([chunk/1, chunk_decode/1, chunk_encode/1, + chunk_extensions_otp_6005/1, chunk_decode_otp_6264/1, + chunk_decode_empty_chunk_otp_6511/1, + chunk_decode_trailer/1, + http_response/1, http_request/1, validate_request_line/1, script/1, + esi_parse_headers/1, cgi_parse_headers/1, + is_absolut_uri/1, convert_netscapecookie_date/1]). + +all(doc) -> + ["Test library functions to the http client and server."]; +all(suite) -> + [chunk, + http_response, http_request, validate_request_line, + script, is_absolut_uri, convert_netscapecookie_date]. + +init_per_testcase(_, Config) -> + Dog = test_server:timetrap(?t:minutes(1)), + NewConfig = lists:keydelete(watchdog, 1, Config), + [{watchdog, Dog} | NewConfig]. + +end_per_testcase(_, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +script(doc) -> + ["Test header parsing in esi/cgi functionality."]; +script(suite) -> + [esi_parse_headers, cgi_parse_headers]. + +chunk(doc) -> + ["Test chunk encoding"]; +chunk(suite) -> + [chunk_decode, chunk_encode, chunk_extensions_otp_6005, + chunk_decode_otp_6264, chunk_decode_empty_chunk_otp_6511, + chunk_decode_trailer]. + +%%------------------------------------------------------------------------- +chunk_decode(doc) -> + ["Test http_chunk:decode/3"]; +chunk_decode(suite) -> + []; +chunk_decode(Config) when is_list(Config) -> + ReqHeaders = #http_request_h{'transfer-encoding' = "chunked"}, + ChunkedBody = "A" ++ ?CRLF ++ "1234567890" ++ ?CRLF ++ "4" ++ + ?CRLF ++ "HEJ!" ++ ?CRLF ++ "0" ++ ?CRLF ++ ?CRLF, + {ok, {Headers, Body}} = + http_chunk:decode(list_to_binary(ChunkedBody), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + "1234567890HEJ!" = binary_to_list(Body), + %% When the "chunked" is removed by the decoding the header + %% will become empty in this case i.e. undefined! + NewReqHeaders = http_chunk:handle_headers(ReqHeaders, Headers), + undefined = NewReqHeaders#http_request_h.'transfer-encoding', + + NewChunkedBody = ["A" ++ [?CR], [?LF] ++ "12345", "67890" ++ ?CRLF ++ "4" + ++ ?CRLF ++ "HEJ!" ++ ?CRLF ++ "0" ++ [?CR], + [?LF, ?CR, ?LF]], + + {Module, Function, Args} = + http_chunk:decode(list_to_binary(hd(NewChunkedBody)), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + + {_, Body} = parse(Module, Function, Args, tl(NewChunkedBody)), + "1234567890HEJ!" = binary_to_list(Body), + + ok. + +%%------------------------------------------------------------------------- +chunk_extensions_otp_6005(doc) -> + ["Make sure so called extensions are ignored"]; +chunk_extensions_otp_6005(suite) -> + []; +chunk_extensions_otp_6005(Config) when is_list(Config)-> + ChunkedBody = "A;ignore this" ++ ?CRLF ++ "1234567890" ++ + ?CRLF ++ "4" ++ ?CRLF ++ "HEJ!"++ ?CRLF ++ "0" ++ + ";extensionname=extensionvalue;foo=bar" ++ ?CRLF ++ ?CRLF, + {ok, {["content-length:14"], Body}} = + http_chunk:decode(list_to_binary(ChunkedBody), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + "1234567890HEJ!" = binary_to_list(Body), + + ChunkedBody1 = ["A;", "ignore this" ++ [?CR], [?LF] ++ "1234567890" ++ + ?CRLF ++ "4" ++ ?CRLF ++ "HEJ!"++ ?CRLF ++ "0" ++ + ";extensionname=extensionvalue;foo=bar" ++ ?CRLF ++ ?CRLF], + + {Module1, Function1, Args1} = + http_chunk:decode(list_to_binary(hd(ChunkedBody1)), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + + {_, NewBody} = parse(Module1, Function1, Args1, tl(ChunkedBody1)), + "1234567890HEJ!" = binary_to_list(NewBody), + ok. + +%%------------------------------------------------------------------------- +chunk_decode_otp_6264(doc) -> + ["Check that 0 in the body does not count as the last chunk"]; +chunk_decode_otp_6264(suite) -> + []; +chunk_decode_otp_6264(Config) when is_list(Config)-> + ChunkedBody = "A;ignore this" ++ ?CRLF ++ "1234567890" ++ + ?CRLF ++ "4" ++ ?CRLF ++ "0123"++ ?CRLF ++ "0" ++ + ";extensionname=extensionvalue;foo=bar" ++ ?CRLF ++ ?CRLF, + {ok, {["content-length:14"], Body}} = + http_chunk:decode(list_to_binary(ChunkedBody), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + "12345678900123" = binary_to_list(Body), + + NewChunkedBody = ["A" ++ [?CR], [?LF] ++ "12345", "67890" ++ ?CRLF ++ "1" + ++ ?CRLF ++ "0" ++ ?CRLF ++ "0" ++ [?CR], + [?LF, ?CR, ?LF]], + + {Module, Function, Args} = + http_chunk:decode(list_to_binary(hd(NewChunkedBody)), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + + {_, NewBody} = parse(Module, Function, Args, tl(NewChunkedBody)), + "12345678900" = binary_to_list(NewBody), + + NewChunkedBody1 = ["A" ++ [?CR], [?LF] ++ "12345", "67890" ++ ?CRLF ++ "1" + ++ ?CRLF ++ "0", ?CRLF ++ "0", [?CR], [?LF], + [?CR], [?LF]], + + {Module1, Function1, Args1} = + http_chunk:decode(list_to_binary(hd(NewChunkedBody1)), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + + {_, NewBody} = parse(Module1, Function1, Args1, tl(NewChunkedBody1)), + "12345678900" = binary_to_list(NewBody), + + ok. +%%------------------------------------------------------------------------- +chunk_decode_empty_chunk_otp_6511(doc) -> + [""]; +chunk_decode_empty_chunk_otp_6511(suite) -> + []; +chunk_decode_empty_chunk_otp_6511(Config) when is_list(Config) -> + ChunkedBody = "0" ++ ?CRLF ++ ?CRLF, + {ok,{["content-length:0"],<<>>}} = + http_chunk:decode(list_to_binary(ChunkedBody), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + ok. + +%%------------------------------------------------------------------------- +chunk_decode_trailer(doc) -> + ["Make sure trailers are handled correctly. Trailers should" + "become new headers"]; +chunk_decode_trailer(suite) -> + []; +chunk_decode_trailer(Config) when is_list(Config)-> + ChunkedBody = "1a; ignore-stuff-here" ++ ?CRLF ++ + "abcdefghijklmnopqrstuvwxyz" ++ ?CRLF ++ "10" ++ ?CRLF + ++ "1234567890abcdef" ++ ?CRLF ++ "0" ++ ?CRLF + ++ "some-footer:some-value" ++ ?CRLF + ++ "another-footer:another-value" ++ ?CRLF ++ ?CRLF, + + {ok, {Headers, Body}} = + http_chunk:decode(list_to_binary(ChunkedBody), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + + %% There is no guaranteed order of headers. + true = lists:member("content-length:42", Headers), + true = lists:member("some-footer:some-value", Headers), + true = lists:member("another-footer:another-value", Headers), + "abcdefghijklmnopqrstuvwxyz1234567890abcdef" = binary_to_list(Body), + + ChunkedBody1 = "1a" ++ ?CRLF ++ + "abcdefghijklmnopqrstuvwxyz" ++ ?CRLF ++ "10" ++ ?CRLF + ++ "1234567890abcdef" ++ ?CRLF ++ "0" ++ ?CRLF + ++ "some-footer:some-value" ++ ?CRLF ++ ?CRLF, + + {ok, {Headers1, Body1}} = + http_chunk:decode(list_to_binary(ChunkedBody1), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + + true = lists:member("content-length:42", Headers1), + true = lists:member("some-footer:some-value", Headers1), + false = lists:member("another-footer:another-value", Headers1), + "abcdefghijklmnopqrstuvwxyz1234567890abcdef" = binary_to_list(Body1), + + + ChunkedBody2 = ["1a", ?CRLF ++ + "abcdefghijklmnopqrstuvwxyz" ++ ?CRLF ++ "10" ++ ?CRLF + ++ "1234567890abcdef" ++ ?CRLF ++ "0", ";", + "ignore stuff here=foobar", ?CRLF ++ + "some-footer:some-value", ?CRLF, ?CRLF], + + {Module, Function, Args} = + http_chunk:decode(list_to_binary(hd(ChunkedBody2)), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + + {_, NewBody} = parse(Module, Function, Args, tl(ChunkedBody2)), + "abcdefghijklmnopqrstuvwxyz1234567890abcdef" = binary_to_list(NewBody), + + ChunkedBody3 = ["1a", ?CRLF ++ + "abcdefghijklmnopqrstuvwxyz", ?CRLF ++ "10" ++ ?CRLF + ++ "1234567890abcdef" ++ ?CRLF ++ "0" ++ ?CRLF + ++ "some-footer:some-value", [?CR], [?LF] , ?CRLF], + + {Module1, Function1, Args1} = + http_chunk:decode(list_to_binary(hd(ChunkedBody3)), + ?HTTP_MAX_BODY_SIZE, ?HTTP_MAX_HEADER_SIZE), + + {_, NewBody} = parse(Module1, Function1, Args1, tl(ChunkedBody3)), + "abcdefghijklmnopqrstuvwxyz1234567890abcdef" = binary_to_list(NewBody), + + ok. + +%%------------------------------------------------------------------------- +chunk_encode(doc) -> + ["Test http_chunk:encode/1 & http_chunk:encode_last/0"]; +chunk_encode(suite) -> + []; +chunk_encode(Config) when is_list(Config) -> + <<54, ?CR, ?LF, 102,111,111,98,97,114, ?CR, ?LF>> = + http_chunk:encode(list_to_binary("foobar")), + ["6", ?CR, ?LF,"foobar", ?CR, ?LF] = http_chunk:encode("foobar"), + <<$0, ?CR, ?LF, ?CR, ?LF >> = http_chunk:encode_last(), + ok. + + +%%------------------------------------------------------------------------- +http_response(doc) -> + ["Test httpc_response:parse*. This test case will simulate that the " + "message will be recived a little at the time on a socket and the " + "package may be broken up into smaller parts at arbitrary point."]; +http_response(suite) -> + []; +http_response(Config) when is_list(Config) -> + + HttpHead1 = ["HTTP", "/1.1 ", "20", "0 ", "ok", [?CR, ?LF], + "content-length:83" ++ ?CRLF ++ "content", "-type:", + "text/html" ++ ?CRLF ++ + "date:Thu, 28 Oct 2004 07:57:43 GMT" ++ + [?CR], [?LF, ?CR, ?LF]], + {"HTTP/1.1", + 200, + "ok", + #http_response_h{'content-length' = "83", + 'content-type' = "text/html", + date = "Thu, 28 Oct 2004 07:57:43 GMT"}, + <<>>} = + parse(httpc_response, parse, [?HTTP_MAX_HEADER_SIZE, false], + HttpHead1), + + HttpHead2 = ["HTTP/1.1 200", " ok", [?CR], [?LF] ++ + "content-length:83" ++ ?CRLF ++ "content-type:", + "text/html" ++ ?CRLF ++ + "date:" ++ "Thu, 28 Oct 2004 07:57:43 GMT" ++ + ?CRLF, ?CRLF], + {"HTTP/1.1", + 200, + "ok", + #http_response_h{'content-length' = "83", + 'content-type' = "text/html", + date = "Thu, 28 Oct 2004 07:57:43 GMT"}, + <<>>} = + parse(httpc_response, parse, [?HTTP_MAX_HEADER_SIZE, false], + HttpHead2), + + HttpHead3 = ["HTTP/1.1 200 ", "ok", ?CRLF ++ + "content-length:83" ++ ?CRLF ++ "content-type:", + "text/html" ++ ?CRLF ++ + "date:" ++ "Thu, 28 Oct 2004 07:57:43 GMT" ++ + [?CR, ?LF,?CR], [?LF]], + {"HTTP/1.1", + 200, + "ok", + #http_response_h{'content-length' = "83", + 'content-type' = "text/html", + date = "Thu, 28 Oct 2004 07:57:43 GMT"}, + <<>>} = + parse(httpc_response, parse, [?HTTP_MAX_HEADER_SIZE, false], + HttpHead3), + + HttpBody = ["<HTML>\n<HEAD>\n<TITLE> dummy </TITLE>\n</HEAD>\n<BODY>\n", + "<H1>dummy</H1>\n</BODY>\n</HTML>\n"], + + NewBody = lists:flatten(HttpBody), + Length = length(NewBody), + NewBody = + binary_to_list(parse + (httpc_response, whole_body, [<<>>,Length], + HttpBody)), + + HttpBody1 = ["<HTML", ">\n<HEAD>", "\n<TITLE> dummy </TITLE>\n</HEAD>\n", + "<BODY>\n", "<H1>du", "mmy</H1>\n</BODY>\n</HTML>\n"], + + NewBody1 = lists:flatten(HttpBody1), + Length1 = length(NewBody1), + NewBody1 = binary_to_list(parse + (httpc_response, whole_body, + [<<>>,Length1], HttpBody1)), + ok. +%%------------------------------------------------------------------------- +http_request(doc) -> + ["Test httpd_request:parse* This test case will simulate that the " + "message will be recived a little at the time on a socket and the " + "package may be broken up into smaller parts at arbitrary point."]; +http_request(suite) -> + []; +http_request(Config) when is_list(Config) -> + + HttpHead = ["GE", "T ", "http://www.erlang", ".org ", "HTTP", + "/1.1" ++ ?CRLF ++ "host:", + "www.erlang.org" ++ [?CR], + [?LF] ++ "te: " ++ ?CRLF, ?CRLF], + {"GET", + "http://www.erlang.org", + "HTTP/1.1", + {#http_request_h{host = "www.erlang.org", te = []}, + ["te: ","host:www.erlang.org"]}, <<>>} = + parse(httpd_request, parse, [?HTTP_MAX_HEADER_SIZE], HttpHead), + + HttpHead1 = ["GET http://www.erlang.org HTTP/1.1" ++ + [?CR], [?LF, ?CR, ?LF]], + {"GET", + "http://www.erlang.org", + "HTTP/1.1", + {#http_request_h{}, []}, <<>>} = + parse(httpd_request, parse, [?HTTP_MAX_HEADER_SIZE], HttpHead1), + + + HttpHead2 = ["GET http://www.erlang.org HTTP/1.1" ++ + [?CR, ?LF, ?CR], [?LF]], + {"GET", + "http://www.erlang.org", + "HTTP/1.1", + {#http_request_h{}, []}, <<>>} = + parse(httpd_request, parse, [?HTTP_MAX_HEADER_SIZE], HttpHead2), + + %% Note the following body is not related to the headers above + HttpBody = ["<HTML>\n<HEAD>\n<TITLE> dummy </TITLE>\n</HEAD>\n<BODY>\n", + "<H1>dummy</H1>\n</BODY>\n</HTML>\n"], + + NewBody = lists:flatten(HttpBody), + Length = length(NewBody), + NewBody = + binary_to_list(parse + (httpd_request, whole_body, [<<>>,Length], HttpBody)), + + HttpBody1 = ["<HTML", ">\n<HEAD>", "\n<TITLE> dummy </TITLE>\n</HEAD>\n", + "<BODY>\n", "<H1>du", "mmy</H1>\n</BODY>\n</HTML>\n"], + + NewBody1 = lists:flatten(HttpBody1), + Length1 = length(NewBody1), + NewBody1 = + binary_to_list(parse + (httpd_request, whole_body, + [<<>>, Length1], HttpBody1)), + ok. +%%------------------------------------------------------------------------- +validate_request_line(doc) -> + ["Test httpd_request:validate/3. Makes sure you can not get past" + " the server_root and that the request is recognized by the server" + " and protcol version." ]; +validate_request_line(suite) -> + []; +validate_request_line(Config) when is_list(Config) -> + + %% HTTP/0.9 only has GET requests + ok = + httpd_request:validate("GET", "http://www.erlang/org", "HTTP/0.9"), + {error, {not_supported, + {"HEAD", "http://www.erlang/org", "HTTP/0.9"}}} = + httpd_request:validate("HEAD", "http://www.erlang/org", "HTTP/0.9"), + {error, {not_supported, + {"TRACE", "http://www.erlang/org", "HTTP/0.9"}}} = + httpd_request:validate("TRACE", "http://www.erlang/org", "HTTP/0.9"), + {error, {not_supported, + {"POST", "http://www.erlang/org", "HTTP/0.9"}}} = + httpd_request:validate("POST", "http://www.erlang/org", "HTTP/0.9"), + + %% HTTP/1.* + ok = httpd_request:validate("HEAD", "http://www.erlang/org", + "HTTP/1.1"), + ok = httpd_request:validate("GET", "http://www.erlang/org", + "HTTP/1.1"), + ok = httpd_request:validate("POST","http://www.erlang/org", + "HTTP/1.1"), + ok = httpd_request:validate("TRACE","http://www.erlang/org", + "HTTP/1.1"), + {error, {not_supported, + {"FOOBAR", "http://www.erlang/org", "HTTP/1.1"}}} = + httpd_request:validate("FOOBAR", "http://www.erlang/org", + "HTTP/1.1"), + + %% Attempts to get outside of server_root directory by relative links + ForbiddenUri = "http://127.0.0.1:8888/../../../../../etc/passwd", + {error, {bad_request, {forbidden, ForbiddenUri}}} = + httpd_request:validate("GET", ForbiddenUri, "HTTP/1.1"), + + ForbiddenUri2 = + "http://127.0.0.1:8888/././././././../../../../../etc/passwd", + {error, {bad_request, {forbidden, ForbiddenUri2}}} = + httpd_request:validate("GET", ForbiddenUri2, "HTTP/1.1"), + + HexForbiddenUri = "http://127.0.0.1:8888/%2e%2e/%2e%2e/%2e%2e/" + "home/ingela/test.html", + {error, {bad_request, {forbidden, HexForbiddenUri}}} = + httpd_request:validate("GET", HexForbiddenUri, "HTTP/1.1"), + + NewForbiddenUri = + "http://127.0.0.1:8888/foobar/../../../home/ingela/test.html", + {error, {bad_request, {forbidden, NewForbiddenUri}}} = + httpd_request:validate("GET", NewForbiddenUri, "HTTP/1.1"), + + NewForbiddenUri1 = + "http://127.0.0.1:8888/../home/ingela/test.html", + {error, {bad_request, {forbidden, NewForbiddenUri1}}} = + httpd_request:validate("GET", NewForbiddenUri1, "HTTP/1.1"), + + ok. +%%------------------------------------------------------------------------- +esi_parse_headers(doc) -> + ["Test httpd_esi:*. All header values are received in the same" + " erlang message."]; +esi_parse_headers(suite) -> + []; +esi_parse_headers(Config) when is_list(Config) -> + + ESIResult = "content-type:text/html\r\ndate:Thu, 28 Oct 2004 07:57:43 " + "GMT\r\nstatus:200 OK\r\n\r\nFoobar", + + {"content-type:text/html\r\ndate:Thu, 28 Oct 2004 07:57:43 GMT\r\nst" + "atus:200 OK\r\n" = Headers, + "Foobar"} = httpd_esi:parse_headers(ESIResult), + + {ok,[{"date","Thu, 28 Oct 2004 07:57:43 GMT"}, + {"content-type","text/html"}], 200} = + httpd_esi:handle_headers(Headers), + + ESIResult2 = + "location:http://foo.bar.se\r\ndate:Thu, 28 Oct 2004 07:57:43 " + "GMT\r\n\r\n", + + {"location:http://foo.bar.se\r\ndate:Thu, 28 Oct 2004 07:57:43 GMT\r\n" = + Headers2,[]} + = httpd_esi:parse_headers(ESIResult2), + + {ok,[{"date","Thu, 28 Oct 2004 07:57:43 GMT"}, + {"location","http://foo.bar.se"}], 302} = + httpd_esi:handle_headers(Headers2), + + {proceed,"/foo/bar.html"} = + httpd_esi:handle_headers("location:/foo/bar.html\r\n"), + ok. + +%%-------------------------------------------------------------------- +cgi_parse_headers(doc) -> + ["Test httpd_cgi:*. This test case will simulate that the " + "message will be recived a little at the time on a socket and the " + "package may be broken up into smaller parts at arbitrary point."]; +cgi_parse_headers(suite) -> + []; +cgi_parse_headers(Config) when is_list(Config) -> + + CGIResult = ["content-type:text", "/html\ndate:Thu, 28 Oct 2004 07:57:43 " + "GMT\nst", "atus:200 OK\n", "\nFoobar"], + + {Headers, Body} = + parse(httpd_cgi, parse_headers, [<<>>, [], []], CGIResult), + + "Foobar" = binary_to_list(Body), + + {ok,[{"content-type","text/html"}, + {"date","Thu, 28 Oct 2004 07:57:43 GMT"}], {200,"OK"}} = + httpd_cgi:handle_headers(Headers), + + CGIResult2 = ["location:http://foo.bar.se\ndate:Thu, 28 Oct 2004" + " 07:57:43 GMT\n\n"], + {Headers2, _} = parse(httpd_cgi, parse_headers, + [<<>>, [], []], CGIResult2), + + {ok,[{"location","http://foo.bar.se"}, + {"date","Thu, 28 Oct 2004 07:57:43 GMT"}], {302,"Redirect"}} = + httpd_cgi:handle_headers(Headers2), + + {proceed,"/foo/bar.html"} = + httpd_cgi:handle_headers(["location:/foo/bar.html\n"]), + + CGIHTTPResult = ["Content-Type:text", "/html\n", "Connection:close\r\n", + "Content-Language:en\r\nAge:", "4711\r\n\r\n\nfoobar"], + + {Headers3, _} = parse(httpd_cgi, parse_headers, + [<<>>, [], []], CGIHTTPResult), + + {ok,[{"content-type","text/html"}, + {"connection","close"}, + {"content-language","en"}, + {"age","4711"}], {200,"ok"}} = httpd_cgi:handle_headers(Headers3), + + ok. + +%%------------------------------------------------------------------------- +is_absolut_uri(doc) -> + ["Test http_request:is_absolut_uri/1."]; +is_absolut_uri(suite) -> + []; +is_absolut_uri(Config) when is_list(Config) -> + true = http_request:is_absolut_uri("http://www.erlang.org"), + true = http_request:is_absolut_uri("https://www.erlang.org"), + false = http_request:is_absolut_uri("index.html"). + + +%%------------------------------------------------------------------------- +convert_netscapecookie_date(doc) -> + ["Test http_util:convert_netscapecookie_date/1."]; +convert_netscapecookie_date(suite) -> + []; +convert_netscapecookie_date(Config) when is_list(Config) -> + {{2006,1,6},{8,59,38}} = + http_util:convert_netscapecookie_date("Mon, 06-Jan-2006 08:59:38 GMT"), + {{2006,2, 7},{8,59,38}} = + http_util:convert_netscapecookie_date("Tue, 07-Feb-2006 08:59:38 GMT"), + {{2006,3,8},{8,59,38}} = + http_util:convert_netscapecookie_date("Wdy, 08-Mar-2006 08:59:38 GMT"), + {{2006,4,9},{8,59,38}} = + http_util:convert_netscapecookie_date("Thu, 09-Apr-2006 08:59:38 GMT"), + {{2006,5,10},{8,59,38}} = + http_util:convert_netscapecookie_date("Fri, 10-May-2006 08:59:38 GMT"), + {{2006,6,11},{8,59,38}} = + http_util:convert_netscapecookie_date("Sat, 11-Jun-2006 08:59:38 GMT"), + {{2006,7,12},{8,59,38}} = + http_util:convert_netscapecookie_date("Sun, 12-Jul-2006 08:59:38 GMT"), + {{2006,8,12},{8,59,38}} = + http_util:convert_netscapecookie_date("Sun, 12-Aug-2006 08:59:38 GMT"), + {{2006,9,12},{8,59,38}} = + http_util:convert_netscapecookie_date("Sun, 12-Sep-2006 08:59:38 GMT"), + {{2006,10,12},{8,59,38}} = + http_util:convert_netscapecookie_date("Sun, 12-Oct-2006 08:59:38 GMT"), + {{2006,11,12},{8,59,38}} = + http_util:convert_netscapecookie_date("Sun, 12-Nov-2006 08:59:38 GMT"), + {{2006,12,12},{8,59,38}} = + http_util:convert_netscapecookie_date("Sun, 12-Dec-2006 08:59:38 GMT"), + ok. + +%%-------------------------------------------------------------------- +%%% Internal functions +%%-------------------------------------------------------------------- + +parse(Module, Function, Args, [Data | Rest]) -> + case Module:Function([list_to_binary(Data) | Args]) of + {ok, Result} -> + Result; + {NewModule, NewFunction, NewArgs} -> + parse(NewModule, NewFunction, NewArgs, Rest) + end. + + + diff --git a/lib/inets/test/http_internal.hrl b/lib/inets/test/http_internal.hrl new file mode 120000 index 0000000000..a4600a09f7 --- /dev/null +++ b/lib/inets/test/http_internal.hrl @@ -0,0 +1 @@ +../src/http_lib/http_internal.hrl
\ No newline at end of file diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl new file mode 100644 index 0000000000..96099c49fd --- /dev/null +++ b/lib/inets/test/httpc_SUITE.erl @@ -0,0 +1,2954 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +%% +%% ts:run(inets, httpc_SUITE, [batch]). +%% + +-module(httpc_SUITE). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +-include_lib("kernel/include/file.hrl"). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +%% Test server specific exports +-define(PROXY_URL, "http://www.erlang.org"). +-define(PROXY, "www-proxy.ericsson.se"). +-define(PROXY_PORT, 8080). +-define(IP_PORT, 8998). +-define(SSL_PORT, 8999). +-define(NOT_IN_USE_PORT, 8997). +-define(LOCAL_HOST, {127,0,0,1}). +-define(IPV6_LOCAL_HOST, "0:0:0:0:0:0:0:1"). +-define(URL_START, "http://localhost:"). +-define(SSL_URL_START, "https://localhost:"). +-define(CR, $\r). +-define(LF, $\n). +-define(HTTP_MAX_HEADER_SIZE, 10240). + + +%%-------------------------------------------------------------------- +%% all(Arg) -> [Doc] | [Case] | {skip, Comment} +%% Arg - doc | suite +%% Doc - string() +%% Case - atom() +%% Name of a test case function. +%% Comment - string() +%% Description: Returns documentation/test cases in this test suite +%% or a skip tuple if the platform is not supported. +%%-------------------------------------------------------------------- + +all(doc) -> + ["Test the http client in the intes application."]; +all(suite) -> + [ + proxy_options, + proxy_head, + proxy_get, + proxy_trace, + proxy_post, + proxy_put, + proxy_delete, + proxy_auth, + proxy_headers, + proxy_emulate_lower_versions, + http_options, + http_head, + http_get, + http_post, + http_dummy_pipe, + http_inets_pipe, + http_trace, + http_async, + http_save_to_file, + http_save_to_file_async, + http_headers, + http_headers_dummy, + http_bad_response, + ssl_head, + ssl_get, + ssl_trace, + http_redirect, + http_redirect_loop, + http_internal_server_error, + http_userinfo, + http_cookie, + http_server_does_not_exist, + http_invalid_http, + http_emulate_lower_versions, + http_relaxed, + page_does_not_exist, + proxy_page_does_not_exist, + proxy_https_not_supported, + http_stream, + http_stream_once, + proxy_stream, + parse_url, + options, + ipv6, + headers_as_is, + tickets + ]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + PrivDir = ?config(priv_dir, Config), + DataDir = ?config(data_dir, Config), + ServerRoot = filename:join(PrivDir, "server_root"), + DocRoot = filename:join(ServerRoot, "htdocs"), + IpConfFile = integer_to_list(?IP_PORT) ++ ".conf", + SslConfFile = integer_to_list(?SSL_PORT) ++ ".conf", + + setup_server_dirs(ServerRoot, DocRoot, DataDir), + create_config(IpConfFile, ip_comm, ?IP_PORT, PrivDir, ServerRoot, + DocRoot, DataDir), + create_config(SslConfFile, ssl, ?SSL_PORT, PrivDir, ServerRoot, + DocRoot, DataDir), + + Cgi = case test_server:os_type() of + {win32, _} -> + filename:join([ServerRoot, "cgi-bin", "cgi_echo.exe"]); + _ -> + filename:join([ServerRoot, "cgi-bin", "cgi_echo"]) + end, + + {ok, FileInfo} = file:read_file_info(Cgi), + ok = file:write_file_info(Cgi, FileInfo#file_info{mode = 8#00755}), + + [{server_root, ServerRoot}, + {doc_root, DocRoot}, + {local_port, ?IP_PORT}, + {local_ssl_port, ?SSL_PORT} | Config]. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(Config) -> + PrivDir = ?config(priv_dir, Config), + inets_test_lib:del_dirs(PrivDir), + application:stop(inets), + application:stop(ssl), + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(Case, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_testcase(otp_8154_1 = Case, Config) -> + init_per_testcase(Case, 5, Config); +init_per_testcase(Case, Config) -> + init_per_testcase(Case, 2, Config). + +init_per_testcase(Case, Timeout, Config) -> + io:format(user, "~n~n*** INIT ~w:~w[~w] ***~n~n", + [?MODULE, Timeout, Case]), + PrivDir = ?config(priv_dir, Config), + application:stop(inets), + Dog = test_server:timetrap(inets_test_lib:minutes(Timeout)), + TmpConfig = lists:keydelete(watchdog, 1, Config), + IpConfFile = integer_to_list(?IP_PORT) ++ ".conf", + SslConfFile = integer_to_list(?SSL_PORT) ++ ".conf", + + NewConfig = + case atom_to_list(Case) of + "ssl" ++ _ -> + application:stop(ssl), + TmpConfig2 = + lists:keydelete(local_ssl_server, 1, TmpConfig), + %% Will start inets + Server = + inets_test_lib:start_http_server( + filename:join(PrivDir, SslConfFile)), + [{watchdog, Dog}, {local_ssl_server, Server} | TmpConfig2]; + "proxy" ++ Rest -> + case Rest of + "_https_not_supported" -> + inets:start(), + case (catch application:start(ssl)) of + ok -> + [{watchdog, Dog} | TmpConfig]; + _ -> + [{skip, + "SSL does not seem to be supported"} + | TmpConfig] + end; + _ -> + case is_proxy_available(?PROXY, ?PROXY_PORT) of + true -> + inets:start(), + [{watchdog, Dog} | TmpConfig]; + false -> + [{skip, "Failed to contact proxy"} | + TmpConfig] + end + end; + _ -> + TmpConfig2 = lists:keydelete(local_server, 1, TmpConfig), + Server = + %% Will start inets + inets_test_lib:start_http_server( + filename:join(PrivDir, IpConfFile)), + [{watchdog, Dog}, {local_server, Server} | TmpConfig2] + end, + + http:set_options([{proxy, {{?PROXY, ?PROXY_PORT}, + ["localhost", ?IPV6_LOCAL_HOST]}}]), + inets:enable_trace(max, io, httpc), + %% inets:enable_trace(max, io, all), + %% snmp:set_trace([gen_tcp, inet_tcp, prim_inet]), + NewConfig. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(Case, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(http_save_to_file, Config) -> + PrivDir = ?config(priv_dir, Config), + FullPath = filename:join(PrivDir, "dummy.html"), + file:delete(FullPath), + finish(Config); + +end_per_testcase(_, Config) -> + finish(Config). + +finish(Config) -> + Dog = ?config(watchdog, Config), + case Dog of + undefined -> + ok; + _ -> + test_server:timetrap_cancel(Dog) + end. + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- + +tickets(doc) -> + ["."]; +tickets(suite) -> + [ + hexed_query_otp_6191, + empty_body_otp_6243, + empty_response_header_otp_6830, + transfer_encoding_otp_6807, + proxy_not_modified_otp_6821, + no_content_204_otp_6982, + missing_CR_otp_7304, + otp_7883, + otp_8154, + otp_8106, + otp_8056, + otp_8352, + otp_8371 + ]. + + +%%------------------------------------------------------------------------- + +http_options(doc) -> + ["Test http options request against local server."]; +http_options(suite) -> + []; +http_options(Config) when is_list(Config) -> + {skip, "Not supported by httpd"}. + +http_head(doc) -> + ["Test http head request against local server."]; +http_head(suite) -> + []; +http_head(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + case http:request(head, {URL, []}, [], []) of + {ok, {{_,200,_}, [_ | _], []}} -> + ok; + {ok, WrongReply} -> + tsf({wrong_reply, WrongReply}); + Error -> + tsf({failed, Error}) + end; + _ -> + {skip, "Failed to start local http-server"} + end. +%%------------------------------------------------------------------------- +http_get(doc) -> + ["Test http get request against local server"]; +http_get(suite) -> + []; +http_get(Config) when is_list(Config) -> + tsp("http_get -> entry with" + "~n Config: ~p", [Config]), + case ?config(local_server, Config) of + ok -> + tsp("local-server running"), + Method = get, + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + Request = {URL, []}, + Timeout = timer:seconds(1), + ConnTimeout = Timeout + timer:seconds(1), + HttpOptions1 = [{timeout, Timeout}, {connect_timeout, ConnTimeout}], + Options1 = [], + Body = + case http:request(Method, Request, HttpOptions1, Options1) of + {ok, {{_,200,_}, [_ | _], ReplyBody = [_ | _]}} -> + ReplyBody; + {ok, UnexpectedReply1} -> + tsf({unexpected_reply, UnexpectedReply1}); + {error, _} = Error1 -> + tsf({bad_reply, Error1}) + end, + + %% eqvivivalent to http:request(get, {URL, []}, [], []), + inets_test_lib:check_body(Body), + + HttpOptions2 = [], + Options2 = [{body_format, binary}], + case http:request(Method, Request, HttpOptions2, Options2) of + {ok, {{_,200,_}, [_ | _], Bin}} when is_binary(Bin) -> + ok; + {ok, {{_,200,_}, [_ | _], BadBin}} -> + tsf({body_format_not_binary, BadBin}); + {ok, UnexpectedReply2} -> + tsf({unexpected_reply, UnexpectedReply2}); + {error, _} = Error2 -> + tsf({bad_reply, Error2}) + end; + _ -> + {skip, "Failed to start local http-server"} + end. + +%%------------------------------------------------------------------------- +http_post(doc) -> + ["Test http post request against local server. We do in this case" + " only care about the client side of the the post. The server" + " script will not actually use the post data."]; +http_post(suite) -> + []; +http_post(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + + URL = case test_server:os_type() of + {win32, _} -> + ?URL_START ++ integer_to_list(Port) ++ + "/cgi-bin/cgi_echo.exe"; + _ -> + ?URL_START ++ integer_to_list(Port) ++ + "/cgi-bin/cgi_echo" + + end, + %% Cgi-script expects the body length to be 100 + Body = lists:duplicate(100, "1"), + + {ok, {{_,200,_}, [_ | _], [_ | _]}} = + http:request(post, {URL, [{"expect","100-continue"}], + "text/plain", Body}, [], []), + + {ok, {{_,504,_}, [_ | _], []}} = + http:request(post, {URL, [{"expect","100-continue"}], + "text/plain", "foobar"}, [], []); + _ -> + {skip, "Failed to start local http-server"} + end. + +%%------------------------------------------------------------------------- +http_emulate_lower_versions(doc) -> + ["Perform request as 0.9 and 1.0 clients."]; +http_emulate_lower_versions(suite) -> + []; +http_emulate_lower_versions(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, Body0} = + http:request(get, {URL, []}, [{version, "HTTP/0.9"}], []), + inets_test_lib:check_body(Body0), + {ok, {{"HTTP/1.0", 200, _}, [_ | _], Body1 = [_ | _]}} = + http:request(get, {URL, []}, [{version, "HTTP/1.0"}], []), + inets_test_lib:check_body(Body1), + {ok, {{"HTTP/1.1", 200, _}, [_ | _], Body2 = [_ | _]}} = + http:request(get, {URL, []}, [{version, "HTTP/1.1"}], []), + inets_test_lib:check_body(Body2); + _-> + {skip, "Failed to start local http-server"} + end. + + +%%------------------------------------------------------------------------- + +http_relaxed(doc) -> + ["Test relaxed mode"]; +http_relaxed(suite) -> + []; +http_relaxed(Config) when is_list(Config) -> + ok = http:set_options([{ipv6, disabled}]), % also test the old option + %% ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ + "/missing_reason_phrase.html", + + {error, Reason} = + http:request(get, {URL, []}, [{relaxed, false}], []), + + test_server:format("Not relaxed: ~p~n", [Reason]), + + {ok, {{_, 200, _}, [_ | _], [_ | _]}} = + http:request(get, {URL, []}, [{relaxed, true}], []), + + DummyServerPid ! stop, + ok = http:set_options([{ipv6, enabled}]), + %% ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- +http_dummy_pipe(doc) -> + ["Test pipelining code."]; +http_dummy_pipe(suite) -> + []; +http_dummy_pipe(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/foobar.html", + + test_pipeline(URL), + + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + +http_inets_pipe(doc) -> + ["Test pipelining code."]; +http_inets_pipe(suite) -> + []; +http_inets_pipe(Config) when is_list(Config) -> + + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + test_pipeline(URL); + _ -> + {skip, "Failed to start local http-server"} + end. + +test_pipeline(URL) -> + p("test_pipeline -> entry with" + "~n URL: ~p", [URL]), + + http:set_options([{pipeline_timeout, 50000}]), + + p("test_pipeline -> issue (async) request 1"), + {ok, RequestId1} = + http:request(get, {URL, []}, [], [{sync, false}]), + test_server:format("RequestId1: ~p~n", [RequestId1]), + p("test_pipeline -> RequestId1: ~p", [RequestId1]), + + %% Make sure pipeline is initiated + p("test_pipeline -> sleep some", []), + test_server:sleep(4000), + + p("test_pipeline -> issue (async) request 2"), + {ok, RequestId2} = + http:request(get, {URL, []}, [], [{sync, false}]), + tsp("RequestId2: ~p", [RequestId2]), + p("test_pipeline -> RequestId2: ~p", [RequestId2]), + + p("test_pipeline -> issue (sync) request 3"), + {ok, {{_,200,_}, [_ | _], [_ | _]}} = + http:request(get, {URL, []}, [], []), + + p("test_pipeline -> expect reply for (async) request 1 or 2"), + receive + {http, {RequestId1, {{_, 200, _}, _, _}}} -> + p("test_pipeline -> received reply for (async) request 1 - now wait for 2"), + receive + {http, {RequestId2, {{_, 200, _}, _, _}}} -> + p("test_pipeline -> received reply for (async) request 2"), + ok; + {http, Msg1} -> + test_server:fail(Msg1) + end; + {http, {RequestId2, {{_, 200, _}, _, _}}} -> + io:format("test_pipeline -> received reply for (async) request 2 - now wait for 1"), + receive + {http, {RequestId1, {{_, 200, _}, _, _}}} -> + io:format("test_pipeline -> received reply for (async) request 1"), + ok; + {http, Msg2} -> + test_server:fail(Msg2) + end; + {http, Msg3} -> + test_server:fail(Msg3) + after 60000 -> + receive Any1 -> + tsp("received crap after timeout: ~n ~p", [Any1]), + test_server:fail({error, {timeout, Any1}}) + end + end, + + p("test_pipeline -> sleep some"), + test_server:sleep(4000), + + p("test_pipeline -> issue (async) request 4"), + {ok, RequestId3} = + http:request(get, {URL, []}, [], [{sync, false}]), + tsp("RequestId3: ~p", [RequestId3]), + p("test_pipeline -> RequestId3: ~p", [RequestId3]), + + p("test_pipeline -> issue (async) request 5"), + {ok, RequestId4} = + http:request(get, {URL, []}, [], [{sync, false}]), + tsp("RequestId4: ~p~n", [RequestId4]), + p("test_pipeline -> RequestId4: ~p", [RequestId4]), + + p("test_pipeline -> cancel (async) request 4"), + ok = http:cancel_request(RequestId3), + + p("test_pipeline -> expect *no* reply for cancelled (async) request 4 (for 3 secs)"), + receive + {http, {RequestId3, _}} -> + test_server:fail(http_cancel_request_failed) + after 3000 -> + ok + end, + + p("test_pipeline -> expect reply for (async) request 4"), + Body = + receive + {http, {RequestId4, {{_, 200, _}, _, BinBody4}}} = Res -> + p("test_pipeline -> received reply for (async) request 5"), + tsp("Receive : ~p", [Res]), + BinBody4; + {http, Msg4} -> + test_server:fail(Msg4) + after 60000 -> + receive Any2 -> + tsp("received crap after timeout: ~n ~p", [Any2]), + test_server:fail({error, {timeout, Any2}}) + end + end, + + p("test_pipeline -> check reply for (async) request 5"), + inets_test_lib:check_body(binary_to_list(Body)), + + p("test_pipeline -> ensure no unexpected incomming"), + receive + {http, Any} -> + test_server:fail({unexpected_message, Any}) + after 500 -> + ok + end, + + p("test_pipeline -> done"), + ok. + + + +%%------------------------------------------------------------------------- +http_trace(doc) -> + ["Perform a TRACE request that goes through a proxy."]; +http_trace(suite) -> + []; +http_trace(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + case http:request(trace, {URL, []}, [], []) of + {ok, {{_,200,_}, [_ | _], "TRACE /dummy.html" ++ _}} -> + ok; + {ok, {{_,200,_}, [_ | _], WrongBody}} -> + test_server:fail({wrong_body, WrongBody}); + {ok, WrongReply} -> + test_server:fail({wrong_reply, WrongReply}); + Error -> + test_server:fail({failed, Error}) + end; + _ -> + {skip, "Failed to start local http-server"} + end. +%%------------------------------------------------------------------------- +http_async(doc) -> + ["Test an asynchrony http request."]; +http_async(suite) -> + []; +http_async(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, RequestId} = + http:request(get, {URL, []}, [], [{sync, false}]), + + Body = + receive + {http, {RequestId, {{_, 200, _}, _, BinBody}}} -> + BinBody; + {http, Msg} -> + test_server:fail(Msg) + end, + + inets_test_lib:check_body(binary_to_list(Body)), + + {ok, NewRequestId} = + http:request(get, {URL, []}, [], [{sync, false}]), + ok = http:cancel_request(NewRequestId), + receive + {http, {NewRequestId, _NewResult}} -> + test_server:fail(http_cancel_request_failed) + after 3000 -> + ok + end; + _ -> + {skip, "Failed to start local http-server"} + end. + +%%------------------------------------------------------------------------- +http_save_to_file(doc) -> + ["Test to save the http body to a file"]; +http_save_to_file(suite) -> + []; +http_save_to_file(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + PrivDir = ?config(priv_dir, Config), + FilePath = filename:join(PrivDir, "dummy.html"), + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, saved_to_file} + = http:request(get, {URL, []}, [], [{stream, FilePath}]), + {ok, Bin} = file:read_file(FilePath), + {ok, {{_,200,_}, [_ | _], Body}} = http:request(URL), + Bin == Body; + _ -> + {skip, "Failed to start local http-server"} + end. + + +%%------------------------------------------------------------------------- +http_save_to_file_async(doc) -> + ["Test to save the http body to a file"]; +http_save_to_file_async(suite) -> + []; +http_save_to_file_async(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + PrivDir = ?config(priv_dir, Config), + FilePath = filename:join(PrivDir, "dummy.html"), + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, RequestId} = http:request(get, {URL, []}, [], + [{stream, FilePath}, + {sync, false}]), + receive + {http, {RequestId, saved_to_file}} -> + ok; + {http, Msg} -> + test_server:fail(Msg) + end, + + {ok, Bin} = file:read_file(FilePath), + {ok, {{_,200,_}, [_ | _], Body}} = http:request(URL), + Bin == Body; + _ -> + {skip, "Failed to start local http-server"} + end. +%%------------------------------------------------------------------------- +http_headers(doc) -> + ["Use as many request headers as possible not used in proxy_headers"]; +http_headers(suite) -> + []; +http_headers(Config) when is_list(Config) -> + + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + DocRoot = ?config(doc_root, Config), + {ok, FileInfo} = + file:read_file_info(filename:join([DocRoot,"dummy.html"])), + CreatedSec = + calendar:datetime_to_gregorian_seconds( + FileInfo#file_info.mtime), + + Mod = httpd_util:rfc1123_date( + calendar:gregorian_seconds_to_datetime( + CreatedSec-1)), + + Date = httpd_util:rfc1123_date({date(), time()}), + + {ok, {{_,200,_}, [_ | _], [_ | _]}} = + http:request(get, {URL, [{"If-Modified-Since", + Mod}, + {"From","[email protected]"}, + {"Date", Date} + ]}, [], []), + + Mod1 = httpd_util:rfc1123_date( + calendar:gregorian_seconds_to_datetime( + CreatedSec+1)), + + {ok, {{_,200,_}, [_ | _], [_ | _]}} = + http:request(get, {URL, [{"If-UnModified-Since", + Mod1} + ]}, [], []), + + Tag = httpd_util:create_etag(FileInfo), + + + {ok, {{_,200,_}, [_ | _], [_ | _]}} = + http:request(get, {URL, [{"If-Match", + Tag} + ]}, [], []), + + {ok, {{_,200,_}, [_ | _], _}} = + http:request(get, {URL, [{"If-None-Match", + "NotEtag,NeihterEtag"}, + {"Connection", "Close"} + ]}, [], []), + ok; + _ -> + {skip, "Failed to start local http-server"} + end. + +%%------------------------------------------------------------------------- +http_headers_dummy(doc) -> + ["Test the code for handling headers we do not want/can send " + "to a real server. Note it is not logical to send" + "all of these headers together, we only want to test that" + "the code for handling headers will not crash."]; +http_headers_dummy(suite) -> + []; +http_headers_dummy(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy_headers.html", + + Foo = http_chunk:encode("foobar") ++ + binary_to_list(http_chunk:encode_last()), + FooBar = Foo ++ "\r\n\r\nOther:inets_test\r\n\r\n", + + UserPasswd = base64:encode_to_string("Alladin:Sesame"), + Auth = "Basic " ++ UserPasswd, + + %% The dummy server will ignore the headers, we only want to test + %% that the client header-handling code. This would not + %% be a vaild http-request! + {ok, {{_,200,_}, [_ | _], [_|_]}} = + http:request(post, + {URL, + [{"Via", + "1.0 fred, 1.1 nowhere.com (Apache/1.1)"}, + {"Warning","1#pseudonym foobar"}, + {"Vary","*"}, + {"Upgrade","HTTP/2.0"}, + {"Pragma", "1#no-cache"}, + {"Cache-Control", "no-cache"}, + {"Connection", "close"}, + {"Date", "Sat, 29 Oct 1994 19:43:31 GMT"}, + {"Accept", " text/plain; q=0.5, text/html"}, + {"Accept-Language", "en"}, + {"Accept-Encoding","chunked"}, + {"Accept-Charset", "ISO8859-1"}, + {"Authorization", Auth}, + {"Expect", "1#100-continue"}, + {"User-Agent","inets"}, + {"Transfer-Encoding","chunked"}, + {"Range", " bytes=0-499"}, + {"If-Range", "Sat, 29 Oct 1994 19:43:31 GMT"}, + {"If-Match", "*"}, + {"Content-Type", "text/plain"}, + {"Content-Encoding", "chunked"}, + {"Content-Length", "6"}, + {"Content-Language", "en"}, + {"Content-Location", "http://www.foobar.se"}, + {"Content-MD5", + "104528739076276072743283077410617235478"}, + {"Content-Range", "bytes 0-499/1234"}, + {"Allow", "GET"}, + {"Proxy-Authorization", Auth}, + {"Expires", "Sat, 29 Oct 1994 19:43:31 GMT"}, + {"Upgrade", "HTTP/2.0"}, + {"Last-Modified", "Sat, 29 Oct 1994 19:43:31 GMT"}, + {"Trailer","1#User-Agent"} + ], "text/plain", FooBar}, + [], []), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- +http_bad_response(doc) -> + ["Test what happens when the server does not follow the protocol"]; +http_bad_response(suite) -> + []; +http_bad_response(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/missing_crlf.html", + + URL1 = ?URL_START ++ integer_to_list(Port) ++ "/wrong_statusline.html", + + {error, timeout} = http:request(get, {URL, []}, [{timeout, 400}], []), + + {error, Reason} = http:request(URL1), + + test_server:format("Wrong Statusline: ~p~n", [Reason]), + + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- +ssl_head(doc) -> + ["Same as http_head/1 but over ssl sockets."]; +ssl_head(suite) -> + []; +ssl_head(Config) when is_list(Config) -> + case ?config(local_ssl_server, Config) of + ok -> + DataDir = ?config(data_dir, Config), + Port = ?config(local_ssl_port, Config), + URL = ?SSL_URL_START ++ integer_to_list(Port) ++ "/dummy.html", + CertFile = filename:join(DataDir, "ssl_client_cert.pem"), + SSLOptions = [{certfile, CertFile}, {keyfile, CertFile}], + {ok, {{_,200, _}, [_ | _], []}} = + http:request(head, {URL, []}, [{ssl, SSLOptions}], []); + {ok, _} -> + {skip, "Failed to start local http-server"}; + _ -> + {skip, "Failed to start SSL"} + end. +%%------------------------------------------------------------------------- +ssl_get(doc) -> + ["Same as http_get/1 but over ssl sockets."]; +ssl_get(suite) -> + []; +ssl_get(Config) when is_list(Config) -> + case ?config(local_ssl_server, Config) of + ok -> + DataDir = ?config(data_dir, Config), + Port = ?config(local_ssl_port, Config), + URL = ?SSL_URL_START ++ integer_to_list(Port) ++ "/dummy.html", + CertFile = filename:join(DataDir, "ssl_client_cert.pem"), + SSLOptions = [{certfile, CertFile}, {keyfile, CertFile}], + {ok, {{_,200, _}, [_ | _], Body = [_ | _]}} = + http:request(get, {URL, []}, [{ssl, SSLOptions}], []), + inets_test_lib:check_body(Body); + {ok, _} -> + {skip, "Failed to start local http-server"}; + _ -> + {skip, "Failed to start SSL"} + end. +%%------------------------------------------------------------------------- +ssl_trace(doc) -> + ["Same as http_trace/1 but over ssl sockets."]; +ssl_trace(suite) -> + []; +ssl_trace(Config) when is_list(Config) -> + case ?config(local_ssl_server, Config) of + ok -> + DataDir = ?config(data_dir, Config), + Port = ?config(local_ssl_port, Config), + URL = ?SSL_URL_START ++ integer_to_list(Port) ++ "/dummy.html", + CertFile = filename:join(DataDir, "ssl_client_cert.pem"), + SSLOptions = [{certfile, CertFile}, {keyfile, CertFile}], + case http:request(trace, {URL, []}, [{ssl, SSLOptions}], []) of + {ok, {{_,200, _}, [_ | _], "TRACE /dummy.html" ++ _}} -> + ok; + {ok, {{_,200,_}, [_ | _], WrongBody}} -> + test_server:fail({wrong_body, WrongBody}); + {ok, WrongReply} -> + test_server:fail({wrong_reply, WrongReply}); + Error -> + test_server:fail({failed, Error}) + end; + {ok, _} -> + {skip, "Failed to start local http-server"}; + _ -> + {skip, "Failed to start SSL"} + end. +%%------------------------------------------------------------------------- +http_redirect(doc) -> + ["Test redirect with dummy server as httpd does not implement" + " server redirect"]; +http_redirect(suite) -> + []; +http_redirect(Config) when is_list(Config) -> + tsp("http_redirect -> entry with" + "~n Config: ~p", [Config]), + case ?config(local_server, Config) of + ok -> + tsp("http_redirect -> set ipfamily option to inet"), + ok = http:set_options([{ipfamily, inet}]), + + tsp("http_redirect -> start dummy server inet"), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + tsp("http_redirect -> server port = ~p", [Port]), + + URL300 = ?URL_START ++ integer_to_list(Port) ++ "/300.html", + + tsp("http_redirect -> issue request 1: " + "~n ~p", [URL300]), + {ok, {{_,200,_}, [_ | _], [_|_]}} + = http:request(get, {URL300, []}, [], []), + + tsp("http_redirect -> issue request 2: " + "~n ~p", [URL300]), + {ok, {{_,300,_}, [_ | _], _}} = + http:request(get, {URL300, []}, [{autoredirect, false}], []), + + URL301 = ?URL_START ++ integer_to_list(Port) ++ "/301.html", + + tsp("http_redirect -> issue request 3: " + "~n ~p", [URL301]), + {ok, {{_,200,_}, [_ | _], [_|_]}} + = http:request(get, {URL301, []}, [], []), + + tsp("http_redirect -> issue request 4: " + "~n ~p", [URL301]), + {ok, {{_,200,_}, [_ | _], []}} + = http:request(head, {URL301, []}, [], []), + + tsp("http_redirect -> issue request 5: " + "~n ~p", [URL301]), + {ok, {{_,301,_}, [_ | _], [_|_]}} + = http:request(post, {URL301, [],"text/plain", "foobar"}, + [], []), + + URL302 = ?URL_START ++ integer_to_list(Port) ++ "/302.html", + + tsp("http_redirect -> issue request 6: " + "~n ~p", [URL302]), + {ok, {{_,200,_}, [_ | _], [_|_]}} + = http:request(get, {URL302, []}, [], []), + case http:request(get, {URL302, []}, [], []) of + {ok, Reply7} -> + case Reply7 of + {{_,200,_}, [_ | _], [_|_]} -> + tsp("http_redirect -> " + "expected reply for request 7"), + ok; + {StatusLine, Headers, Body} -> + tsp("http_redirect -> " + "unexpected reply for request 7: " + "~n StatusLine: ~p" + "~n Headers: ~p" + "~n Body: ~p", + [StatusLine, Headers, Body]), + tsf({unexpected_reply, Reply7}) + end; + Error7 -> + tsp("http_redirect -> " + "unexpected result for request 7: " + "~n Error7: ~p", + [Error7]), + tsf({unexpected_result, Error7}) + end, + + tsp("http_redirect -> issue request 7: " + "~n ~p", [URL302]), + {ok, {{_,200,_}, [_ | _], []}} + = http:request(head, {URL302, []}, [], []), + + tsp("http_redirect -> issue request 8: " + "~n ~p", [URL302]), + {ok, {{_,302,_}, [_ | _], [_|_]}} + = http:request(post, {URL302, [],"text/plain", "foobar"}, + [], []), + + URL307 = ?URL_START ++ integer_to_list(Port) ++ "/307.html", + + tsp("http_redirect -> issue request 9: " + "~n ~p", [URL307]), + {ok, {{_,200,_}, [_ | _], [_|_]}} + = http:request(get, {URL307, []}, [], []), + + tsp("http_redirect -> issue request 10: " + "~n ~p", [URL307]), + {ok, {{_,200,_}, [_ | _], []}} + = http:request(head, {URL307, []}, [], []), + + tsp("http_redirect -> issue request 11: " + "~n ~p", [URL307]), + {ok, {{_,307,_}, [_ | _], [_|_]}} + = http:request(post, {URL307, [],"text/plain", "foobar"}, + [], []), + + tsp("http_redirect -> stop dummy server"), + DummyServerPid ! stop, + tsp("http_redirect -> reset ipfamily option (to inet6fb4)"), + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + tsp("http_redirect -> done"), + ok; + + _ -> + {skip, "Failed to start local http-server"} + end. + + + +%%------------------------------------------------------------------------- +http_redirect_loop(doc) -> + ["Test redirect loop detection"]; +http_redirect_loop(suite) -> + []; +http_redirect_loop(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/redirectloop.html", + + {ok, {{_,300,_}, [_ | _], _}} + = http:request(get, {URL, []}, [], []), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + +%%------------------------------------------------------------------------- +http_internal_server_error(doc) -> + ["Test 50X codes"]; +http_internal_server_error(suite) -> + []; +http_internal_server_error(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL500 = ?URL_START ++ integer_to_list(Port) ++ "/500.html", + + {ok, {{_,500,_}, [_ | _], _}} + = http:request(get, {URL500, []}, [], []), + + + URL503 = ?URL_START ++ integer_to_list(Port) ++ "/503.html", + + %% Used to be able to make the service available after retry. + ets:new(unavailable, [named_table, public, set]), + ets:insert(unavailable, {503, unavailable}), + + {ok, {{_,200, _}, [_ | _], [_|_]}} = + http:request(get, {URL503, []}, [], []), + + ets:insert(unavailable, {503, long_unavailable}), + + {ok, {{_,503, _}, [_ | _], [_|_]}} = + http:request(get, {URL503, []}, [], []), + + ets:delete(unavailable), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- +http_userinfo(doc) -> + ["Test user info e.i. http://user:passwd@host:port/"]; +http_userinfo(suite) -> + []; +http_userinfo(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URLAuth = "http://alladin:sesame@localhost:" + ++ integer_to_list(Port) ++ "/userinfo.html", + + {ok, {{_,200,_}, [_ | _], _}} + = http:request(get, {URLAuth, []}, [], []), + + URLUnAuth = "http://alladin:foobar@localhost:" + ++ integer_to_list(Port) ++ "/userinfo.html", + + {ok, {{_,401, _}, [_ | _], _}} = + http:request(get, {URLUnAuth, []}, [], []), + + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- +http_cookie(doc) -> + ["Test cookies."]; +http_cookie(suite) -> + []; +http_cookie(Config) when is_list(Config) -> + ok = http:set_options([{cookies, enabled}, {ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URLStart = ?URL_START + ++ integer_to_list(Port), + + URLCookie = URLStart ++ "/cookie.html", + + {ok, {{_,200,_}, [_ | _], [_|_]}} + = http:request(get, {URLCookie, []}, [], []), + + ets:new(cookie, [named_table, public, set]), + ets:insert(cookie, {cookies, true}), + + {ok, {{_,200,_}, [_ | _], [_|_]}} + = http:request(get, {URLStart ++ "/", []}, [], []), + + ets:delete(cookie), + + ok = http:set_options([{cookies, disabled}, {ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6************ + ok. + +%%------------------------------------------------------------------------- +proxy_options(doc) -> + ["Perform a OPTIONS request that goes through a proxy."]; +proxy_options(suite) -> + []; +proxy_options(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + case http:request(options, {?PROXY_URL, []}, [], []) of + {ok, {{_,200,_}, Headers, _}} -> + case lists:keysearch("allow", 1, Headers) of + {value, {"allow", _}} -> + ok; + _ -> + test_server:fail(http_options_request_failed) + end; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_head(doc) -> + ["Perform a HEAD request that goes through a proxy."]; +proxy_head(suite) -> + []; +proxy_head(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + case http:request(head, {?PROXY_URL, []}, [], []) of + {ok, {{_,200, _}, [_ | _], []}} -> + ok; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_get(doc) -> + ["Perform a GET request that goes through a proxy."]; +proxy_get(suite) -> + []; +proxy_get(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + case http:request(get, {?PROXY_URL, []}, [], []) of + {ok, {{_,200,_}, [_ | _], Body = [_ | _]}} -> + inets_test_lib:check_body(Body); + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + +%%------------------------------------------------------------------------- +proxy_emulate_lower_versions(doc) -> + ["Perform requests as 0.9 and 1.0 clients."]; +proxy_emulate_lower_versions(suite) -> + []; +proxy_emulate_lower_versions(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + Result09 = pelv_get("HTTP/0.9"), + case Result09 of + {ok, [_| _] = Body0} -> + inets_test_lib:check_body(Body0), + ok; + _ -> + tsf({unexpected_result, "HTTP/0.9", Result09}) + end, + + %% We do not check the version here as many servers + %% do not behave according to the rfc and send + %% 1.1 in its response. + Result10 = pelv_get("HTTP/1.0"), + case Result10 of + {ok,{{_, 200, _}, [_ | _], Body1 = [_ | _]}} -> + inets_test_lib:check_body(Body1), + ok; + _ -> + tsf({unexpected_result, "HTTP/1.0", Result10}) + end, + + Result11 = pelv_get("HTTP/1.1"), + case Result11 of + {ok, {{"HTTP/1.1", 200, _}, [_ | _], Body2 = [_ | _]}} -> + inets_test_lib:check_body(Body2); + _ -> + tsf({unexpected_result, "HTTP/1.1", Result11}) + end; + + Reason -> + {skip, Reason} + end. + +pelv_get(Version) -> + http:request(get, {?PROXY_URL, []}, [{version, Version}], []). + +%%------------------------------------------------------------------------- +proxy_trace(doc) -> + ["Perform a TRACE request that goes through a proxy."]; +proxy_trace(suite) -> + []; +proxy_trace(Config) when is_list(Config) -> + %%{ok, {{_,200,_}, [_ | _], "TRACE " ++ _}} = + %% http:request(trace, {?PROXY_URL, []}, [], []), + {skip, "HTTP TRACE is no longer allowed on the ?PROXY_URL server due " + "to security reasons"}. + + +%%------------------------------------------------------------------------- +proxy_post(doc) -> + ["Perform a POST request that goes through a proxy. Note the server" + " will reject the request this is a test of the sending of the" + " request."]; +proxy_post(suite) -> + []; +proxy_post(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + case http:request(post, {?PROXY_URL, [], + "text/plain", "foobar"}, [],[]) of + {ok, {{_,405,_}, [_ | _], [_ | _]}} -> + ok; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_put(doc) -> + ["Perform a PUT request that goes through a proxy. Note the server" + " will reject the request this is a test of the sending of the" + " request."]; +proxy_put(suite) -> + []; +proxy_put(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + case http:request(put, {"http://www.erlang.org/foobar.html", [], + "html", "<html> <body><h1> foo </h1>" + "<p>bar</p> </body></html>"}, [], []) of + {ok, {{_,405,_}, [_ | _], [_ | _]}} -> + ok; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_delete(doc) -> + ["Perform a DELETE request that goes through a proxy. Note the server" + " will reject the request this is a test of the sending of the" + " request. But as the file does not exist the return code will" + " be 404 not found."]; +proxy_delete(suite) -> + []; +proxy_delete(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + URL = ?PROXY_URL ++ "/foobar.html", + case http:request(delete, {URL, []}, [], []) of + {ok, {{_,404,_}, [_ | _], [_ | _]}} -> + ok; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_headers(doc) -> + ["Use as many request headers as possible"]; +proxy_headers(suite) -> + []; +proxy_headers(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + {ok, {{_,200,_}, [_ | _], [_ | _]}} + = http:request(get, {?PROXY_URL, + [ + {"Accept", + "text/*, text/html," + " text/html;level=1," + " */*"}, + {"Accept-Charset", + "iso-8859-5, unicode-1-1;" + "q=0.8"}, + {"Accept-Encoding", "*"}, + {"Accept-Language", + "sv, en-gb;q=0.8," + " en;q=0.7"}, + {"User-Agent", "inets"}, + {"Max-Forwards","5"}, + {"Referer", + "http://otp.ericsson.se:8000" + "/product/internal"} + ]}, [], []), + ok; + Reason -> + {skip, Reason} + end. + +%%------------------------------------------------------------------------- +proxy_auth(doc) -> + ["Test the code for sending of proxy authorization."]; +proxy_auth(suite) -> + []; +proxy_auth(Config) when is_list(Config) -> + %% Our proxy seems to ignore the header, however our proxy + %% does not requirer an auth header, but we want to know + %% atleast the code for sending the header does not crash! + case ?config(skip, Config) of + undefined -> + case http:request(get, {?PROXY_URL, []}, + [{proxy_auth, {"foo", "bar"}}], []) of + {ok, {{_,200, _}, [_ | _], [_|_]}} -> + ok; + Unexpected -> + test_server:fail({unexpected_result, Unexpected}) + end; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +http_server_does_not_exist(doc) -> + ["Test that we get an error message back when the server " + "does note exist."]; +http_server_does_not_exist(suite) -> + []; +http_server_does_not_exist(Config) when is_list(Config) -> + {error, _} = + http:request(get, {"http://localhost:" ++ + integer_to_list(?NOT_IN_USE_PORT) + ++ "/", []},[], []), + ok. + + +%%------------------------------------------------------------------------- +page_does_not_exist(doc) -> + ["Test that we get a 404 when the page is not found."]; +page_does_not_exist(suite) -> + []; +page_does_not_exist(Config) when is_list(Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/doesnotexist.html", + {ok, {{_,404,_}, [_ | _], [_ | _]}} + = http:request(get, {URL, []}, [], []), + ok. + + +%%------------------------------------------------------------------------- +proxy_page_does_not_exist(doc) -> + ["Test that we get a 404 when the page is not found."]; +proxy_page_does_not_exist(suite) -> + []; +proxy_page_does_not_exist(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + URL = ?PROXY_URL ++ "/doesnotexist.html", + {ok, {{_,404,_}, [_ | _], [_ | _]}} = + http:request(get, {URL, []}, [], []), + ok; + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +proxy_https_not_supported(doc) -> + []; +proxy_https_not_supported(suite) -> + []; +proxy_https_not_supported(Config) when is_list(Config) -> + {error, {failed_connecting, https_through_proxy_is_not_currently_supported}} = + http:request(get, {"https://login.yahoo.com", []}, [], []), + ok. + + +%%------------------------------------------------------------------------- + +http_stream(doc) -> + ["Test the option stream for asynchrony requests"]; +http_stream(suite) -> + []; +http_stream(Config) when is_list(Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, {{_,200,_}, [_ | _], Body}} = + http:request(get, {URL, []}, [], []), + + {ok, RequestId} = + http:request(get, {URL, []}, [], [{sync, false}, + {stream, self}]), + + receive + {http, {RequestId, stream_start, _Headers}} -> + ok; + {http, Msg} -> + test_server:fail(Msg) + end, + + StreamedBody = receive_streamed_body(RequestId, <<>>), + + Body == binary_to_list(StreamedBody). + + +%%------------------------------------------------------------------------- +http_stream_once(doc) -> + ["Test the option stream for asynchrony requests"]; +http_stream_once(suite) -> + []; +http_stream_once(Config) when is_list(Config) -> + p("http_stream_once -> entry with" + "~n Config: ~p", [Config]), + + p("http_stream_once -> set ipfamily to inet", []), + ok = http:set_options([{ipfamily, inet}]), + p("http_stream_once -> start dummy server", []), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + PortStr = integer_to_list(Port), + p("http_stream_once -> once", []), + once(?URL_START ++ PortStr ++ "/once.html"), + p("http_stream_once -> once_chunked", []), + once(?URL_START ++ PortStr ++ "/once_chunked.html"), + p("http_stream_once -> dummy", []), + once(?URL_START ++ PortStr ++ "/dummy.html"), + + p("http_stream_once -> stop dummy server", []), + DummyServerPid ! stop, + p("http_stream_once -> set ipfamily to inet6fb4", []), + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + p("http_stream_once -> done", []), + ok. + +once(URL) -> + p("once -> issue sync request for ~p", [URL]), + {ok, {{_,200,_}, [_ | _], Body}} = + http:request(get, {URL, []}, [], []), + + p("once -> issue async (self stream) request for ~p", [URL]), + {ok, RequestId} = + http:request(get, {URL, []}, [], [{sync, false}, + {stream, {self, once}}]), + + p("once -> await stream_start reply for (async) request ~p", [RequestId]), + NewPid = + receive + {http, {RequestId, stream_start, _Headers, Pid}} -> + p("once -> received stream_start reply for (async) request ~p: ~p", + [RequestId, Pid]), + Pid; + {http, Msg} -> + test_server:fail(Msg) + end, + + tsp("once -> request handler: ~p", [NewPid]), + + p("once -> await stream reply for (async) request ~p", [RequestId]), + BodyPart = + receive + {http, {RequestId, stream, BinBodyPart}} -> + p("once -> received stream reply for (async) request ~p: " + "~n~p", [RequestId, binary_to_list(BinBodyPart)]), + BinBodyPart + end, + + tsp("once -> first body part '~p' received", [binary_to_list(BodyPart)]), + + StreamedBody = receive_streamed_body(RequestId, BinBodyPart, NewPid), + + Body = binary_to_list(StreamedBody), + + p("once -> done when Bode: ~p", [Body]), + ok. + + +%%------------------------------------------------------------------------- +proxy_stream(doc) -> + ["Test the option stream for asynchrony requests"]; +proxy_stream(suite) -> + []; +proxy_stream(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + {ok, {{_,200,_}, [_ | _], Body}} = + http:request(get, {?PROXY_URL, []}, [], []), + + {ok, RequestId} = + http:request(get, {?PROXY_URL, []}, [], + [{sync, false}, {stream, self}]), + + receive + {http, {RequestId, stream_start, _Headers}} -> + ok; + {http, Msg} -> + test_server:fail(Msg) + end, + + StreamedBody = receive_streamed_body(RequestId, <<>>), + + Body == binary_to_list(StreamedBody); + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- +parse_url(doc) -> + ["Test that an url is parsed correctly"]; +parse_url(suite) -> + []; +parse_url(Config) when is_list(Config) -> + %% ipv6 + {http,[],"2010:836B:4179::836B:4179",80,"/foobar.html",[]} + = http_uri:parse("http://[2010:836B:4179::836B:4179]/foobar.html"), + {error, + {malformed_url,"http://2010:836B:4179::836B:4179/foobar.html"}} = + http_uri:parse("http://2010:836B:4179::836B:4179/foobar.html"), + + %% ipv4 + {http,[],"127.0.0.1",80,"/foobar.html",[]} = + http_uri:parse("http://127.0.0.1/foobar.html"), + + %% host + {http,[],"localhost",8888,"/foobar.html",[]} = + http_uri:parse("http://localhost:8888/foobar.html"), + + %% Userinfo + {http,"nisse:foobar","localhost",8888,"/foobar.html",[]} = + http_uri:parse("http://nisse:foobar@localhost:8888/foobar.html"), + + %% Scheme error + {error,no_scheme} = http_uri:parse("localhost/foobar.html"), + {error,{not_supported_scheme,localhost}} = + http_uri:parse("localhost:8888/foobar.html"), + + %% Query + {http,[],"localhost",8888,"/foobar.html","?foo=bar&foobar=42"} = + http_uri:parse("http://localhost:8888/foobar.html?foo=bar&foobar=42"), + + %% Esc chars + {http,[],"www.somedomain.com",80,"/%2Eabc",[]} = + http_uri:parse("http://www.somedomain.com/%2Eabc"), + {http,[],"www.somedomain.com",80,"/%252Eabc",[]} = + http_uri:parse("http://www.somedomain.com/%252Eabc"), + {http,[],"www.somedomain.com",80,"/%25abc",[]} = + http_uri:parse("http://www.somedomain.com/%25abc"), + {http,[],"www.somedomain.com",80,"/%25abc", "?foo=bar"} = + http_uri:parse("http://www.somedomain.com/%25abc?foo=bar"), + ok. + + +%%------------------------------------------------------------------------- +ipv6(doc) -> + ["Test ipv6."]; +ipv6(suite) -> + []; +ipv6(Config) when is_list(Config) -> + {ok, Hostname} = inet:gethostname(), + + case lists:member(list_to_atom(Hostname), + ?config(ipv6_hosts, Config)) of + true -> + {DummyServerPid, Port} = dummy_server(self(), ipv6), + + URL = "http://[" ++ ?IPV6_LOCAL_HOST ++ "]:" ++ + integer_to_list(Port) ++ "/foobar.html", + {ok, {{_,200,_}, [_ | _], [_|_]}} = + http:request(get, {URL, []}, [], []), + + DummyServerPid ! stop, + ok; + false -> + {skip, "Host does not support IPv6"} + end. + + +%%------------------------------------------------------------------------- +headers_as_is(doc) -> + ["Test the option headers_as_is"]; +headers_as_is(suite) -> + []; +headers_as_is(Config) when is_list(Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, {{_,200,_}, [_|_], [_|_]}} = + http:request(get, {URL, [{"Host", "localhost"},{"Te", ""}]}, + [], [{headers_as_is, true}]), + + {ok, {{_,400,_}, [_|_], [_|_]}} = + http:request(get, {URL, [{"Te", ""}]},[], [{headers_as_is, true}]), + ok. + + +%%------------------------------------------------------------------------- +options(doc) -> + ["Test the option parameters."]; +options(suite) -> + []; +options(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + {ok, {{_,200,_}, [_ | _], Bin}} + = http:request(get, {URL, []}, [{foo, bar}], + %% Ignore unknown options + [{body_format, binary}, {foo, bar}]), + + true = is_binary(Bin), + {ok, {200, [_|_]}} + = http:request(get, {URL, []}, [{timeout, infinity}], + [{full_result, false}]); + _ -> + {skip, "Failed to start local http-server"} + end. + + +%%------------------------------------------------------------------------- +http_invalid_http(doc) -> + ["Test parse error"]; +http_invalid_http(suite) -> + []; +http_invalid_http(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/invalid_http.html", + + {error, {could_not_parse_as_http, _} = Reason} = + http:request(get, {URL, []}, [], []), + + test_server:format("Parse error: ~p ~n", [Reason]), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +hexed_query_otp_6191(doc) -> + []; +hexed_query_otp_6191(suite) -> + []; +hexed_query_otp_6191(Config) when is_list(Config) -> + Google = "www.google.com", + GoogleSearch = "http://" ++ Google ++ "/search", + Search1 = "?hl=en&q=a%D1%85%D1%83%D0%B9&btnG=Google+Search", + URI1 = GoogleSearch ++ Search1, + Search2 = "?hl=en&q=%25%25", + URI2 = GoogleSearch ++ Search2, + Search3 = "?hl=en&q=%foo", + URI3 = GoogleSearch ++ Search3, + + {http, [], Google, 80, "/search", _} = http_uri:parse(URI1), + {http, [], Google, 80, "/search", _} = http_uri:parse(URI2), + {http, [], Google, 80, "/search", _} = http_uri:parse(URI3), + ok. + + +%%------------------------------------------------------------------------- + +empty_body_otp_6243(doc) -> + ["An empty body was not returned directly. There was a delay for several" + "seconds."]; +empty_body_otp_6243(suite) -> + []; +empty_body_otp_6243(Config) when is_list(Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/empty.html", + {ok, {{_,200,_}, [_ | _], []}} = + http:request(get, {URL, []}, [{timeout, 500}], []). + + +%%------------------------------------------------------------------------- + +transfer_encoding_otp_6807(doc) -> + ["Transfer encoding is case insensitive"]; +transfer_encoding_otp_6807(suite) -> + []; +transfer_encoding_otp_6807(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ + "/capital_transfer_encoding.html", + {ok, {{_,200,_}, [_|_], [_ | _]}} = http:request(URL), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +proxy_not_modified_otp_6821(doc) -> + ["If unmodified no body should be returned"]; +proxy_not_modified_otp_6821(suite) -> + []; +proxy_not_modified_otp_6821(Config) when is_list(Config) -> + case ?config(skip, Config) of + undefined -> + provocate_not_modified_bug(?PROXY_URL); + Reason -> + {skip, Reason} + end. + + +%%------------------------------------------------------------------------- + +empty_response_header_otp_6830(doc) -> + ["Test the case that the HTTP server does not send any headers"]; +empty_response_header_otp_6830(suite) -> + []; +empty_response_header_otp_6830(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/no_headers.html", + {ok, {{_,200,_}, [], [_ | _]}} = http:request(URL), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +no_content_204_otp_6982(doc) -> + ["Test the case that the HTTP 204 no content header"]; +no_content_204_otp_6982(suite) -> + []; +no_content_204_otp_6982(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/no_content.html", + {ok, {{_,204,_}, [], []}} = http:request(URL), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +missing_CR_otp_7304(doc) -> + ["Test the case that the HTTP server uses only LF instead of CRLF" + "as delimitor"]; +missing_CR_otp_7304(suite) -> + []; +missing_CR_otp_7304(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/missing_CR.html", + {ok, {{_,200,_}, _, [_ | _]}} = http:request(URL), + DummyServerPid ! stop, + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +otp_7883(suite) -> + [otp_7883_1, otp_7883_2]. + +otp_7883_1(doc) -> + ["OTP-7883-sync"]; +otp_7883_1(suite) -> + []; +otp_7883_1(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/just_close.html", + {error, socket_closed_remotely} = http:request(URL), + DummyServerPid ! stop, + + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + +otp_7883_2(doc) -> + ["OTP-7883-async"]; +otp_7883_2(suite) -> + []; +otp_7883_2(Config) when is_list(Config) -> + ok = http:set_options([{ipfamily, inet}]), + + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ "/just_close.html", + Method = get, + Request = {URL, []}, + HttpOptions = [], + Options = [{sync, false}], + Profile = http:default_profile(), + {ok, RequestId} = + http:request(Method, Request, HttpOptions, Options, Profile), + ok = + receive + {http, {RequestId, {error, socket_closed_remotely}}} -> + ok + end, + DummyServerPid ! stop, + + ok = http:set_options([{ipfamily, inet6fb4}]), % ********** ipfamily = inet6 ************* + ok. + + +%%------------------------------------------------------------------------- + +otp_8154(suite) -> + [otp_8154_1]. + +otp_8154_1(doc) -> + ["OTP-8154"]; +otp_8154_1(suite) -> + []; +otp_8154_1(Config) when is_list(Config) -> + start_inets(), + ReqSeqNumServer = start_sequence_number_server(), + RespSeqNumServer = start_sequence_number_server(), + {ok, Server, Port} = start_slow_server(RespSeqNumServer), + Clients = run_clients(105, Port, ReqSeqNumServer), + %% ok = wait_for_clients(Clients), + ok = wait4clients(Clients, timer:minutes(3)), + Server ! shutdown, + RespSeqNumServer ! shutdown, + ReqSeqNumServer ! shutdown, + ok. + +start_inets() -> + inets:start(), + ok. + + +%% ----------------------------------------------------- +%% A sequence number handler +%% The purpose is to be able to pair requests with responses. + +start_sequence_number_server() -> + proc_lib:spawn(fun() -> loop_sequence_number(1) end). + +loop_sequence_number(N) -> + receive + shutdown -> + ok; + {From, get_next} -> + From ! {next_is, N}, + loop_sequence_number(N + 1) + end. + +get_next_sequence_number(SeqNumServer) -> + SeqNumServer ! {self(), get_next}, + receive {next_is, N} -> N end. + +%% ----------------------------------------------------- +%% Client part +%% Sends requests randomly parallel + +run_clients(NumClients, ServerPort, SeqNumServer) -> + io:format("start clients when" + "~n NumClients: ~w" + "~n ServerPort: ~w" + "~n SeqNumServer: ~w" + "~n", [NumClients, ServerPort, SeqNumServer]), + set_random_seed(), + lists:map( + fun(Id) -> + io:format("starting client ~w~n", [Id]), + Req = f("req~3..0w", [get_next_sequence_number(SeqNumServer)]), + Url = f(?URL_START ++ "~w/~s", [ServerPort, Req]), + Pid = proc_lib:spawn( + fun() -> + io:format("[~w] client started - " + "issue request~n", [Id]), + case http:request(Url) of + {ok, {{_,200,_}, _, Resp}} -> + io:format("[~w] 200 response: " + "~p~n", [Id, Resp]), + case lists:prefix(Req++"->", Resp) of + true -> exit(normal); + false -> exit({bad_resp,Req,Resp}) + end; + {ok, {{_,EC,Reason},_,Resp}} -> + io:format("[~w] ~w response: " + "~s~n~s~n", + [Id, EC, Reason, Resp]), + exit({bad_resp,Req,Resp}); + Crap -> + io:format("[~w] bad response: ~p", + [Id, Crap]), + exit({bad_resp, Req, Crap}) + end + end), + MRef = erlang:monitor(process, Pid), + timer:sleep(10 + random:uniform(1334)), + {Id, Pid, MRef} + + end, + lists:seq(1, NumClients)). + +%% wait_for_clients(Clients) -> +%% lists:foreach( +%% fun({Id, Pid, MRef}) -> +%% io:format("waiting for client ~w termination~n", [Id]), +%% receive +%% {'DOWN', MRef, process, Pid, normal} -> +%% io:format("waiting for clients: " +%% "normal exit from ~w (~p)~n", +%% [Id, Pid]), +%% ok; +%% {'DOWN', MRef, process, Pid, Reason} -> +%% io:format("waiting for clients: " +%% "unexpected exit from ~w (~p):" +%% "~n Reason: ~p" +%% "~n", [Id, Pid, Reason]), +%% erlang:error(Reason) +%% end +%% end, +%% Clients). + + +wait4clients([], _Timeout) -> + ok; +wait4clients(Clients, Timeout) when Timeout > 0 -> + io:format("wait4clients -> entry with" + "~n length(Clients): ~w" + "~n Timeout: ~w" + "~n", [length(Clients), Timeout]), + T = t(), + receive + {'DOWN', _MRef, process, Pid, normal} -> + case lists:keysearch(Pid, 2, Clients) of + {value, {Id, _, _}} -> + io:format("receive normal exit message " + "from client ~p (~p)", [Id, Pid]), + NewClients = + lists:keydelete(Id, 1, Clients), + wait4clients(NewClients, + Timeout - (t() - T)); + false -> + io:format("receive normal exit message " + "from unknown process: ~p", [Pid]), + wait4clients(Clients, Timeout - (t() - T)) + end; + + {'DOWN', _MRef, process, Pid, Reason} -> + case lists:keysearch(Pid, 2, Clients) of + {value, {Id, _, _}} -> + io:format("receive bad exit message " + "from client ~p (~p):" + "~n ~p", [Id, Pid, Reason]), + erlang:error({bad_client_termination, Id, Reason}); + false -> + io:format("receive normal exit message " + "from unknown process: ~p", [Pid]), + wait4clients(Clients, Timeout - (t() - T)) + end + + after Timeout -> + erlang:error({client_timeout, Clients}) + end; +wait4clients(Clients, _) -> + erlang:error({client_timeout, Clients}). + + +%% Time in milli seconds +t() -> + {A,B,C} = erlang:now(), + A*1000000000+B*1000+(C div 1000). + + +%% ----------------------------------------------------- +%% Webserver part: +%% Implements a web server that sends responses one character +%% at a time, with random delays between the characters. + +start_slow_server(SeqNumServer) -> + io:format("start slow server when" + "~n SeqNumServer: ~w" + "~n", [SeqNumServer]), + proc_lib:start( + erlang, apply, [fun() -> init_slow_server(SeqNumServer) end, []]). + +init_slow_server(SeqNumServer) -> + io:format("[webserver ~w] init slow server" + "~n", [SeqNumServer]), + {ok, LSock} = gen_tcp:listen(0, [binary, {packet,0}, {active,true}, + {backlog, 100}]), + io:format("[webserver ~w] LSock: ~p" + "~n", [SeqNumServer, LSock]), + {ok, {_IP, Port}} = inet:sockname(LSock), + io:format("[webserver ~w] Port: ~w" + "~n", [SeqNumServer, Port]), + proc_lib:init_ack({ok, self(), Port}), + loop_slow_server(LSock, SeqNumServer). + +loop_slow_server(LSock, SeqNumServer) -> + io:format("[webserver ~w] entry with" + "~n LSock: ~p" + "~n", [SeqNumServer, LSock]), + Master = self(), + Acceptor = proc_lib:spawn( + fun() -> client_handler(Master, LSock, SeqNumServer) end), + io:format("[webserver ~w] acceptor started" + "~n Acceptor: ~p" + "~n", [SeqNumServer, Acceptor]), + receive + {accepted, Acceptor} -> + io:format("[webserver ~w] accepted" + "~n", [SeqNumServer]), + loop_slow_server(LSock, SeqNumServer); + shutdown -> + gen_tcp:close(LSock), + exit(Acceptor, kill) + end. + + +%% Handle one client connection +client_handler(Master, LSock, SeqNumServer) -> + io:format("[acceptor ~w] await accept" + "~n", [SeqNumServer]), + {ok, CSock} = gen_tcp:accept(LSock), + io:format("[acceptor ~w] accepted" + "~n CSock: ~p" + "~n", [SeqNumServer, CSock]), + Master ! {accepted, self()}, + set_random_seed(), + loop_client(1, CSock, SeqNumServer). + +loop_client(N, CSock, SeqNumServer) -> + %% Await request, don't bother parsing it too much, + %% assuming the entire request arrives in one packet. + io:format("[acceptor ~w] await request" + "~n N: ~p" + "~n", [SeqNumServer, N]), + receive + {tcp, CSock, Req} -> + ReqNum = parse_req_num(Req), + RespSeqNum = get_next_sequence_number(SeqNumServer), + Response = f("~s->resp~3..0w/~2..0w", [ReqNum, RespSeqNum, N]), + Txt = f("Slow server (~p) got ~p, answering with ~p", + [self(), Req, Response]), + io:format("~s...~n", [Txt]), + slowly_send_response(CSock, Response), + case parse_connection_type(Req) of + keep_alive -> + io:format("~s...done~n", [Txt]), + loop_client(N+1, CSock, SeqNumServer); + close -> + io:format("~s...done (closing)~n", [Txt]), + gen_tcp:close(CSock) + end + end. + +slowly_send_response(CSock, Answer) -> + Response = f("HTTP/1.1 200 OK\r\nContent-Length: ~w\r\n\r\n~s", + [length(Answer), Answer]), + lists:foreach( + fun(Char) -> + timer:sleep(random:uniform(500)), + gen_tcp:send(CSock, <<Char>>) + end, + Response). + +parse_req_num(Request) -> + Opts = [caseless,{capture,all_but_first,list}], + {match, [ReqNum]} = re:run(Request, "GET /(.*) HTTP", Opts), + ReqNum. + +parse_connection_type(Request) -> + Opts = [caseless,{capture,all_but_first,list}], + {match,[CType]} = re:run(Request, "connection: *(keep-alive|close)", Opts), + case string:to_lower(CType) of + "close" -> close; + "keep-alive" -> keep_alive + end. + + +set_random_seed() -> + {_, _, Micros} = now(), + A = erlang:phash2([make_ref(), self(), Micros]), + random:seed(A, A, A). + +f(F, A) -> lists:flatten(io_lib:format(F,A)). + + + + +%%------------------------------------------------------------------------- + +otp_8106(suite) -> + [ + otp_8106_pid, + otp_8106_fun, + otp_8106_mfa + ]. + + +otp_8106_pid(doc) -> + ["OTP-8106 - deliver reply info using \"other\" pid"]; +otp_8106_pid(suite) -> + []; +otp_8106_pid(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + ReceiverPid = create_receiver(pid), + Receiver = ReceiverPid, + + otp8106(ReceiverPid, Receiver, Config), + + stop_receiver(ReceiverPid), + + ok; + _ -> + {skip, "Failed to start local http-server"} + end. + + +otp_8106_fun(doc) -> + ["OTP-8106 - deliver reply info using fun"]; +otp_8106_fun(suite) -> + []; +otp_8106_fun(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + ReceiverPid = create_receiver(function), + Receiver = otp_8106_deliver_fun(ReceiverPid), + + otp8106(ReceiverPid, Receiver, Config), + + stop_receiver(ReceiverPid), + + ok; + _ -> + {skip, "Failed to start local http-server"} + end. + + +otp_8106_mfa(doc) -> + ["OTP-8106 - deliver reply info using mfa callback"]; +otp_8106_mfa(suite) -> + []; +otp_8106_mfa(Config) when is_list(Config) -> + case ?config(local_server, Config) of + ok -> + ReceiverPid = create_receiver(mfa), + Receiver = {?MODULE, otp_8106_deliver, [mfa, ReceiverPid]}, + + otp8106(ReceiverPid, Receiver, Config), + + stop_receiver(ReceiverPid), + + ok; + _ -> + {skip, "Failed to start local http-server"} + end. + + + otp8106(ReceiverPid, Receiver, Config) -> + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + Request = {URL, []}, + HTTPOptions = [], + Options = [{sync, false}, {receiver, Receiver}], + + {ok, RequestId} = + httpc:request(get, Request, HTTPOptions, Options), + + Body = + receive + {reply, ReceiverPid, {RequestId, {{_, 200, _}, _, B}}} -> + B; + {reply, ReceiverPid, Msg} -> + tsf(Msg); + {bad_reply, ReceiverPid, Msg} -> + tsf(Msg) + end, + + inets_test_lib:check_body(binary_to_list(Body)), + ok. + + +create_receiver(Type) -> + Parent = self(), + Receiver = fun() -> receiver(Type, Parent) end, + spawn_link(Receiver). + +stop_receiver(Pid) -> + Pid ! {stop, self()}. + +receiver(Type, Parent) -> + receive + {stop, Parent} -> + exit(normal); + + {http, ReplyInfo} when (Type =:= pid) -> + Parent ! {reply, self(), ReplyInfo}, + receiver(Type, Parent); + + {Type, ReplyInfo} -> + Parent ! {reply, self(), ReplyInfo}, + receiver(Type, Parent); + + Crap -> + Parent ! {reply, self(), {bad_reply, Crap}}, + receiver(Type, Parent) + end. + + +otp_8106_deliver_fun(ReceiverPid) -> + fun(ReplyInfo) -> otp_8106_deliver(ReplyInfo, function, ReceiverPid) end. + +otp_8106_deliver(ReplyInfo, Type, ReceiverPid) -> + ReceiverPid ! {Type, ReplyInfo}, + ok. + + + +%%------------------------------------------------------------------------- + +otp_8056(doc) -> + "OTP-8056"; +otp_8056(suite) -> + []; +otp_8056(Config) when is_list(Config) -> + Method = get, + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + Request = {URL, []}, + HTTPOptions = [], + Options1 = [{sync, true}, {stream, {self, once}}], + Options2 = [{sync, true}, {stream, self}], + {error, streaming_error} = httpc:request(Method, Request, + HTTPOptions, Options1), + tsp("request 1 failed as expected"), + {error, streaming_error} = httpc:request(Method, Request, + HTTPOptions, Options2), + tsp("request 2 failed as expected"), + ok. + + +%%------------------------------------------------------------------------- + +otp_8352(doc) -> + "OTP-8352"; +otp_8352(suite) -> + []; +otp_8352(Config) when is_list(Config) -> + tsp("otp_8352 -> entry with" + "~n Config: ~p", [Config]), + case ?config(local_server, Config) of + ok -> + tsp("local-server running"), + + tsp("initial profile info(1): ~p", [httpc:info()]), + + MaxSessions = 5, + MaxKeepAlive = 10, + KeepAliveTimeout = timer:minutes(2), + ConnOptions = [{max_sessions, MaxSessions}, + {max_keep_alive_length, MaxKeepAlive}, + {keep_alive_timeout, KeepAliveTimeout}], + http:set_options(ConnOptions), + + Method = get, + Port = ?config(local_port, Config), + URL = ?URL_START ++ integer_to_list(Port) ++ "/dummy.html", + Request = {URL, []}, + Timeout = timer:seconds(1), + ConnTimeout = Timeout + timer:seconds(1), + HttpOptions1 = [{timeout, Timeout}, {connect_timeout, ConnTimeout}], + Options1 = [{socket_opts, [{tos, 87}, + {recbuf, 16#FFFF}, + {sndbuf, 16#FFFF}]}], + case http:request(Method, Request, HttpOptions1, Options1) of + {ok, {{_,200,_}, [_ | _], ReplyBody1 = [_ | _]}} -> + %% equivaliant to http:request(get, {URL, []}, [], []), + inets_test_lib:check_body(ReplyBody1); + {ok, UnexpectedReply1} -> + tsf({unexpected_reply, UnexpectedReply1}); + {error, _} = Error1 -> + tsf({bad_reply, Error1}) + end, + + tsp("profile info (2): ~p", [httpc:info()]), + + HttpOptions2 = [], + Options2 = [{socket_opts, [{tos, 84}, + {recbuf, 32#1FFFF}, + {sndbuf, 32#1FFFF}]}], + case http:request(Method, Request, HttpOptions2, Options2) of + {ok, {{_,200,_}, [_ | _], ReplyBody2 = [_ | _]}} -> + %% equivaliant to http:request(get, {URL, []}, [], []), + inets_test_lib:check_body(ReplyBody2); + {ok, UnexpectedReply2} -> + tsf({unexpected_reply, UnexpectedReply2}); + {error, _} = Error2 -> + tsf({bad_reply, Error2}) + end, + tsp("profile info (3): ~p", [httpc:info()]), + ok; + + _ -> + {skip, "Failed to start local http-server"} + end. + + +%%------------------------------------------------------------------------- + +otp_8371(doc) -> + ["OTP-8371"]; +otp_8371(suite) -> + []; +otp_8371(Config) when is_list(Config) -> + ok = http:set_options([{ipv6, disabled}]), % also test the old option + {DummyServerPid, Port} = dummy_server(self(), ipv4), + + URL = ?URL_START ++ integer_to_list(Port) ++ + "/ensure_host_header_with_port.html", + + case http:request(get, {URL, []}, [], []) of + {ok, Result} -> + case Result of + {{_, 200, _}, _Headers, Body} -> + tsp("expected response with" + "~n Body: ~p", [Body]), + ok; + {StatusLine, Headers, Body} -> + tsp("expected response with" + "~n StatusLine: ~p" + "~n Headers: ~p" + "~n Body: ~p", [StatusLine, Headers, Body]), + tsf({unexpected_result, + [{status_line, StatusLine}, + {headers, Headers}, + {body, Body}]}); + _ -> + tsf({unexpected_result, Result}) + end; + Error -> + tsf({request_failed, Error}) + end, + + DummyServerPid ! stop, + ok = http:set_options([{ipv6, enabled}]), + ok. + + + +%%-------------------------------------------------------------------- +%% Internal functions +%%-------------------------------------------------------------------- +setup_server_dirs(ServerRoot, DocRoot, DataDir) -> + ConfDir = filename:join(ServerRoot, "conf"), + CgiDir = filename:join(ServerRoot, "cgi-bin"), + ok = file:make_dir(ServerRoot), + ok = file:make_dir(DocRoot), + ok = file:make_dir(ConfDir), + ok = file:make_dir(CgiDir), + + {ok, Files} = file:list_dir(DataDir), + + lists:foreach(fun(File) -> case lists:suffix(".html", File) of + true -> + inets_test_lib:copy_file(File, + DataDir, + DocRoot); + false -> + ok + end + end, Files), + + Cgi = case test_server:os_type() of + {win32, _} -> + "cgi_echo.exe"; + _ -> + "cgi_echo" + end, + + inets_test_lib:copy_file(Cgi, DataDir, CgiDir), + inets_test_lib:copy_file("mime.types", DataDir, ConfDir). + +create_config(FileName, ComType, Port, PrivDir, ServerRoot, DocRoot, + SSLDir) -> + MaxHdrSz = io_lib:format("~p", [256]), + MaxHdrAct = io_lib:format("~p", [close]), + SSL = + case ComType of + ssl -> + [cline(["SSLCertificateFile ", + filename:join(SSLDir, "ssl_server_cert.pem")]), + cline(["SSLCertificateKeyFile ", + filename:join(SSLDir, "ssl_server_cert.pem")]), + cline(["SSLVerifyClient 0"])]; + _ -> + [] + end, + + Mod_order = "Modules mod_alias mod_auth mod_esi mod_actions mod_cgi" + " mod_include mod_dir mod_get mod_head" + " mod_log mod_disk_log mod_trace", + + HttpConfig = [ + cline(["Port ", integer_to_list(Port)]), + cline(["ServerName ", "httpc_test"]), + cline(["SocketType ", atom_to_list(ComType)]), + cline([Mod_order]), + cline(["ServerRoot ", ServerRoot]), + cline(["DocumentRoot ", DocRoot]), + cline(["MaxHeaderSize ",MaxHdrSz]), + cline(["MaxHeaderAction ",MaxHdrAct]), + cline(["DirectoryIndex ", "index.html "]), + cline(["DefaultType ", "text/plain"]), + cline(["ScriptAlias /cgi-bin/ ", + filename:join(ServerRoot, "cgi-bin"), "/"]), + SSL], + ConfigFile = filename:join([PrivDir,FileName]), + {ok, Fd} = file:open(ConfigFile, [write]), + ok = file:write(Fd, lists:flatten(HttpConfig)), + ok = file:close(Fd). + +cline(List) -> + lists:flatten([List, "\r\n"]). + +is_proxy_available(Proxy, Port) -> + case gen_tcp:connect(Proxy, Port, []) of + {ok, Socket} -> + gen_tcp:close(Socket), + true; + _ -> + false + end. + +receive_streamed_body(RequestId, Body) -> + receive + {http, {RequestId, stream, BinBodyPart}} -> + receive_streamed_body(RequestId, + <<Body/binary, BinBodyPart/binary>>); + {http, {RequestId, stream_end, _Headers}} -> + Body; + {http, Msg} -> + test_server:fail(Msg) + end. + +receive_streamed_body(RequestId, Body, Pid) -> + http:stream_next(Pid), + test_server:format("~p:receive_streamed_body -> requested next stream ~n", [?MODULE]), + receive + {http, {RequestId, stream, BinBodyPart}} -> + receive_streamed_body(RequestId, + <<Body/binary, BinBodyPart/binary>>, + Pid); + {http, {RequestId, stream_end, _Headers}} -> + Body; + {http, Msg} -> + test_server:fail(Msg) + end. + + + +dummy_server(Caller, IpV) -> + Pid = spawn(httpc_SUITE, dummy_server_init, [Caller, IpV]), + receive + {port, Port} -> + {Pid, Port} + end. + +dummy_server_init(Caller, IpV) -> + {ok, ListenSocket} = + case IpV of + ipv4 -> + gen_tcp:listen(0, [binary, inet, {packet, 0}, + {reuseaddr,true}, + {active, false}]); + ipv6 -> + gen_tcp:listen(0, [binary, inet6, {packet, 0}, + {reuseaddr,true}, + {active, false}]) + end, + {ok, Port} = inet:port(ListenSocket), + tsp("dummy_server_init -> Port: ~p", [Port]), + Caller ! {port, Port}, + dummy_server_loop({httpd_request, parse, [?HTTP_MAX_HEADER_SIZE]}, + [], ListenSocket). + +dummy_server_loop(MFA, Handlers, ListenSocket) -> + receive + stop -> + lists:foreach(fun(Handler) -> Handler ! stop end, Handlers) + after 0 -> + {ok, Socket} = gen_tcp:accept(ListenSocket), + HandlerPid = dummy_request_handler(MFA, Socket), + gen_tcp:controlling_process(Socket, HandlerPid), + HandlerPid ! controller, + dummy_server_loop(MFA, [HandlerPid | Handlers], + ListenSocket) + end. + +dummy_request_handler(MFA, Socket) -> + spawn(httpc_SUITE, dummy_request_handler_init, [MFA, Socket]). + +dummy_request_handler_init(MFA, Socket) -> + receive + controller -> + inet:setopts(Socket, [{active, true}]) + end, + dummy_request_handler_loop(MFA, Socket). + +dummy_request_handler_loop({Module, Function, Args}, Socket) -> + tsp("dummy_request_handler_loop -> entry with" + "~n Module: ~p" + "~n Function: ~p" + "~n Args: ~p", [Module, Function, Args]), + receive + {tcp, _, Data} -> + tsp("dummy_request_handler_loop -> Data ~p", [Data]), + case handle_request(Module, Function, [Data | Args], Socket) of + stop -> + gen_tcp:close(Socket); + NewMFA -> + dummy_request_handler_loop(NewMFA, Socket) + end; + stop -> + gen_tcp:close(Socket) + end. + +handle_request(Module, Function, Args, Socket) -> + tsp("handle_request -> entry with" + "~n Module: ~p" + "~n Function: ~p" + "~n Args: ~p", [Module, Function, Args]), + case Module:Function(Args) of + {ok, Result} -> + tsp("handle_request -> ok" + "~n Result: ~p", [Result]), + case (catch handle_http_msg(Result, Socket)) of + stop -> + stop; + <<>> -> + tsp("handle_request -> empty data"), + {httpd_request, parse, [[<<>>, ?HTTP_MAX_HEADER_SIZE]]}; + Data -> + handle_request(httpd_request, parse, + [Data |[?HTTP_MAX_HEADER_SIZE]], Socket) + end; + NewMFA -> + tsp("handle_request -> " + "~n NewMFA: ~p", [NewMFA]), + NewMFA + end. + +handle_http_msg({_, RelUri, _, {_, Headers}, Body}, Socket) -> + tsp("handle_http_msg -> entry with: " + "~n RelUri: ~p" + "~n Headers: ~p" + "~n Body: ~p", [RelUri, Headers, Body]), + NextRequest = + case RelUri of + "/dummy_headers.html" -> + <<>>; + "/no_headers.html" -> + stop; + "/just_close.html" -> + stop; + _ -> + ContentLength = content_length(Headers), + case size(Body) - ContentLength of + 0 -> + <<>>; + _ -> + <<_BodyThisReq:ContentLength/binary, + Next/binary>> = Body, + Next + end + end, + + tsp("handle_http_msg -> NextRequest: ~p", [NextRequest]), + case (catch ets:lookup(cookie, cookies)) of + [{cookies, true}]-> + tsp("handle_http_msg -> check cookies ~p", []), + check_cookie(Headers); + _ -> + ok + end, + + DefaultResponse = "HTTP/1.1 200 ok\r\n" ++ + "Content-Length:32\r\n\r\n" + "<HTML><BODY>foobar</BODY></HTML>", + + Msg = + case RelUri of + "/just_close.html" -> + close; + "/no_content.html" -> + "HTTP/1.0 204 No Content\r\n\r\n"; + "/no_headers.html" -> + "HTTP/1.0 200 OK\r\n\r\nTEST"; + "/ensure_host_header_with_port.html" -> + %% tsp("handle_http_msg -> validate host with port"), + case ensure_host_header_with_port(Headers) of + true -> + B = + "<HTML><BODY>" ++ + "host with port" ++ + "</BODY></HTML>", + Len = integer_to_list(length(B)), + "HTTP/1.1 200 ok\r\n" ++ + "Content-Length:" ++ Len ++ "\r\n\r\n" ++ B; + false -> + B = + "<HTML><BODY>" ++ + "Internal Server Error - host without port" ++ + "</BODY></HTML>", + Len = integer_to_list(length(B)), + "HTTP/1.1 500 Internal Server Error\r\n" ++ + "Content-Length:" ++ Len ++ "\r\n\r\n" ++ B + end; + "/300.html" -> + NewUri = ?URL_START ++ + integer_to_list(?IP_PORT) ++ "/dummy.html", + "HTTP/1.1 300 Multiple Choices\r\n" ++ + "Location:" ++ NewUri ++ "\r\n" ++ + "Content-Length:0\r\n\r\n"; + "/301.html" -> + NewUri = ?URL_START ++ + integer_to_list(?IP_PORT) ++ "/dummy.html", + "HTTP/1.1 301 Moved Permanently\r\n" ++ + "Location:" ++ NewUri ++ "\r\n" ++ + "Content-Length:80\r\n\r\n" ++ + "<HTML><BODY><a href=" ++ NewUri ++ + ">New place</a></BODY></HTML>"; + "/302.html" -> + NewUri = ?URL_START ++ + integer_to_list(?IP_PORT) ++ "/dummy.html", + "HTTP/1.1 302 Found \r\n" ++ + "Location:" ++ NewUri ++ "\r\n" ++ + "Content-Length:80\r\n\r\n" ++ + "<HTML><BODY><a href=" ++ NewUri ++ + ">New place</a></BODY></HTML>"; + "/307.html" -> + NewUri = ?URL_START ++ + integer_to_list(?IP_PORT) ++ "/dummy.html", + "HTTP/1.1 307 Temporary Rediect \r\n" ++ + "Location:" ++ NewUri ++ "\r\n" ++ + "Content-Length:80\r\n\r\n" ++ + "<HTML><BODY><a href=" ++ NewUri ++ + ">New place</a></BODY></HTML>"; + "/500.html" -> + "HTTP/1.1 500 Internal Server Error\r\n" ++ + "Content-Length:47\r\n\r\n" ++ + "<HTML><BODY>Internal Server Error</BODY></HTML>"; + "/503.html" -> + case ets:lookup(unavailable, 503) of + [{503, unavailable}] -> + ets:insert(unavailable, {503, available}), + "HTTP/1.1 503 Service Unavailable\r\n" ++ + "Retry-After:5\r\n" ++ + "Content-Length:47\r\n\r\n" ++ + "<HTML><BODY>Internal Server Error</BODY></HTML>"; + [{503, available}] -> + DefaultResponse; + [{503, long_unavailable}] -> + "HTTP/1.1 503 Service Unavailable\r\n" ++ + "Retry-After:120\r\n" ++ + "Content-Length:47\r\n\r\n" ++ + "<HTML><BODY>Internal Server Error</BODY></HTML>" + end; + "/redirectloop.html" -> %% Create a potential endless loop! + {ok, Port} = inet:port(Socket), + NewUri = ?URL_START ++ + integer_to_list(Port) ++ "/redirectloop.html", + "HTTP/1.1 300 Multiple Choices\r\n" ++ + "Location:" ++ NewUri ++ "\r\n" ++ + "Content-Length:0\r\n\r\n"; + "/userinfo.html" -> + Challange = "HTTP/1.1 401 Unauthorized \r\n" ++ + "WWW-Authenticate:Basic" ++"\r\n" ++ + "Content-Length:0\r\n\r\n", + case auth_header(Headers) of + {ok, Value} -> + handle_auth(Value, Challange, DefaultResponse); + _ -> + Challange + end; + "/dummy_headers.html" -> + %% The client will only care about the Transfer-Encoding + %% header the rest of these headers are left to the + %% user to evaluate. This is not a valid response + %% it only tests that the header handling code works. + Head = "HTTP/1.1 200 ok\r\n" ++ + "Content-Length:32\r\n" ++ + "Pragma:1#no-cache\r\n" ++ + "Via:1.0 fred, 1.1 nowhere.com (Apache/1.1)\r\n" ++ + "Warning:1#pseudonym foobar\r\n" ++ + "Vary:*\r\n" ++ + "Trailer:Other:inets_test\r\n" ++ + "Upgrade:HTTP/2.0\r\n" ++ + "Age:4711\r\n" ++ + "Transfer-Encoding:chunked\r\n" ++ + "Content-Encoding:foo\r\n" ++ + "Content-Language:en\r\n" ++ + "Content-Location:http://www.foobar.se\r\n" ++ + "Content-MD5:104528739076276072743283077410617235478\r\n" + ++ + "Content-Range:Sat, 29 Oct 1994 19:43:31 GMT\r\n" ++ + "Expires:Sat, 29 Oct 1994 19:43:31 GMT\r\n" ++ + "Proxy-Authenticate:#1Basic" ++ + "\r\n\r\n", + gen_tcp:send(Socket, Head), + gen_tcp:send(Socket, http_chunk:encode("<HTML><BODY>fo")), + gen_tcp:send(Socket, http_chunk:encode("obar</BODY></HTML>")), + http_chunk:encode_last(); + "/capital_transfer_encoding.html" -> + Head = "HTTP/1.1 200 ok\r\n" ++ + "Transfer-Encoding:Chunked\r\n\r\n", + gen_tcp:send(Socket, Head), + gen_tcp:send(Socket, http_chunk:encode("<HTML><BODY>fo")), + gen_tcp:send(Socket, http_chunk:encode("obar</BODY></HTML>")), + http_chunk:encode_last(); + "/cookie.html" -> + "HTTP/1.1 200 ok\r\n" ++ + "set-cookie:" ++ "test_cookie=true; path=/;" ++ + "max-age=60000\r\n" ++ + "Content-Length:32\r\n\r\n"++ + "<HTML><BODY>foobar</BODY></HTML>"; + "/missing_crlf.html" -> + "HTTP/1.1 200 ok" ++ + "Content-Length:32\r\n" ++ + "<HTML><BODY>foobar</BODY></HTML>"; + "/wrong_statusline.html" -> + "ok 200 HTTP/1.1\r\n\r\n" ++ + "Content-Length:32\r\n\r\n" ++ + "<HTML><BODY>foobar</BODY></HTML>"; + "/once_chunked.html" -> + Head = "HTTP/1.1 200 ok\r\n" ++ + "Transfer-Encoding:Chunked\r\n\r\n", + gen_tcp:send(Socket, Head), + gen_tcp:send(Socket, http_chunk:encode("<HTML><BODY>fo")), + gen_tcp:send(Socket, + http_chunk:encode("obar</BODY></HTML>")), + http_chunk:encode_last(); + "/once.html" -> + Head = "HTTP/1.1 200 ok\r\n" ++ + "Content-Length:32\r\n\r\n", + gen_tcp:send(Socket, Head), + gen_tcp:send(Socket, "<HTML><BODY>fo"), + test_server:sleep(1000), + gen_tcp:send(Socket, "ob"), + test_server:sleep(1000), + gen_tcp:send(Socket, "ar</BODY></HTML>"); + "/invalid_http.html" -> + "HTTP/1.1 301\r\nDate:Sun, 09 Dec 2007 13:04:18 GMT\r\n" ++ + "Transfer-Encoding:chunked\r\n\r\n"; + "/missing_reason_phrase.html" -> + "HTTP/1.1 200\r\n" ++ + "Content-Length: 32\r\n\r\n" + "<HTML><BODY>foobar</BODY></HTML>"; + "/missing_CR.html" -> + "HTTP/1.1 200 ok\n" ++ + "Content-Length:32\r\n\n" + "<HTML><BODY>foobar</BODY></HTML>"; + _ -> + DefaultResponse + end, + + tsp("handle_http_msg -> Msg: ~p", [Msg]), + case Msg of + ok -> + %% Previously, this resulted in an {error, einval}. Now what? + ok; + close -> + %% Nothing to send, just close + gen_tcp:close(Socket); + _ when is_list(Msg) orelse is_binary(Msg) -> + gen_tcp:send(Socket, Msg) + end, + tsp("handle_http_msg -> done"), + NextRequest. + +ensure_host_header_with_port([]) -> + false; +ensure_host_header_with_port(["host: " ++ Host| _]) -> + case string:tokens(Host, [$:]) of + [ActualHost, Port] -> + tsp("ensure_host_header_with_port -> " + "~n ActualHost: ~p" + "~n Port: ~p", [ActualHost, Port]), + true; + _ -> + false + end; +ensure_host_header_with_port([_|T]) -> + ensure_host_header_with_port(T). + +auth_header([]) -> + auth_header_not_found; +auth_header(["authorization:" ++ Value | _]) -> + {ok, string:strip(Value)}; +auth_header([_ | Tail]) -> + auth_header(Tail). + +handle_auth("Basic " ++ UserInfo, Challange, DefaultResponse) -> + case string:tokens(base64:decode_to_string(UserInfo), ":") of + ["alladin", "sesame"] = Auth -> + test_server:format("Auth: ~p~n", [Auth]), + DefaultResponse; + Other -> + test_server:format("UnAuth: ~p~n", [Other]), + Challange + end. + +check_cookie([]) -> + test_server:fail(no_cookie_header); +check_cookie(["cookie:" ++ _Value | _]) -> + ok; +check_cookie([_Head | Tail]) -> + check_cookie(Tail). + +content_length([]) -> + 0; +content_length(["content-length:" ++ Value | _]) -> + list_to_integer(string:strip(Value)); +content_length([_Head | Tail]) -> + content_length(Tail). + +provocate_not_modified_bug(Url) -> + Timeout = 15000, %% 15s should be plenty + + {ok, {{_, 200, _}, ReplyHeaders, _Body}} = + http:request(get, {Url, []}, [{timeout, Timeout}], []), + Etag = pick_header(ReplyHeaders, "ETag"), + Last = pick_header(ReplyHeaders, "last-modified"), + + case http:request(get, {Url, [{"If-None-Match", Etag}, + {"If-Modified-Since", Last}]}, + [{timeout, 15000}], + []) of + {ok, {{_, 304, _}, _, _}} -> %% The expected reply + page_unchanged; + {ok, {{_, 200, _}, _, _}} -> + %% If the page has changed since the + %% last request we retry to + %% trigger the bug + provocate_not_modified_bug(Url); + {error, timeout} -> + %% Not what we expected. Tcpdump can be used to + %% verify that we receive the complete http-reply + %% but still time out. + incorrect_result + end. + +pick_header(Headers, Name) -> + case lists:keysearch(string:to_lower(Name), 1, + [{string:to_lower(X), Y} || {X, Y} <- Headers]) of + false -> + []; + {value, {_Key, Val}} -> + Val + end. + + +not_implemented_yet() -> + exit(not_implemented_yet). + + +p(F) -> + p(F, []). + +p(F, A) -> + io:format("~p ~w:" ++ F ++ "~n", [self(), ?MODULE | A]). + +tsp(F) -> + tsp(F, []). +tsp(F, A) -> + test_server:format("~p ~p:" ++ F ++ "~n", [self(), ?MODULE | A]). + +tsf(Reason) -> + test_server:fail(Reason). diff --git a/lib/inets/test/httpc_SUITE_data/Makefile.src b/lib/inets/test/httpc_SUITE_data/Makefile.src new file mode 120000 index 0000000000..ad6e7bf9c8 --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/Makefile.src @@ -0,0 +1 @@ +../httpd_SUITE_data/Makefile.src
\ No newline at end of file diff --git a/lib/inets/test/httpc_SUITE_data/cgi_echo.c b/lib/inets/test/httpc_SUITE_data/cgi_echo.c new file mode 120000 index 0000000000..38e06fe0d2 --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/cgi_echo.c @@ -0,0 +1 @@ +../httpd_SUITE_data/cgi_echo.c
\ No newline at end of file diff --git a/lib/inets/test/httpc_SUITE_data/dummy.html b/lib/inets/test/httpc_SUITE_data/dummy.html new file mode 100644 index 0000000000..9a960ecc8a --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/dummy.html @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<title>Dummy</title> +</head> + +<body> +<h1>Dummy</h1> + +<p>This is a dummy html file! </p> +</body> +</html> diff --git a/lib/inets/test/httpc_SUITE_data/empty.html b/lib/inets/test/httpc_SUITE_data/empty.html new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/empty.html diff --git a/lib/inets/test/httpc_SUITE_data/mime.types b/lib/inets/test/httpc_SUITE_data/mime.types new file mode 100644 index 0000000000..d2f81e4e5e --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/mime.types @@ -0,0 +1,465 @@ +# This is a comment. I love comments. + +# MIME type Extension +application/EDI-Consent +application/EDI-X12 +application/EDIFACT +application/activemessage +application/andrew-inset ez +application/applefile +application/atomicmail +application/batch-SMTP +application/beep+xml +application/cals-1840 +application/commonground +application/cybercash +application/dca-rft +application/dec-dx +application/dvcs +application/eshop +application/http +application/hyperstudio +application/iges +application/index +application/index.cmd +application/index.obj +application/index.response +application/index.vnd +application/iotp +application/ipp +application/isup +application/font-tdpfr +application/mac-binhex40 hqx +application/mac-compactpro cpt +application/macwriteii +application/marc +application/mathematica +application/mathematica-old +application/msword doc +application/news-message-id +application/news-transmission +application/ocsp-request +application/ocsp-response +application/octet-stream bin dms lha lzh exe class so dll +application/oda oda +application/parityfec +application/pdf pdf +application/pgp-encrypted +application/pgp-keys +application/pgp-signature +application/pkcs10 +application/pkcs7-mime +application/pkcs7-signature +application/pkix-cert +application/pkix-crl +application/pkixcmp +application/postscript ai eps ps +application/prs.alvestrand.titrax-sheet +application/prs.cww +application/prs.nprend +application/qsig +application/remote-printing +application/riscos +application/rtf +application/sdp +application/set-payment +application/set-payment-initiation +application/set-registration +application/set-registration-initiation +application/sgml +application/sgml-open-catalog +application/sieve +application/slate +application/smil smi smil +application/timestamp-query +application/timestamp-reply +application/vemmi +application/vnd.3M.Post-it-Notes +application/vnd.FloGraphIt +application/vnd.accpac.simply.aso +application/vnd.accpac.simply.imp +application/vnd.acucobol +application/vnd.aether.imp +application/vnd.anser-web-certificate-issue-initiation +application/vnd.anser-web-funds-transfer-initiation +application/vnd.audiograph +application/vnd.businessobjects +application/vnd.bmi +application/vnd.canon-cpdl +application/vnd.canon-lips +application/vnd.claymore +application/vnd.commerce-battelle +application/vnd.commonspace +application/vnd.comsocaller +application/vnd.contact.cmsg +application/vnd.cosmocaller +application/vnd.cups-postscript +application/vnd.cups-raster +application/vnd.cups-raw +application/vnd.ctc-posml +application/vnd.cybank +application/vnd.dna +application/vnd.dpgraph +application/vnd.dxr +application/vnd.ecdis-update +application/vnd.ecowin.chart +application/vnd.ecowin.filerequest +application/vnd.ecowin.fileupdate +application/vnd.ecowin.series +application/vnd.ecowin.seriesrequest +application/vnd.ecowin.seriesupdate +application/vnd.enliven +application/vnd.epson.esf +application/vnd.epson.msf +application/vnd.epson.quickanime +application/vnd.epson.salt +application/vnd.epson.ssf +application/vnd.ericsson.quickcall +application/vnd.eudora.data +application/vnd.fdf +application/vnd.ffsns +application/vnd.framemaker +application/vnd.fsc.weblaunch +application/vnd.fujitsu.oasys +application/vnd.fujitsu.oasys2 +application/vnd.fujitsu.oasys3 +application/vnd.fujitsu.oasysgp +application/vnd.fujitsu.oasysprs +application/vnd.fujixerox.ddd +application/vnd.fujixerox.docuworks +application/vnd.fujixerox.docuworks.binder +application/vnd.fut-misnet +application/vnd.grafeq +application/vnd.groove-account +application/vnd.groove-identity-message +application/vnd.groove-injector +application/vnd.groove-tool-message +application/vnd.groove-tool-template +application/vnd.groove-vcard +application/vnd.hhe.lesson-player +application/vnd.hp-HPGL +application/vnd.hp-PCL +application/vnd.hp-PCLXL +application/vnd.hp-hpid +application/vnd.hp-hps +application/vnd.httphone +application/vnd.hzn-3d-crossword +application/vnd.ibm.afplinedata +application/vnd.ibm.MiniPay +application/vnd.ibm.modcap +application/vnd.informix-visionary +application/vnd.intercon.formnet +application/vnd.intertrust.digibox +application/vnd.intertrust.nncp +application/vnd.intu.qbo +application/vnd.intu.qfx +application/vnd.irepository.package+xml +application/vnd.is-xpr +application/vnd.japannet-directory-service +application/vnd.japannet-jpnstore-wakeup +application/vnd.japannet-payment-wakeup +application/vnd.japannet-registration +application/vnd.japannet-registration-wakeup +application/vnd.japannet-setstore-wakeup +application/vnd.japannet-verification +application/vnd.japannet-verification-wakeup +application/vnd.koan +application/vnd.lotus-1-2-3 +application/vnd.lotus-approach +application/vnd.lotus-freelance +application/vnd.lotus-notes +application/vnd.lotus-organizer +application/vnd.lotus-screencam +application/vnd.lotus-wordpro +application/vnd.mcd +application/vnd.mediastation.cdkey +application/vnd.meridian-slingshot +application/vnd.mif mif +application/vnd.minisoft-hp3000-save +application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf +application/vnd.mobius.dis +application/vnd.mobius.msl +application/vnd.mobius.plc +application/vnd.mobius.txf +application/vnd.motorola.flexsuite +application/vnd.motorola.flexsuite.adsi +application/vnd.motorola.flexsuite.fis +application/vnd.motorola.flexsuite.gotap +application/vnd.motorola.flexsuite.kmr +application/vnd.motorola.flexsuite.ttc +application/vnd.motorola.flexsuite.wem +application/vnd.mozilla.xul+xml +application/vnd.ms-artgalry +application/vnd.ms-asf +application/vnd.ms-excel xls +application/vnd.ms-lrm +application/vnd.ms-powerpoint ppt +application/vnd.ms-project +application/vnd.ms-tnef +application/vnd.ms-works +application/vnd.mseq +application/vnd.msign +application/vnd.music-niff +application/vnd.musician +application/vnd.netfpx +application/vnd.noblenet-directory +application/vnd.noblenet-sealer +application/vnd.noblenet-web +application/vnd.novadigm.EDM +application/vnd.novadigm.EDX +application/vnd.novadigm.EXT +application/vnd.osa.netdeploy +application/vnd.palm +application/vnd.pg.format +application/vnd.pg.osasli +application/vnd.powerbuilder6 +application/vnd.powerbuilder6-s +application/vnd.powerbuilder7 +application/vnd.powerbuilder7-s +application/vnd.powerbuilder75 +application/vnd.powerbuilder75-s +application/vnd.previewsystems.box +application/vnd.publishare-delta-tree +application/vnd.pvi.ptid1 +application/vnd.pwg-xhtml-print+xml +application/vnd.rapid +application/vnd.s3sms +application/vnd.seemail +application/vnd.shana.informed.formdata +application/vnd.shana.informed.formtemplate +application/vnd.shana.informed.interchange +application/vnd.shana.informed.package +application/vnd.sss-cod +application/vnd.sss-dtf +application/vnd.sss-ntf +application/vnd.street-stream +application/vnd.svd +application/vnd.swiftview-ics +application/vnd.triscape.mxs +application/vnd.trueapp +application/vnd.truedoc +application/vnd.tve-trigger +application/vnd.ufdl +application/vnd.uplanet.alert +application/vnd.uplanet.alert-wbxml +application/vnd.uplanet.bearer-choice-wbxml +application/vnd.uplanet.bearer-choice +application/vnd.uplanet.cacheop +application/vnd.uplanet.cacheop-wbxml +application/vnd.uplanet.channel +application/vnd.uplanet.channel-wbxml +application/vnd.uplanet.list +application/vnd.uplanet.list-wbxml +application/vnd.uplanet.listcmd +application/vnd.uplanet.listcmd-wbxml +application/vnd.uplanet.signal +application/vnd.vcx +application/vnd.vectorworks +application/vnd.vidsoft.vidconference +application/vnd.visio +application/vnd.vividence.scriptfile +application/vnd.wap.sic +application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo +application/vnd.wrq-hp3000-labelled +application/vnd.wt.stf +application/vnd.xara +application/vnd.xfdl +application/vnd.yellowriver-custom-menu +application/whoispp-query +application/whoispp-response +application/wita +application/wordperfect5.1 +application/x-bcpio bcpio +application/x-cdlink vcd +application/x-chess-pgn pgn +application/x-compress +application/x-cpio cpio +application/x-csh csh +application/x-director dcr dir dxr +application/x-dvi dvi +application/x-futuresplash spl +application/x-gtar gtar +application/x-gzip +application/x-hdf hdf +application/x-javascript js +application/x-koan skp skd skt skm +application/x-latex latex +application/x-netcdf nc cdf +application/x-sh sh +application/x-shar shar +application/x-shockwave-flash swf +application/x-stuffit sit +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-tar tar +application/x-tcl tcl +application/x-tex tex +application/x-texinfo texinfo texi +application/x-troff t tr roff +application/x-troff-man man +application/x-troff-me me +application/x-troff-ms ms +application/x-ustar ustar +application/x-wais-source src +application/x400-bp +application/xml +application/xml-dtd +application/xml-external-parsed-entity +application/zip zip +audio/32kadpcm +audio/basic au snd +audio/g.722.1 +audio/l16 +audio/midi mid midi kar +audio/mp4a-latm +audio/mpa-robust +audio/mpeg mpga mp2 mp3 +audio/parityfec +audio/prs.sid +audio/telephone-event +audio/tone +audio/vnd.cisco.nse +audio/vnd.cns.anp1 +audio/vnd.cns.inf1 +audio/vnd.digital-winds +audio/vnd.everad.plj +audio/vnd.lucent.voice +audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 +audio/vnd.nuera.ecelp7470 +audio/vnd.nuera.ecelp9600 +audio/vnd.octel.sbc +audio/vnd.qcelp +audio/vnd.rhetorex.32kadpcm +audio/vnd.vmx.cvsd +audio/x-aiff aif aiff aifc +audio/x-mpegurl m3u +audio/x-pn-realaudio ram rm +audio/x-pn-realaudio-plugin rpm +audio/x-realaudio ra +audio/x-wav wav +chemical/x-pdb pdb +chemical/x-xyz xyz +image/bmp bmp +image/cgm +image/g3fax +image/gif gif +image/ief ief +image/jpeg jpeg jpg jpe +image/naplps +image/png png +image/prs.btif +image/prs.pti +image/tiff tiff tif +image/vnd.cns.inf2 +image/vnd.dwg +image/vnd.dxf +image/vnd.fastbidsheet +image/vnd.fpx +image/vnd.fst +image/vnd.fujixerox.edmics-mmr +image/vnd.fujixerox.edmics-rlc +image/vnd.mix +image/vnd.net-fpx +image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff +image/x-cmu-raster ras +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd +message/delivery-status +message/disposition-notification +message/external-body +message/http +message/news +message/partial +message/rfc822 +message/s-http +model/iges igs iges +model/mesh msh mesh silo +model/vnd.dwf +model/vnd.flatland.3dml +model/vnd.gdl +model/vnd.gs-gdl +model/vnd.gtw +model/vnd.mts +model/vnd.vtu +model/vrml wrl vrml +multipart/alternative +multipart/appledouble +multipart/byteranges +multipart/digest +multipart/encrypted +multipart/form-data +multipart/header-set +multipart/mixed +multipart/parallel +multipart/related +multipart/report +multipart/signed +multipart/voice-message +text/calendar +text/css css +text/directory +text/enriched +text/html html htm +text/parityfec +text/plain asc txt +text/prs.lines.tag +text/rfc822-headers +text/richtext rtx +text/rtf rtf +text/sgml sgml sgm +text/tab-separated-values tsv +text/t140 +text/uri-list +text/vnd.DMClientScript +text/vnd.IPTC.NITF +text/vnd.IPTC.NewsML +text/vnd.abc +text/vnd.curl +text/vnd.flatland.3dml +text/vnd.fly +text/vnd.fmi.flexstor +text/vnd.in3d.3dml +text/vnd.in3d.spot +text/vnd.latex-z +text/vnd.motorola.reflex +text/vnd.ms-mediapackage +text/vnd.wap.si +text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-setext etx +text/x-server-parsed-html shtml +text/xml xml xsl +text/xml-external-parsed-entity +video/mp4v-es +video/mpeg mpeg mpg mpe +video/parityfec +video/pointer +video/quicktime qt mov +video/vnd.fvt +video/vnd.motorola.video +video/vnd.motorola.videop +video/vnd.mpegurl mxu +video/vnd.mts +video/vnd.nokia.interleaved-multimedia +video/vnd.vivo +video/x-msvideo avi +video/x-sgi-movie movie +x-conference/x-cooltalk ice + + + diff --git a/lib/inets/test/httpc_SUITE_data/redirect.html b/lib/inets/test/httpc_SUITE_data/redirect.html new file mode 100644 index 0000000000..7034461ed6 --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/redirect.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> <head> +<meta http-eqviv="Refresh", content="10;URL=http://localhost:8888/dummy.html"> +<title>Redirect</title> + +</head> + +<body> +<p> You will be redirected</p> +</body> </html> diff --git a/lib/inets/test/httpc_SUITE_data/ssl_client_cert.pem b/lib/inets/test/httpc_SUITE_data/ssl_client_cert.pem new file mode 100644 index 0000000000..f274d2021d --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/ssl_client_cert.pem @@ -0,0 +1,22 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBOwIBAAJBANz7eFvORmJDi1XJMM2U3uHC5wmp/DXTLMw08XaEvtZ73wgVg84E +V0oyX3Kh1thRE3Hch9AyrHjgpizCj9/Ra38CAwEAAQJACzpz2SZYCTIpaEh6xFdm +I86FcsZCXHHIeu/NvRntoHQ+nfM7Np379+z6XNJWIcWh/QgG/jNJalR1BO+eyc6/ +YQIhAP3m8M0LDxJwSgHFtGAGatQqaqw9l48Kq5xdMFqvdpiHAiEA3s7lld6yCJYu +6q7fZjTH+eKUwgg0vpgJutP7Fsok60kCIHHesQBEhW3vjkFdOZgXSLH+k/jLZr1w +O6bU5GrHZpjhAiEAyTvGYcjDtTunXjDY9l+fadK6FlEBCk8ZIpNIiTnDhHkCIQDr +QxxLLuNHRj8iWNbuVVZ99SJy8zC33pMgPFaFKaZesQ== +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIB7jCCAZgCAQAwDQYJKoZIhvcNAQEEBQAwgYExCzAJBgNVBAYTAlNFMRIwEAYD +VQQHEwlTdG9ja2hvbG0xETAPBgNVBAoTCEVyaWNzc29uMQwwCgYDVQQLEwNFVFgx +FjAUBgNVBAMTDUhlbGVuIEFpcml5YW4xJTAjBgkqhkiG9w0BCQEWFmhlbGVuQGVy +aXguZXJpY3Nzb24uc2UwHhcNOTcwNzI4MDcxNDI1WhcNOTgxMjEwMDcxNDI1WjCB +gTELMAkGA1UEBhMCU0UxEjAQBgNVBAcTCVN0b2NraG9sbTERMA8GA1UEChMIRXJp +Y3Nzb24xDDAKBgNVBAsTA0VUWDEWMBQGA1UEAxMNSGVsZW4gQWlyaXlhbjElMCMG +CSqGSIb3DQEJARYWaGVsZW5AZXJpeC5lcmljc3Nvbi5zZTBcMA0GCSqGSIb3DQEB +AQUAA0sAMEgCQQDc+3hbzkZiQ4tVyTDNlN7hwucJqfw10yzMNPF2hL7We98IFYPO +BFdKMl9yodbYURNx3IfQMqx44KYswo/f0Wt/AgMBAAEwDQYJKoZIhvcNAQEEBQAD +QQC2++hLIaQJ4ChCjFE9UCfXO9cZ3Vq/FT9VjE+G4MRBDo4LQ5mBKNXcPF6EFZmi +7XrlvopXkVPlRguTi2SLRPkY +-----END CERTIFICATE----- diff --git a/lib/inets/test/httpc_SUITE_data/ssl_server_cert.pem b/lib/inets/test/httpc_SUITE_data/ssl_server_cert.pem new file mode 100644 index 0000000000..f01b6c992b --- /dev/null +++ b/lib/inets/test/httpc_SUITE_data/ssl_server_cert.pem @@ -0,0 +1,22 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBOQIBAAJBAMe2WhP6s+JeKOwWPEjI9susfN4Vjn2dd1X4QUlOETcWVLoF916m +M4JU+ms7+ciMR8GRNCsIeqZGY8/GSqm74ccCAwEAAQJAF08YKlbLYfM9cXiS5qfV +7iWemUkIzW5wfC8yZ3zeE4Cp6R9ViUfs/dadQ/23Cw0Bpo2t8UdTUdCa4KpmqOem +cQIhAOnxTWZ5eo6h6PXDp7L5FZUACg8+wT3qf5f2is2mbSZPAiEA2orUY8JZDTSk +Rm7q9WxLiLNtORsXdTCmnCWhqBOYpwkCIErdowRxScxNekz0IT3AQqzdR1rbnWHg +IpcSGhd39CQ3AiA1XvQxjLP8wp9fyBS/bPwhXVhOOuyGpSP7PEF3b5m3KQIgGQWc +/a5wuWx3pc3mLx0ILwNoJr2ubFEuW1PJPsPJPv0= +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIB7jCCAZgCAQAwDQYJKoZIhvcNAQEEBQAwgYExCzAJBgNVBAYTAlNFMRIwEAYD +VQQHEwlTdG9ja2hvbG0xETAPBgNVBAoTCEVyaWNzc29uMQwwCgYDVQQLEwNFVFgx +FjAUBgNVBAMTDUhlbGVuIEFpcml5YW4xJTAjBgkqhkiG9w0BCQEWFmhlbGVuQGVy +aXguZXJpY3Nzb24uc2UwHhcNOTcwNzI4MDcyMTAwWhcNOTgxMjEwMDcyMTAwWjCB +gTELMAkGA1UEBhMCU0UxEjAQBgNVBAcTCVN0b2NraG9sbTERMA8GA1UEChMIRXJp +Y3Nzb24xDDAKBgNVBAsTA0VUWDEWMBQGA1UEAxMNSGVsZW4gQWlyaXlhbjElMCMG +CSqGSIb3DQEJARYWaGVsZW5AZXJpeC5lcmljc3Nvbi5zZTBcMA0GCSqGSIb3DQEB +AQUAA0sAMEgCQQDHtloT+rPiXijsFjxIyPbLrHzeFY59nXdV+EFJThE3FlS6Bfde +pjOCVPprO/nIjEfBkTQrCHqmRmPPxkqpu+HHAgMBAAEwDQYJKoZIhvcNAQEEBQAD +QQCnU1TkxmfbLdUwjdECb5x9QHCevAR7AmTms4Csn2oOEyPX+bgF2d94xhrV1sxO +Rs0yigk1PtN17Ci0Dey0LYkR +-----END CERTIFICATE----- diff --git a/lib/inets/test/httpc_cookie_SUITE.erl b/lib/inets/test/httpc_cookie_SUITE.erl new file mode 100644 index 0000000000..ad5df656c6 --- /dev/null +++ b/lib/inets/test/httpc_cookie_SUITE.erl @@ -0,0 +1,451 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(httpc_cookie_SUITE). + +-include("test_server.hrl"). +-include_lib("stdlib/include/ms_transform.hrl"). + +%% Test server specific exports +-export([all/1, init_per_testcase/2, end_per_testcase/2]). + +%% Test cases must be exported. +-export([session_cookies_only/1, netscape_cookies/1, + cookie_cancel/1, cookie_expires/1, persistent_cookie/1, + domain_cookie/1, secure_cookie/1, update_cookie/1, + update_cookie_session/1, cookie_attributes/1]). + +-define(URL, "http://myhost.cookie.test.org"). +-define(URL_DOMAIN, "http://myhost2.cookie.test.org"). +-define(URL_SECURE, "https://myhost.cookie.test.org"). + +%% Test server callback functions + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initiation before each test case +%%-------------------------------------------------------------------- +init_per_testcase(session_cookies_only = Case, Config0) -> + tsp("init_per_testcase(~p) -> entry with" + "~n Config0: ~p", [Case, Config0]), + Config = init_workdir(Case, Config0), + application:start(inets), + http:set_options([{cookies, verify}]), + watch_dog(Config); + +init_per_testcase(Case, Config0) -> + tsp("init_per_testcase(~p) -> entry with" + "~n Config0: ~p", [Case, Config0]), + Config = init_workdir(Case, Config0), + CaseDir = ?config(case_top_dir, Config), + application:load(inets), + application:set_env(inets, services, [{httpc, {default, CaseDir}}]), + application:start(inets), + http:set_options([{cookies, verify}]), + watch_dog(Config). + +watch_dog(Config) -> + Dog = test_server:timetrap(inets_test_lib:minutes(10)), + NewConfig = lists:keydelete(watchdog, 1, Config), + [{watchdog, Dog} | NewConfig]. + +init_workdir(Case, Config) -> + PrivDir = ?config(priv_dir, Config), + SuiteTopDir = filename:join(PrivDir, ?MODULE), + case file:make_dir(SuiteTopDir) of + ok -> + ok; + {error, eexist} -> + ok; + Error -> + tsf({failed_creating_subsuite_top_dir, Error}) + end, + + CaseTopDir = filename:join(SuiteTopDir, Case), + ?line ok = file:make_dir(CaseTopDir), + [{suite_top_dir, SuiteTopDir}, + {case_top_dir, CaseTopDir} | Config]. + + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + tsp("end_per_testcase(~p) -> entry with" + "~n Config: ~p", [Case, Config]), + application:stop(inets), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Describe the main purpose of this suite"]; + +all(suite) -> + [ + session_cookies_only, + netscape_cookies, + cookie_cancel, + cookie_expires, + persistent_cookie, + domain_cookie, + secure_cookie, + update_cookie, + update_cookie_session, + cookie_attributes + ]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- +session_cookies_only(doc) -> + ["Test that all cookies are handled as session cookies if there" + "does not exist a directory to save presitent cookies in."]; +session_cookies_only(suite) -> + []; +session_cookies_only(Config) when is_list(Config) -> + tsp("session_cookies_only -> Cookies 1: ~p", [httpc:which_cookies()]), + + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + ";max-age=60000"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + application:stop(inets), + application:start(inets), + {"cookie",""} = http:cookie_header(?URL), + + tsp("session_cookies_only -> Cookies 2: ~p", [httpc:which_cookies()]), + ok. + +netscape_cookies(doc) -> + ["Test that the old (original) format of cookies are accepted."]; +netscape_cookies(suite) -> + []; +netscape_cookies(Config) when is_list(Config) -> + tsp("netscape_cookies -> Cookies 1: ~p", [httpc:which_cookies()]), + + Expires = future_netscape_date(), + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/; " + "expires=" ++ Expires}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} = + http:cookie_header(?URL), + + tsp("netscape_cookies -> Cookies 2: ~p", [httpc:which_cookies()]), + ok. + +cookie_cancel(doc) -> + ["A cookie can be canceld by sending the same cookie with max-age=0 " + "this test cheks that cookie is canceled."]; +cookie_cancel(suite) -> + []; +cookie_cancel(Config) when is_list(Config) -> + tsp("cookie_cancel -> Cookies 1: ~p", [httpc:which_cookies()]), + + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=60000"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + NewSetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=0"}], + http:verify_cookies(NewSetCookieHeaders, ?URL), + {"cookie", ""} = http:cookie_header(?URL), + + tsp("cookie_cancel -> Cookies 2: ~p", [httpc:which_cookies()]), + ok. + +cookie_expires(doc) -> + ["Test that a cookie is not used when it has expired"]; +cookie_expires(suite) -> + []; +cookie_expires(Config) when is_list(Config) -> + tsp("cookie_expires -> Cookies 1: ~p", [httpc:which_cookies()]), + + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=5"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} + = http:cookie_header(?URL), + test_server:sleep(10000), + {"cookie", ""} = http:cookie_header(?URL), + + tsp("cookie_expires -> Cookies 2: ~p", [httpc:which_cookies()]), + ok. + +persistent_cookie(doc) -> + ["Test domian cookie attribute"]; +persistent_cookie(suite) -> + []; +persistent_cookie(Config) when is_list(Config)-> + tsp("persistent_cookie -> Cookies 1: ~p", [httpc:which_cookies()]), + + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=60000"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/"} = + http:cookie_header(?URL), + CaseDir = ?config(case_top_dir, Config), + application:stop(inets), + application:load(inets), + application:set_env(inets, services, [{httpc, {default, CaseDir}}]), + application:start(inets), + http:set_options([{cookies, enabled}]), + {"cookie","$Version=0; test_cookie=true; $Path=/"} = http:cookie_header(?URL), + + tsp("persistent_cookie -> Cookies 2: ~p", [httpc:which_cookies()]), + ok. + + +domain_cookie(doc) -> + ["Test the domian cookie attribute"]; +domain_cookie(suite) -> + []; +domain_cookie(Config) when is_list(Config) -> + tsp("domain_cookie -> Cookies 1: ~p", [httpc:which_cookies()]), + + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "domain=.cookie.test.org"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=0; test_cookie=true; $Path=/; " + "$Domain=.cookie.test.org"} = + http:cookie_header(?URL_DOMAIN), + + tsp("domain_cookie -> Cookies 2: ~p", [httpc:which_cookies()]), + ok. + + +secure_cookie(doc) -> + ["Test the secure cookie attribute"]; +secure_cookie(suite) -> + []; +secure_cookie(Config) when is_list(Config) -> + tsp("secure_cookie -> entry with" + "~n Config: ~p", [Config]), + + inets:enable_trace(max, io, httpc), + + %% httpc:reset_cookies(), + + tsp("secure_cookie -> Cookies 1: ~p", [httpc:which_cookies()]), + + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/; secure"}], + tsp("secure_cookie -> verify cookies (1)"), + ok = http:verify_cookies(SetCookieHeaders, ?URL), + + tsp("secure_cookie -> Cookies 2: ~p", [httpc:which_cookies()]), + + tsp("secure_cookie -> check cookie (secure)"), + check_cookie("$Version=0; test_cookie=true; $Path=/", ?URL_SECURE), + + tsp("secure_cookie -> check cookie (plain)"), + check_cookie("", ?URL), + + tsp("secure_cookie -> verify cookies (2)"), + SetCookieHeaders1 = [{"set-cookie", "test1_cookie=true; path=/; secure"}], + ok = http:verify_cookies(SetCookieHeaders1, ?URL), + + tsp("secure_cookie -> Cookies 3: ~p", [httpc:which_cookies()]), + + tsp("secure_cookie -> cookie header (3)"), + check_cookie("$Version=0; test_cookie=true; $Path=/; " + "test1_cookie=true; $Path=/", + ?URL_SECURE), +%% {"cookie","$Version=0; test_cookie=true; $Path=/; " +%% "test1_cookie=true; $Path=/"} = http:cookie_header(?URL_SECURE), + + tsp("secure_cookie -> Cookies 4: ~p", [httpc:which_cookies()]), + + inets:disable_trace(), + tsp("secure_cookie -> done"), + ok. + +update_cookie(doc)-> + ["Test that a cookie can be updated."]; +update_cookie(suite) -> + []; +update_cookie(Config) when is_list(Config)-> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/;" + "max-age=6500"}, + {"set-cookie", "test_cookie2=true; path=/;" + "max-age=6500"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie", "$Version=0; test_cookie2=true; $Path=/; " + "test_cookie=true; $Path=/"} = http:cookie_header(?URL), + NewSetCookieHeaders = [{"set-cookie", "test_cookie=false; " + "path=/;max-age=6500"}], + http:verify_cookies(NewSetCookieHeaders, ?URL), + {"cookie", "$Version=0; test_cookie2=true; $Path=/; " + "test_cookie=false; $Path=/"} = http:cookie_header(?URL). + +update_cookie_session(doc)-> + ["Test that a cookie can be updated."]; +update_cookie_session(suite) -> + []; +update_cookie_session(Config) when is_list(Config)-> + SetCookieHeaders = [{"set-cookie", "test_cookie=true; path=/"}, + {"set-cookie", "test_cookie2=true; path=/"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie", "$Version=0; test_cookie2=true; $Path=/; " + "test_cookie=true; $Path=/"} = http:cookie_header(?URL), + NewSetCookieHeaders = [{"set-cookie", "test_cookie=false; path=/"}], + http:verify_cookies(NewSetCookieHeaders, ?URL), + {"cookie", "$Version=0; test_cookie2=true; $Path=/; " + "test_cookie=false; $Path=/"} = http:cookie_header(?URL). + + +cookie_attributes(doc) -> + ["Test attribute not covered by the other test cases"]; +cookie_attributes(suite) -> + []; +cookie_attributes(Config) when is_list(Config) -> + SetCookieHeaders = [{"set-cookie", "test_cookie=true;version=1;" + "comment=foobar; "%% Comment + "foo=bar;" %% Nonsense should be ignored + "max-age=60000"}], + http:verify_cookies(SetCookieHeaders, ?URL), + {"cookie","$Version=1; test_cookie=true"} = http:cookie_header(?URL), + ok. + + +%%-------------------------------------------------------------------- +%%% Internal functions +%%-------------------------------------------------------------------- + +check_cookie(Expect, URL) -> + case http:cookie_header(URL) of + {"cookie", Expect} -> + ok; + {"cookie", Unexpected} -> + case lists:prefix(Expect, Unexpected) of + true -> + Extra = Unexpected -- Expect, + tsf({extra_cookie_info, Extra}); + false -> + tsf({unknown_cookie, Expect, Unexpected}) + end; + Bad -> + tsf({bad_cookies, Bad}) + end. + + +future_netscape_date() -> + [Day, DD, Mon, YYYY] = netscape_date(date()), + lists:flatten(io_lib:format("~s, ~s ~s ~s 12:30:00 GMT", + [Day, DD, Mon, YYYY])). + +netscape_date({Year, 12, _}) -> + NewYear = Year + 1, + NewMonth = 1, + NewDay = calendar:last_day_of_the_month(NewYear, NewMonth), + WeekDay = calendar:day_of_the_week(NewYear, NewMonth, NewDay), + WeekDayNrStr = day_nr_str(NewDay), + NewDayStr = week_day_str(WeekDay), + MonthStr = month_str(NewMonth), + [NewDayStr, WeekDayNrStr, MonthStr, integer_to_list(NewYear)]; + +netscape_date({Year, Month, _}) -> + NewMonth = Month + 1, + NewDay = calendar:last_day_of_the_month(Year, NewMonth), + WeekDay = calendar:day_of_the_week(Year, NewMonth, NewDay), + WeekDayNrStr = day_nr_str(NewDay), + NewDayStr = week_day_str(WeekDay), + MonthStr = month_str(NewMonth), + [NewDayStr, WeekDayNrStr, MonthStr, integer_to_list(Year)]. + +week_day_str(1) -> + "Mon"; +week_day_str(2) -> + "Tus"; +week_day_str(3) -> + "Wdy"; +week_day_str(4) -> + "Thu"; +week_day_str(5) -> + "Fri"; +week_day_str(6) -> + "Sat"; +week_day_str(7) -> + "Sun". + +day_nr_str(1) -> + "01"; +day_nr_str(2) -> + "02"; +day_nr_str(3) -> + "03"; +day_nr_str(4) -> + "04"; +day_nr_str(5) -> + "05"; +day_nr_str(6) -> + "06"; +day_nr_str(7) -> + "07"; +day_nr_str(8) -> + "08"; +day_nr_str(0) -> + "09"; +day_nr_str(N) -> + integer_to_list(N). + +month_str(1) ->"Jan"; +month_str(2) ->"Feb"; +month_str(3) ->"Mar"; +month_str(4) ->"Apr"; +month_str(5) ->"May"; +month_str(6) ->"Jun"; +month_str(7) ->"Jul"; +month_str(8) ->"Aug"; +month_str(9) ->"Sep"; +month_str(10) ->"Oct"; +month_str(11) ->"Nov"; +month_str(12) ->"Dec". + + +tsp(F) -> + tsp(F, []). +tsp(F, A) -> + test_server:format("~p ~p:" ++ F ++ "~n", [self(), ?MODULE | A]). + +tsf(Reason) -> + test_server:fail(Reason). + diff --git a/lib/inets/test/httpc_internal.hrl b/lib/inets/test/httpc_internal.hrl new file mode 120000 index 0000000000..bef2c94879 --- /dev/null +++ b/lib/inets/test/httpc_internal.hrl @@ -0,0 +1 @@ +../src/http_client/httpc_internal.hrl
\ No newline at end of file diff --git a/lib/inets/test/httpd_1_1.erl b/lib/inets/test/httpd_1_1.erl new file mode 100644 index 0000000000..055d034bec --- /dev/null +++ b/lib/inets/test/httpd_1_1.erl @@ -0,0 +1,494 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(httpd_1_1). +-author('[email protected]'). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include_lib("kernel/include/file.hrl"). + +-export([host/4, chunked/4, expect/4, range/4, if_test/5, http_trace/4, + head/4, mod_cgi_chunked_encoding_test/5]). + +%% -define(all_keys_lower_case,true). +-ifndef(all_keys_lower_case). +-define(CONTENT_LENGTH, "Content-Length: "). +-define(CONTENT_RANGE, "Content-Range: "). +-define(CONTENT_TYPE, "Content-Type: "). +-else. +-define(CONTENT_LENGTH, "content-length:"). +-define(CONTENT_RANGE, "content-range:"). +-define(CONTENT_TYPE, "content-type:"). +-endif. + + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +host(Type, Port, Host, Node) -> + %% No host needed for HTTP/1.0 + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + %% No host must generate an error + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\n\r\n", + [{statuscode, 400}]), + + %% If it is a fully qualified URL no host is needed + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET HTTP://"++ Host ++ ":" ++ + integer_to_list(Port)++ + "/ HTTP/1.1\r\n\r\n", + [{statuscode, 200}]), + + %% If both look at the url. + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET HTTP://"++ Host ++ ":"++ + integer_to_list(Port) ++ + "/ HTTP/1.1\r\nHost:"++ Host ++ + "\r\n\r\n",[{statuscode, 200}]), + + %% Allow the request if its a Host field + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:"++ + Host ++ "\r\n\r\n", + [{statuscode, 200}]), + ok. + +chunked(Type, Port, Host, Node)-> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\n" + "Host:"++ Host ++"\r\n" + "Transfer-Encoding:chunked\r\n" + "\r\n" + "A\r\n" + "1234567890\r\n" + "4\r\n" + "HEJ!\r\n" + "0\r\n\r\n", + [{statuscode, 200}]), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\n" + "Host:"++ Host ++"\r\n" + "Transfer-Encoding:chunked\r\n" + "Trailer:Content-Type\r\n" + "\r\n" + "A\r\n" + "1234567890\r\n" + "4\r\n" + "HEJ!\r\n" + "0\r\n" + "Content-Type:text/plain\r\n\r\n", + [{statuscode, 200}]), + ok. + +expect(Type, Port, Host, Node)-> + Request="GET / HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nContent-Length:22\r\nExpect:100-continue\r\n\r\n", + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + Request, + [{statuscode, 100}]). +range(Type, Port, Host, Node)-> + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /range.txt HTTP/1.1\r\nHost:" + ++ Host + ++ "\r\nRange:bytes=110-120\r\n\r\n", + [{statuscode,416}]), + %%The simples of all range request a range + Request1="GET /range.txt HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nRange:bytes=0-9\r\n\r\n", + {ok, Socket1} = inets_test_lib:connect_byte(Type, Host, Port), + inets_test_lib:send(Type, Socket1,Request1), + ok = validateRangeRequest(Socket1,[],"1234567890",$2,$0,$6), + inets_test_lib:close(Type,Socket1), + + %% Request the end of the file + Request2 = + "GET /range.txt HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nRange:bytes=90-\r\n\r\n", + + {ok, Socket2} = inets_test_lib:connect_byte(Type, Host, Port), + inets_test_lib:send(Type, Socket2, Request2), + ok = validateRangeRequest(Socket2,[],"1234567890",$2,$0,$6), + inets_test_lib:close(Type,Socket2), + + %% The last byte in the file + Request3 = + "GET /range.txt HTTP/1.1\r\nHost:"++ + Host ++ "\r\nRange:bytes=-1\r\n\r\n", + {ok, Socket3} = inets_test_lib:connect_byte(Type, Host, Port), + inets_test_lib:send(Type, Socket3,Request3), + ok = validateRangeRequest(Socket3,[],"0",$2,$0,$6), + inets_test_lib:close(Type, Socket3), + + %%Multi Range + Request4 = "GET /range.txt HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nRange:bytes=0-0,2-2,-1\r\n\r\n", + {ok, Socket4} = inets_test_lib:connect_byte(Type, Host, Port), + inets_test_lib:send(Type, Socket4, Request4), + ok = validateRangeRequest(Socket4,[],"130",$2,$0,$6), + inets_test_lib:close(Type, Socket4). + +if_test(Type, Port, Host, Node, DocRoot)-> + {ok, FileInfo} = + file:read_file_info(filename:join([DocRoot,"index.html"])), + CreatedSec = + calendar:datetime_to_gregorian_seconds(FileInfo#file_info.mtime), + + Mod = httpd_util:rfc1123_date(calendar:gregorian_seconds_to_datetime( + CreatedSec-1)), + + %% Test that we get the data when the file is modified + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" ++ Host ++ + "\r\nIf-Modified-Since:" ++ + Mod ++ "\r\n\r\n", + [{statuscode, 200}]), + Mod1 = httpd_util:rfc1123_date(calendar:gregorian_seconds_to_datetime( + CreatedSec+100)), + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++"\r\nIf-Modified-Since:" + ++ Mod1 ++"\r\n\r\n", + [{statuscode, 304}]), + + Mod2 = httpd_util:rfc1123_date(calendar:gregorian_seconds_to_datetime( + CreatedSec+1)), + %% Control that the If-Unmodified-Header lmits the response + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++ + "\r\nIf-Unmodified-Since:" ++ Mod2 + ++ "\r\n\r\n", + [{statuscode, 200}]), + Mod3 = httpd_util:rfc1123_date(calendar:gregorian_seconds_to_datetime( + CreatedSec-1)), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++ + "\r\nIf-Unmodified-Since:"++ Mod3 + ++"\r\n\r\n", + [{statuscode, 412}]), + + %% Control that we get the body when the etag match + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" ++ Host + ++"\r\n"++ + "If-Match:"++ + httpd_util:create_etag(FileInfo)++ + "\r\n\r\n", + [{statuscode, 200}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" ++ + Host ++ "\r\n"++ + "If-Match:NotEtag\r\n\r\n", + [{statuscode, 412}]), + + %% Control the response when the if-none-match header is there + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++"\r\n"++ + "If-None-Match:NoTaag," ++ + httpd_util:create_etag(FileInfo) ++ + "\r\n\r\n", + [{statuscode, 304}]), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.1\r\nHost:" + ++ Host ++ "\r\n"++ + "If-None-Match:NotEtag," + "NeihterEtag\r\n\r\n", + [{statuscode,200}]). + +http_trace(Type, Port, Host, Node)-> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "TRACE / HTTP/1.1\r\n" ++ + "Host:" ++ Host ++ "\r\n" ++ + "Max-Forwards:2\r\n\r\n", + [{statuscode, 200}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "TRACE / HTTP/1.0\r\n\r\n", + [{statuscode, 501}, + {version, "HTTP/1.0"}]). +head(Type, Port, Host, Node)-> + %% mod_include + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /fsize.shtml HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /fsize.shtml HTTP/1.1\r\nhost:" ++ + Host ++ "\r\n\r\n", [{statuscode, 200}]), + %% mod_esi + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /cgi-bin/erl/httpd_example/newformat" + " HTTP/1.0\r\n\r\n", [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /cgi-bin/erl/httpd_example/newformat " + "HTTP/1.1\r\nhost:" ++ Host ++ "\r\n\r\n", + [{statuscode, 200}]), + %% mod_cgi + Script = + case test_server:os_type() of + {win32, _} -> + "printenv.bat"; + _ -> + "printenv.sh" + end, + ok = httpd_test_lib:verify_request(Type,Host,Port,Node,"HEAD /cgi-bin/" + ++ Script ++ " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, "HEAD /cgi-bin/" + ++ Script ++ " HTTP/1.1\r\nhost:" ++ + Host ++ "\r\n\r\n", + [{statuscode, 200}]). + +mod_cgi_chunked_encoding_test(_, _, _, _, [])-> + ok; +mod_cgi_chunked_encoding_test(Type, Port, Host, Node, [Request| Rest])-> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, Request, + [{statuscode, 200}]), + mod_cgi_chunked_encoding_test(Type, Port, Host, Node, Rest). + +%%-------------------------------------------------------------------- +%% Internal functions +%%-------------------------------------------------------------------- +validateRangeRequest(Socket,Response,ValidBody,C,O,DE)-> + receive + {tcp,Socket,Data} -> + case string:str(Data,"\r\n") of + 0-> + validateRangeRequest(Socket, + Response ++ Data, + ValidBody, C, O, DE); + _N -> + case Response ++ Data of + [$H,$T,$T,$P,$/,$1,$.,$1,$ ,C,O,DE | _Rest]-> + case [C,O,DE] of + "206" -> + validateRangeRequest1(Socket, + Response ++ Data, + ValidBody); + _ -> + bad_code + end; + _-> + error + end + end; + _Error -> + error + end. + +validateRangeRequest1(Socket, Response, ValidBody) -> + case end_of_header(Response) of + false -> + receive + {tcp,Socket,Data} -> + validateRangeRequest1(Socket, Response ++ Data, + ValidBody); + _-> + error + end; + {true, Head1, Body, _Size} -> + %% In this case size will be 0 if it is a multipart so + %% don't use it. + validateRangeRequest2(Socket, Head1, Body, ValidBody, + getRangeSize(Head1)) + end. + +validateRangeRequest2(Socket, Head, Body, ValidBody, {multiPart,Boundary})-> + case endReached(Body,Boundary) of + true -> + validateMultiPartRangeRequest(Body, ValidBody, Boundary); + false-> + receive + {tcp, Socket, Data} -> + validateRangeRequest2(Socket, Head, Body ++ Data, + ValidBody, {multiPart, Boundary}); + {tcp_closed, Socket} -> + error; + _ -> + error + end + end; + +validateRangeRequest2(Socket, Head, Body, ValidBody, BodySize) + when is_integer(BodySize) -> + case length(Body) of + Size when Size =:= BodySize -> + case Body of + ValidBody -> + ok; + Body -> + error + end; + Size when Size < BodySize -> + receive + {tcp, Socket, Data} -> + validateRangeRequest2(Socket, Head, + Body ++ Data, ValidBody, BodySize); + _ -> + error + end; + _ -> + error + end. + + +validateMultiPartRangeRequest(Body, ValidBody, Boundary)-> + case inets_regexp:split(Body,"--"++Boundary++"--") of + %%Last is the epilogue and must be ignored + {ok,[First | _Last]}-> + %%First is now the actuall http request body. + case inets_regexp:split(First, "--" ++ Boundary) of + %%Parts is now a list of ranges and the heads for each range + %%Gues we try to split out the body + {ok,Parts}-> + case lists:flatten(lists:map(fun splitRange/1,Parts)) of + ValidBody-> + ok; + ParsedBody-> + error = ParsedBody + end + end; + _ -> + error + end. + + +splitRange(Part)-> + case inets_regexp:split(Part, "\r\n\r\n") of + {ok,[_, Body]} -> + string:substr(Body, 1, length(Body) - 2); + _ -> + [] + end. + +endReached(Body, Boundary)-> + EndBound = "--" ++ Boundary ++ "--", + case string:str(Body, EndBound) of + 0 -> + false; + _ -> + true + end. + +getRangeSize(Head)-> + case controlMimeType(Head) of + {multiPart, BoundaryString}-> + {multiPart, BoundaryString}; + _X1 -> + case inets_regexp:match(Head, ?CONTENT_RANGE "bytes=.*\r\n") of + {match, Start, Lenght} -> + %% Get the range data remove the fieldname and the + %% end of line. + RangeInfo = string:substr(Head, Start + 20, + Lenght - (20 - 2)), + rangeSize(RangeInfo); + _X2 -> + error + end + end. +%%RangeInfo is NNN1-NNN2/NNN3 +%%NNN1=RangeStartByte +%%NNN2=RangeEndByte +%%NNN3=total amount of bytes in file +rangeSize([$=|RangeInfo]) -> + rangeSize(RangeInfo); +rangeSize(RangeInfo) -> + StartByte = lists:takewhile(fun(X)-> + num(X, true) + end, RangeInfo), + RangeInfo2 = string:substr(RangeInfo, length(StartByte) + 2), + EndByte = lists:takewhile(fun(X)-> + num(X,true) + end, RangeInfo2), + case list_to_integer(EndByte) - list_to_integer(StartByte) of + Val when is_number(Val) -> + %%Add one since it is startByte to endbyte ie 0-0 is 1 + %%byte 0-99 is 100 bytes + Val + 1; + _Val -> + error + end. + +num(CharVal, RetVal) when (CharVal >= 48) andalso (CharVal =< 57) -> + RetVal; +num(_CharVal, true) -> + false; +num(_CharVal, false) -> + true. + +controlMimeType(Head)-> + case inets_regexp:match(Head,?CONTENT_TYPE "multipart/byteranges.*\r\n") of + {match,Start,Length}-> + FieldNameLen = length(?CONTENT_TYPE "multipart/byteranges"), + case clearBoundary(string:substr(Head, Start + FieldNameLen, + Length - (FieldNameLen+2))) of + error -> + error; + BoundaryStr -> + {multiPart,BoundaryStr} + end; + nomatch-> + 0; + _ -> + error + end. + +clearBoundary(Boundary)-> + case inets_regexp:match(Boundary, "boundary=.*\$") of + {match, Start1, Length1}-> + BoundLen = length("boundary="), + string:substr(Boundary, Start1 + BoundLen, Length1 - BoundLen); + _ -> + error + end. + + +end_of_header(HeaderPart) -> + case httpd_util:split(HeaderPart,"\r\n\r\n",2) of + {ok, [Head, Body]} -> + {true, Head, Body, get_body_size(Head)}; + _Pos -> + false + end. + +get_body_size(Head) -> + case inets_regexp:match(Head,?CONTENT_LENGTH ".*\r\n") of + {match, Start, Length} -> + %% 15 is length of Content-Length, + %% 17 Is length of Content-Length and \r\ + S = list_to_integer( + string:strip(string:substr(Head, Start + 15, Length-17))), + S; + _-> + 0 + end. diff --git a/lib/inets/test/httpd_SUITE.erl b/lib/inets/test/httpd_SUITE.erl new file mode 100644 index 0000000000..7403d4a643 --- /dev/null +++ b/lib/inets/test/httpd_SUITE.erl @@ -0,0 +1,2081 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(httpd_SUITE). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include("inets_test_lib.hrl"). + +-include_lib("kernel/include/file.hrl"). + +%% Test server specific exports +-export([all/1]). +-export([init_per_testcase/2, end_per_testcase/2, + init_per_suite/1, end_per_suite/1]). + +%% Test cases must be exported. +-export([ip/1, ssl/1, http_1_1_ip/1, http_1_0_ip/1, http_0_9_ip/1, + ipv6/1, tickets/1]). + +%% Core Server tests +-export([ip_mod_alias/1, ip_mod_actions/1, ip_mod_security/1, ip_mod_auth/1, + ip_mod_auth_api/1, ip_mod_auth_mnesia_api/1, + ip_mod_htaccess/1, ip_mod_cgi/1, ip_mod_esi/1, + ip_mod_get/1, ip_mod_head/1, ip_mod_all/1, ip_load_light/1, + ip_load_medium/1, ip_load_heavy/1, ip_dos_hostname/1, + ip_time_test/1, ip_block_disturbing_idle/1, + ip_block_non_disturbing_idle/1, ip_block_503/1, + ip_block_disturbing_active/1, ip_block_non_disturbing_active/1, + ip_block_disturbing_active_timeout_not_released/1, + ip_block_disturbing_active_timeout_released/1, + ip_block_non_disturbing_active_timeout_not_released/1, + ip_block_non_disturbing_active_timeout_released/1, + ip_block_disturbing_blocker_dies/1, + ip_block_non_disturbing_blocker_dies/1, + ip_restart_no_block/1, ip_restart_disturbing_block/1, + ip_restart_non_disturbing_block/1 + ]). + +-export([ssl_mod_alias/1, ssl_mod_actions/1, ssl_mod_security/1, + ssl_mod_auth/1, ssl_mod_auth_api/1, + ssl_mod_auth_mnesia_api/1, ssl_mod_htaccess/1, + ssl_mod_cgi/1, ssl_mod_esi/1, ssl_mod_get/1, ssl_mod_head/1, + ssl_mod_all/1, ssl_load_light/1, ssl_load_medium/1, + ssl_load_heavy/1, ssl_dos_hostname/1, ssl_time_test/1, + ssl_restart_no_block/1, ssl_restart_disturbing_block/1, + ssl_restart_non_disturbing_block/1, ssl_block_disturbing_idle/1, + ssl_block_non_disturbing_idle/1, ssl_block_503/1, + ssl_block_disturbing_active/1, ssl_block_non_disturbing_active/1, + ssl_block_disturbing_active_timeout_not_released/1, + ssl_block_disturbing_active_timeout_released/1, + ssl_block_non_disturbing_active_timeout_not_released/1, + ssl_block_non_disturbing_active_timeout_released/1, + ssl_block_disturbing_blocker_dies/1, + ssl_block_non_disturbing_blocker_dies/1]). + +%%% HTTP 1.1 tests +-export([ip_host/1, ip_chunked/1, ip_expect/1, ip_range/1, + ip_if_test/1, ip_http_trace/1, ip_http1_1_head/1, + ip_mod_cgi_chunked_encoding_test/1]). + +%%% HTTP 1.0 tests +-export([ip_head_1_0/1, ip_get_1_0/1, ip_post_1_0/1]). + +%%% HTTP 0.9 tests +-export([ip_get_0_9/1]). + +%%% Ticket tests +-export([ticket_5775/1,ticket_5865/1,ticket_5913/1,ticket_6003/1, + ticket_7304/1]). + +%%% Misc +-export([ipv6_hostname/1, ipv6_address/1]). + +%% Help functions +-export([cleanup_mnesia/0, setup_mnesia/0, setup_mnesia/1]). + +-define(IP_PORT, 8898). +-define(SSL_PORT, 8899). +-define(MAX_HEADER_SIZE, 256). +-define(IPV6_LOCAL_HOST, "0:0:0:0:0:0:0:1"). + +%% Minutes before failed auths timeout. +-define(FAIL_EXPIRE_TIME,1). + +%% Seconds before successful auths timeout. +-define(AUTH_TIMEOUT,5). + +-record(httpd_user, {user_name, password, user_data}). +-record(httpd_group,{group_name, userlist}). + + +%%-------------------------------------------------------------------- +%% all(Arg) -> [Doc] | [Case] | {skip, Comment} +%% Arg - doc | suite +%% Doc - string() +%% Case - atom() +%% Name of a test case function. +%% Comment - string() +%% Description: Returns documentation/test cases in this test suite +%% or a skip tuple if the platform is not supported. +%%-------------------------------------------------------------------- +all(doc) -> + ["Test the http server in the intes application."]; +all(suite) -> + [ + ip, + ssl, + http_1_1_ip, + http_1_0_ip, + http_0_9_ip, + %% ipv6, + tickets + ]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + io:format(user, "init_per_suite -> entry with" + "~n Config: ~p" + "~n", [Config]), + + PrivDir = ?config(priv_dir, Config), + SuiteTopDir = filename:join(PrivDir, ?MODULE), + case file:make_dir(SuiteTopDir) of + ok -> + ok; + {error, eexist} -> + ok; + Error -> + throw({error, {failed_creating_suite_top_dir, Error}}) + end, + + [{suite_top_dir, SuiteTopDir}, + {node, node()}, + {host, inets_test_lib:hostname()}, + {address, getaddr()} | Config]. + + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- + +end_per_suite(_Config) -> + %% SuiteTopDir = ?config(suite_top_dir, Config), + %% inets_test_lib:del_dirs(SuiteTopDir), + ok. + + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(Case, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_testcase(Case, Config) -> + NewConfig = init_per_testcase2(Case, Config), + init_per_testcase3(Case, NewConfig). + + +init_per_testcase2(Case, Config) -> + + io:format(user, "~w:init_per_testcase2(~w) -> entry with" + "~n Config: ~p" + "~n", [?MODULE, Case, Config]), + + IpNormal = integer_to_list(?IP_PORT) ++ ".conf", + IpHtacess = integer_to_list(?IP_PORT) ++ "htacess.conf", + SslNormal = integer_to_list(?SSL_PORT) ++ ".conf", + SslHtacess = integer_to_list(?SSL_PORT) ++ "htacess.conf", + + DataDir = ?config(data_dir, Config), + SuiteTopDir = ?config(suite_top_dir, Config), + + io:format(user, "~w:init_per_testcase2(~w) -> " + "~n SuiteDir: ~p" + "~n DataDir: ~p" + "~n", [?MODULE, Case, SuiteTopDir, DataDir]), + + TcTopDir = filename:join(SuiteTopDir, Case), + ?line ok = file:make_dir(TcTopDir), + + io:format(user, "~w:init_per_testcase2(~w) -> " + "~n TcTopDir: ~p" + "~n", [?MODULE, Case, TcTopDir]), + + DataSrc = filename:join([DataDir, "server_root"]), + ServerRoot = filename:join([TcTopDir, "server_root"]), + + io:format(user, "~w:init_per_testcase2(~w) -> " + "~n DataSrc: ~p" + "~n ServerRoot: ~p" + "~n", [?MODULE, Case, DataSrc, ServerRoot]), + + ok = file:make_dir(ServerRoot), + ok = file:make_dir(filename:join([TcTopDir, "logs"])), + + NewConfig = [{tc_top_dir, TcTopDir}, {server_root, ServerRoot} | Config], + + io:format(user, "~w:init_per_testcase2(~w) -> " + "copy DataSrc to ServerRoot~n", + [?MODULE, Case]), + + inets_test_lib:copy_dirs(DataSrc, ServerRoot), + + io:format(user, "~w:init_per_testcase2(~w) -> fix cgi~n", + [?MODULE, Case]), + EnvCGI = filename:join([ServerRoot, "cgi-bin", "printenv.sh"]), + {ok, FileInfo} = file:read_file_info(EnvCGI), + ok = file:write_file_info(EnvCGI, + FileInfo#file_info{mode = 8#00755}), + + EchoCGI = case test_server:os_type() of + {win32, _} -> + "cgi_echo.exe"; + _ -> + "cgi_echo" + end, + CGIDir = filename:join([ServerRoot, "cgi-bin"]), + inets_test_lib:copy_file(EchoCGI, DataDir, CGIDir), + NewEchoCGI = filename:join([CGIDir, EchoCGI]), + {ok, FileInfo1} = file:read_file_info(NewEchoCGI), + ok = file:write_file_info(NewEchoCGI, + FileInfo1#file_info{mode = 8#00755}), + + %% To be used by IP test cases + io:format(user, "~w:init_per_testcase2(~w) -> ip testcase setups~n", + [?MODULE, Case]), + create_config([{port, ?IP_PORT}, {sock_type, ip_comm} | NewConfig], + normal_acess, IpNormal), + create_config([{port, ?IP_PORT}, {sock_type, ip_comm} | NewConfig], + mod_htaccess, IpHtacess), + + %% To be used by SSL test cases + io:format(user, "~w:init_per_testcase2(~w) -> ssl testcase setups~n", + [?MODULE, Case]), + create_config([{port, ?SSL_PORT}, {sock_type, ssl} | NewConfig], + normal_acess, SslNormal), + create_config([{port, ?SSL_PORT}, {sock_type, ssl} | NewConfig], + mod_htaccess, SslHtacess), + + %% To be used by IPv6 test cases. Case-clause is so that + %% you can do ts:run(inets, httpd_SUITE, <test case>) + %% for all cases except the ipv6 cases as they depend + %% on 'test_host_ipv6_only' that will only be present + %% when you run the whole test suite due to shortcomings + %% of the test server. + %% case (catch ?config(test_host_ipv6_only, Config)) of + %% {_,IPv6Host,IPv6Adress,_,_} -> + %% create_ipv6_config([{port, ?IP_PORT}, + %% {sock_type, ip_comm} | NewConfig], + %% "ipv6_hostname.conf", IPv6Host), + %% create_ipv6_config([{port, ?IP_PORT}, + %% {sock_type, ip_comm} | NewConfig], + %% "ipv6_address.conf", IPv6Adress); + %% _ -> + %% ok + %% end, + + io:format(user, "~w:init_per_testcase2(~w) -> done~n", + [?MODULE, Case]), + + NewConfig. + + +init_per_testcase3(Case, Config) -> + io:format(user, "~w:init_per_testcase3(~w) -> entry with" + "~n Config: ~p", [?MODULE, Case, Config]), + + %% Clean up (we do not want this clean up in end_per_testcase + %% if init_per_testcase crases for some testcase it will + %% have contaminated the environment and there will be no clean up.) + %% This init can take a few different paths so that one crashes + %% does not mean that all invocations will. + + application:unset_env(inets, services), + application:stop(inets), + application:stop(ssl), + cleanup_mnesia(), + + %% TraceLevel = max, + TraceLevel = 70, + TraceDest = io, + inets:enable_trace(TraceLevel, TraceDest), + + %% Start initialization + io:format(user, "~w:init_per_testcase3(~w) -> start init", + [?MODULE, Case]), + + Dog = test_server:timetrap(inets_test_lib:minutes(10)), + NewConfig = lists:keydelete(watchdog, 1, Config), + TcTopDir = ?config(tc_top_dir, Config), + CaseRest = + case atom_to_list(Case) of + "ip_mod_htaccess" -> + inets_test_lib:start_http_server( + filename:join(TcTopDir, + integer_to_list(?IP_PORT) ++ + "htacess.conf")), + "mod_htaccess"; + "ip_" ++ Rest -> + inets_test_lib:start_http_server( + filename:join(TcTopDir, + integer_to_list(?IP_PORT) ++ ".conf")), + Rest; + "ticket_5913" -> + HttpdOptions = + [{file, + filename:join(TcTopDir, + integer_to_list(?IP_PORT) ++ ".conf")}, + {accept_timeout,30000}, + {debug,[{exported_functions, + [httpd_manager,httpd_request_handler]}]}], + inets_test_lib:start_http_server(HttpdOptions); + "ticket_"++Rest -> + %% OTP-5913 use the new syntax of inets.config + inets_test_lib:start_http_server([{file, + filename:join(TcTopDir, + integer_to_list(?IP_PORT) ++ ".conf")}]), + Rest; + "ssl_mod_htaccess" -> + case inets_test_lib:start_http_server_ssl( + filename:join(TcTopDir, + integer_to_list(?SSL_PORT) ++ + "htacess.conf")) of + ok -> + "mod_htaccess"; + Other -> + error_logger:info_report("Other: ~p~n", [Other]), + {skip, "SSL does not seem to be supported"} + end; + "ssl_" ++ Rest -> + case inets_test_lib:start_http_server_ssl( + filename:join(TcTopDir, + integer_to_list(?SSL_PORT) ++ + ".conf")) of + ok -> + Rest; + Other -> + error_logger:info_report("Other: ~p~n", [Other]), + {skip, "SSL does not seem to be supported"} + end; + "ipv6_" ++ _ = TestCaseStr -> + {ok, Hostname} = inet:gethostname(), + + case lists:member(list_to_atom(Hostname), + ?config(ipv6_hosts, Config)) of + true -> + inets_test_lib:start_http_server( + filename:join(TcTopDir, + TestCaseStr ++ ".conf")); + + false -> + {skip, "Host does not support IPv6"} + end + end, + + case CaseRest of + {skip, _} = Skip -> + Skip; + "mod_auth_" ++ _ -> + start_mnesia(?config(node, Config)), + [{watchdog, Dog} | NewConfig]; + "mod_htaccess" -> + ServerRoot = ?config(server_root, Config), + Path = filename:join([ServerRoot, "htdocs"]), + catch remove_htacess(Path), + create_htacess_data(Path, ?config(address, Config)), + [{watchdog, Dog} | NewConfig]; + "range" -> + ServerRoot = ?config(server_root, Config), + Path = filename:join([ServerRoot, "htdocs"]), + create_range_data(Path), + [{watchdog, Dog} | NewConfig]; + _ -> + [{watchdog, Dog} | NewConfig] + end. + + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(Case, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + end_per_testcase2(Case, lists:keydelete(watchdog, 1, Config)), + ok. + +end_per_testcase2(Case, Config) -> + io:format(user, "~w:end_per_testcase2(~w) -> entry with" + "~n Config: ~p~n", + [?MODULE, Case, Config]), + application:unset_env(inets, services), + application:stop(inets), + application:stop(ssl), + cleanup_mnesia(), + io:format(user, "~w:end_per_testcase2(~w) -> done~n", + [?MODULE, Case]), + ok. + + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +ip(doc) -> + ["HTTP tests using TCP/IP"]; +ip(suite) -> + [ + ip_mod_alias, + ip_mod_actions, + ip_mod_security, + ip_mod_auth, + ip_mod_auth_api, + ip_mod_auth_mnesia_api, + ip_mod_htaccess, + ip_mod_cgi, + ip_mod_esi, + ip_mod_get, + ip_mod_head, + ip_mod_all, + ip_load_light, + ip_load_medium, + ip_load_heavy, + ip_dos_hostname, + ip_time_test, + ip_block_disturbing_idle, + ip_block_non_disturbing_idle, + ip_block_503, + ip_block_disturbing_active, + ip_block_non_disturbing_active, + ip_block_disturbing_active_timeout_not_released, + ip_block_disturbing_active_timeout_released, + ip_block_non_disturbing_active_timeout_not_released, + ip_block_non_disturbing_active_timeout_released, + ip_block_disturbing_blocker_dies, + ip_block_non_disturbing_blocker_dies, + ip_restart_no_block, + ip_restart_disturbing_block, + ip_restart_non_disturbing_block + ]. + +%%------------------------------------------------------------------------- +ssl(doc) -> + ["HTTP test using SSL"]; +ssl(suite) -> + [ + ssl_mod_alias, + ssl_mod_actions, + ssl_mod_security, + ssl_mod_auth, + ssl_mod_auth_api, + ssl_mod_auth_mnesia_api, + ssl_mod_htaccess, + ssl_mod_cgi, + ssl_mod_esi, + ssl_mod_get, + ssl_mod_head, + ssl_mod_all, + ssl_load_light, + ssl_load_medium, + ssl_load_heavy, + ssl_dos_hostname, + ssl_time_test, + ssl_restart_no_block, + ssl_restart_disturbing_block, + ssl_restart_non_disturbing_block, + ssl_block_disturbing_idle, + ssl_block_non_disturbing_idle, + ssl_block_503, + ssl_block_disturbing_active, + ssl_block_non_disturbing_active, + ssl_block_disturbing_active_timeout_not_released, + ssl_block_disturbing_active_timeout_released, + ssl_block_non_disturbing_active_timeout_not_released, + ssl_block_non_disturbing_active_timeout_released, + ssl_block_disturbing_blocker_dies, + ssl_block_non_disturbing_blocker_dies + ]. + +%%------------------------------------------------------------------------- +http_1_1_ip(doc) -> + ["HTTP/1.1"]; +http_1_1_ip(suite) -> + [ + ip_host, + ip_chunked, + ip_expect, + ip_range, + ip_if_test, + ip_http_trace, + ip_http1_1_head, + ip_mod_cgi_chunked_encoding_test + ]. + +%%------------------------------------------------------------------------- +http_1_0_ip(doc) -> + ["HTTP/1.0"]; +http_1_0_ip(suite) -> + [ + ip_head_1_0, + ip_get_1_0, + ip_post_1_0 + ]. + +%%------------------------------------------------------------------------- +http_0_9_ip(doc) -> + ["HTTP/0.9"]; +http_0_9_ip(suite) -> + [ + ip_get_0_9 + ]. + +%%------------------------------------------------------------------------- +ipv6(doc) -> + ["Tests ipv6 functionality."]; +ipv6(suite) -> + [ + ipv6_hostname, + ipv6_address + ]. + +%%------------------------------------------------------------------------- +tickets(doc) -> + ["Test cases for reported bugs."]; +tickets(suite) -> + [ + ticket_5775, + ticket_5865, + ticket_5913, + ticket_6003, + ticket_7304 + ]. + +%%------------------------------------------------------------------------- +ip_mod_alias(doc) -> + ["Module test: mod_alias"]; +ip_mod_alias(suite) -> + []; +ip_mod_alias(Config) when is_list(Config) -> + httpd_mod:alias(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_mod_actions(doc) -> + ["Module test: mod_actions"]; +ip_mod_actions(suite) -> + []; +ip_mod_actions(Config) when is_list(Config) -> + httpd_mod:actions(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_mod_security(doc) -> + ["Module test: mod_security"]; +ip_mod_security(suite) -> + []; +ip_mod_security(Config) when is_list(Config) -> + ServerRoot = ?config(server_root, Config), + httpd_mod:security(ServerRoot, ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ip_mod_auth(doc) -> + ["Module test: mod_auth"]; +ip_mod_auth(suite) -> + []; +ip_mod_auth(Config) when is_list(Config) -> + httpd_mod:auth(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ip_mod_auth_api(doc) -> + ["Module test: mod_auth_api"]; +ip_mod_auth_api(suite) -> + []; +ip_mod_auth_api(Config) when is_list(Config) -> + ServerRoot = ?config(server_root, Config), + Host = ?config(host, Config), + Node = ?config(node, Config), + httpd_mod:auth_api(ServerRoot, "", ip_comm, ?IP_PORT, Host, Node), + httpd_mod:auth_api(ServerRoot, "dets_", ip_comm, ?IP_PORT, Host, Node), + httpd_mod:auth_api(ServerRoot, "mnesia_", ip_comm, ?IP_PORT, Host, Node), + ok. +%%------------------------------------------------------------------------- +ip_mod_auth_mnesia_api(doc) -> + ["Module test: mod_auth_mnesia_api"]; +ip_mod_auth_mnesia_api(suite) -> + []; +ip_mod_auth_mnesia_api(Config) when is_list(Config) -> + httpd_mod:auth_mnesia_api(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_mod_htaccess(doc) -> + ["Module test: mod_htaccess"]; +ip_mod_htaccess(suite) -> + []; +ip_mod_htaccess(Config) when is_list(Config) -> + httpd_mod:htaccess(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_mod_cgi(doc) -> + ["Module test: mod_cgi"]; +ip_mod_cgi(suite) -> + []; +ip_mod_cgi(Config) when is_list(Config) -> + case test_server:os_type() of + vxworks -> + {skip, cgi_not_supported_on_vxwoks}; + _ -> + httpd_mod:cgi(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok + end. +%%------------------------------------------------------------------------- +ip_mod_esi(doc) -> + ["Module test: mod_esi"]; +ip_mod_esi(suite) -> + []; +ip_mod_esi(Config) when is_list(Config) -> + httpd_mod:esi(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ip_mod_get(doc) -> + ["Module test: mod_get"]; +ip_mod_get(suite) -> + []; +ip_mod_get(Config) when is_list(Config) -> + httpd_mod:get(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ip_mod_head(doc) -> + ["Module test: mod_head"]; +ip_mod_head(suite) -> + []; +ip_mod_head(Config) when is_list(Config) -> + httpd_mod:head(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_mod_all(doc) -> + ["All modules test"]; +ip_mod_all(suite) -> + []; +ip_mod_all(Config) when is_list(Config) -> + httpd_mod:all(ip_comm, ?IP_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_load_light(doc) -> + ["Test light load"]; +ip_load_light(suite) -> + []; +ip_load_light(Config) when is_list(Config) -> + httpd_load:load_test(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config), + get_nof_clients(ip_comm, light)), + ok. +%%------------------------------------------------------------------------- +ip_load_medium(doc) -> + ["Test medium load"]; +ip_load_medium(suite) -> + []; +ip_load_medium(Config) when is_list(Config) -> + httpd_load:load_test(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config), + get_nof_clients(ip_comm, medium)), + ok. +%%------------------------------------------------------------------------- +ip_load_heavy(doc) -> + ["Test heavy load"]; +ip_load_heavy(suite) -> + []; +ip_load_heavy(Config) when is_list(Config) -> + httpd_load:load_test(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config), + get_nof_clients(ip_comm, heavy)), + ok. +%%------------------------------------------------------------------------- +ip_dos_hostname(doc) -> + ["Denial Of Service (DOS) attack test case"]; +ip_dos_hostname(suite) -> + []; +ip_dos_hostname(Config) when is_list(Config) -> + dos_hostname(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config), ?MAX_HEADER_SIZE), + ok. +%%------------------------------------------------------------------------- +ip_time_test(doc) -> + [""]; +ip_time_test(suite) -> + []; +ip_time_test(Config) when is_list(Config) -> + %% <CONDITIONAL-SKIP> + Skippable = [win32], + Condition = fun() -> ?OS_BASED_SKIP(Skippable) end, + ?NON_PC_TC_MAYBE_SKIP(Config, Condition), + %% </CONDITIONAL-SKIP> + + httpd_time_test:t(ip_comm, ?config(host, Config), ?IP_PORT), + ok. + +%%------------------------------------------------------------------------- +ip_block_503(doc) -> + ["Check that you will receive status code 503 when the server" + " is blocked and 200 when its not blocked."]; +ip_block_503(suite) -> + []; +ip_block_503(Config) when is_list(Config) -> + httpd_block:block_503(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_block_disturbing_idle(doc) -> + ["Check that you can block/unblock an idle server. The strategy " + "distribing does not really make a difference in this case."]; +ip_block_disturbing_idle(suite) -> + []; +ip_block_disturbing_idle(Config) when is_list(Config) -> + httpd_block:block_disturbing_idle(ip_comm, ?IP_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_block_non_disturbing_idle(doc) -> + ["Check that you can block/unblock an idle server. The strategy " + "non distribing does not really make a difference in this case."]; +ip_block_non_disturbing_idle(suite) -> + []; +ip_block_non_disturbing_idle(Config) when is_list(Config) -> + httpd_block:block_non_disturbing_idle(ip_comm, ?IP_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_block_disturbing_active(doc) -> + ["Check that you can block/unblock an active server. The strategy " + "distribing means ongoing requests should be terminated."]; +ip_block_disturbing_active(suite) -> + []; +ip_block_disturbing_active(Config) when is_list(Config) -> + httpd_block:block_disturbing_active(ip_comm, ?IP_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_block_non_disturbing_active(doc) -> + ["Check that you can block/unblock an idle server. The strategy " + "non distribing means the ongoing requests should be compleated."]; +ip_block_non_disturbing_active(suite) -> + []; +ip_block_non_disturbing_active(Config) when is_list(Config) -> + httpd_block:block_non_disturbing_idle(ip_comm, ?IP_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ip_block_disturbing_active_timeout_not_released(doc) -> + ["Check that you can block an active server. The strategy " + "distribing means ongoing requests should be compleated" + "if the timeout does not occur."]; +ip_block_disturbing_active_timeout_not_released(suite) -> + []; +ip_block_disturbing_active_timeout_not_released(Config) + when is_list(Config) -> + httpd_block:block_disturbing_active_timeout_not_released(ip_comm, + ?IP_PORT, + ?config(host, + Config), + ?config(node, + Config)), + ok. +%%------------------------------------------------------------------------- +ip_block_disturbing_active_timeout_released(doc) -> + ["Check that you can block an active server. The strategy " + "distribing means ongoing requests should be terminated when" + "the timeout occurs."]; +ip_block_disturbing_active_timeout_released(suite) -> + []; +ip_block_disturbing_active_timeout_released(Config) + when is_list(Config) -> + httpd_block:block_disturbing_active_timeout_released(ip_comm, + ?IP_PORT, + ?config(host, + Config), + ?config(node, + Config)), + ok. + +%%------------------------------------------------------------------------- +ip_block_non_disturbing_active_timeout_not_released(doc) -> + ["Check that you can block an active server. The strategy " + "non non distribing means ongoing requests should be completed."]; +ip_block_non_disturbing_active_timeout_not_released(suite) -> + []; +ip_block_non_disturbing_active_timeout_not_released(Config) + when is_list(Config) -> + httpd_block: + block_non_disturbing_active_timeout_not_released(ip_comm, + ?IP_PORT, + ?config(host, + Config), + ?config(node, + Config)), + ok. +%%------------------------------------------------------------------------- +ip_block_non_disturbing_active_timeout_released(doc) -> + ["Check that you can block an active server. The strategy " + "non non distribing means ongoing requests should be completed. " + "When the timeout occurs the block operation sohould be canceled." ]; +ip_block_non_disturbing_active_timeout_released(suite) -> + []; +ip_block_non_disturbing_active_timeout_released(Config) + when is_list(Config) -> + httpd_block: + block_non_disturbing_active_timeout_released(ip_comm, + ?IP_PORT, + ?config(host, + Config), + ?config(node, + Config)), + ok. +%%------------------------------------------------------------------------- +ip_block_disturbing_blocker_dies(doc) -> + []; +ip_block_disturbing_blocker_dies(suite) -> + []; +ip_block_disturbing_blocker_dies(Config) when is_list(Config) -> + httpd_block:disturbing_blocker_dies(ip_comm, ?IP_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_block_non_disturbing_blocker_dies(doc) -> + []; +ip_block_non_disturbing_blocker_dies(suite) -> + []; +ip_block_non_disturbing_blocker_dies(Config) when is_list(Config) -> + httpd_block:non_disturbing_blocker_dies(ip_comm, ?IP_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_restart_no_block(doc) -> + [""]; +ip_restart_no_block(suite) -> + []; +ip_restart_no_block(Config) when is_list(Config) -> + httpd_block:restart_no_block(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_restart_disturbing_block(doc) -> + [""]; +ip_restart_disturbing_block(suite) -> + []; +ip_restart_disturbing_block(Config) when is_list(Config) -> + %% <CONDITIONAL-SKIP> + Condition = + fun() -> + case os:type() of + {unix, linux} -> + HW = string:strip(os:cmd("uname -m"), right, $\n), + case HW of + "ppc" -> + case inet:gethostname() of + {ok, "peach"} -> + true; + _ -> + false + end; + _ -> + false + end; + _ -> + false + end + end, + ?NON_PC_TC_MAYBE_SKIP(Config, Condition), + %% </CONDITIONAL-SKIP> + + httpd_block:restart_disturbing_block(ip_comm, ?IP_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ip_restart_non_disturbing_block(doc) -> + [""]; +ip_restart_non_disturbing_block(suite) -> + []; +ip_restart_non_disturbing_block(Config) when is_list(Config) -> + %% <CONDITIONAL-SKIP> + Condition = + fun() -> + case os:type() of + {unix, linux} -> + HW = string:strip(os:cmd("uname -m"), right, $\n), + case HW of + "ppc" -> + case inet:gethostname() of + {ok, "peach"} -> + true; + _ -> + false + end; + _ -> + false + end; + _ -> + false + end + end, + ?NON_PC_TC_MAYBE_SKIP(Config, Condition), + %% </CONDITIONAL-SKIP> + + httpd_block:restart_non_disturbing_block(ip_comm, ?IP_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ssl_mod_alias(doc) -> + ["Module test: mod_alias"]; +ssl_mod_alias(suite) -> + []; +ssl_mod_alias(Config) when is_list(Config) -> + httpd_mod:alias(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_mod_actions(doc) -> + ["Module test: mod_actions"]; +ssl_mod_actions(suite) -> + []; +ssl_mod_actions(Config) when is_list(Config) -> + httpd_mod:actions(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_mod_security(doc) -> + ["Module test: mod_security"]; +ssl_mod_security(suite) -> + []; +ssl_mod_security(Config) when is_list(Config) -> + ServerRoot = ?config(server_root, Config), + httpd_mod:security(ServerRoot, ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_mod_auth(doc) -> + ["Module test: mod_auth"]; +ssl_mod_auth(suite) -> + []; +ssl_mod_auth(Config) when is_list(Config) -> + httpd_mod:auth(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_mod_auth_api(doc) -> + ["Module test: mod_auth"]; +ssl_mod_auth_api(suite) -> + []; +ssl_mod_auth_api(Config) when is_list(Config) -> + ServerRoot = ?config(server_root, Config), + Host = ?config(host, Config), + Node = ?config(node, Config), + httpd_mod:auth_api(ServerRoot, "", ssl, ?SSL_PORT, Host, Node), + httpd_mod:auth_api(ServerRoot, "dets_", ssl, ?SSL_PORT, Host, Node), + httpd_mod:auth_api(ServerRoot, "mnesia_", ssl, ?SSL_PORT, Host, Node), + ok. + +%%------------------------------------------------------------------------- +ssl_mod_auth_mnesia_api(doc) -> + ["Module test: mod_auth_mnesia_api"]; +ssl_mod_auth_mnesia_api(suite) -> + []; +ssl_mod_auth_mnesia_api(Config) when is_list(Config) -> + httpd_mod:auth_mnesia_api(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_mod_htaccess(doc) -> + ["Module test: mod_htaccess"]; +ssl_mod_htaccess(suite) -> + []; +ssl_mod_htaccess(Config) when is_list(Config) -> + httpd_mod:htaccess(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_mod_cgi(doc) -> + ["Module test: mod_cgi"]; +ssl_mod_cgi(suite) -> + []; +ssl_mod_cgi(Config) when is_list(Config) -> + case test_server:os_type() of + vxworks -> + {skip, cgi_not_supported_on_vxwoks}; + _ -> + httpd_mod:cgi(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok + end. +%%------------------------------------------------------------------------- +ssl_mod_esi(doc) -> + ["Module test: mod_esi"]; +ssl_mod_esi(suite) -> + []; +ssl_mod_esi(Config) when is_list(Config) -> + httpd_mod:esi(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ssl_mod_get(doc) -> + ["Module test: mod_get"]; +ssl_mod_get(suite) -> + []; +ssl_mod_get(Config) when is_list(Config) -> + httpd_mod:get(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_mod_head(doc) -> + ["Module test: mod_head"]; +ssl_mod_head(suite) -> + []; +ssl_mod_head(Config) when is_list(Config) -> + httpd_mod:head(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_mod_all(doc) -> + ["All modules test"]; +ssl_mod_all(suite) -> + []; +ssl_mod_all(Config) when is_list(Config) -> + httpd_mod:all(ssl, ?SSL_PORT, + ?config(host, Config), ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ssl_load_light(doc) -> + ["Test light load"]; +ssl_load_light(suite) -> + []; +ssl_load_light(Config) when is_list(Config) -> + httpd_load:load_test(ssl, ?SSL_PORT, ?config(host, Config), + ?config(node, Config), + get_nof_clients(ssl, light)), + ok. + +%%------------------------------------------------------------------------- +ssl_load_medium(doc) -> + ["Test medium load"]; +ssl_load_medium(suite) -> + []; +ssl_load_medium(Config) when is_list(Config) -> + %% <CONDITIONAL-SKIP> + Skippable = [win32], + Condition = fun() -> ?OS_BASED_SKIP(Skippable) end, + ?NON_PC_TC_MAYBE_SKIP(Config, Condition), + %% </CONDITIONAL-SKIP> + + httpd_load:load_test(ssl, ?SSL_PORT, ?config(host, Config), + ?config(node, Config), + get_nof_clients(ssl, medium)), + ok. + +%%------------------------------------------------------------------------- +ssl_load_heavy(doc) -> + ["Test heavy load"]; +ssl_load_heavy(suite) -> + []; +ssl_load_heavy(Config) when is_list(Config) -> + %% <CONDITIONAL-SKIP> + Skippable = [win32], + Condition = fun() -> ?OS_BASED_SKIP(Skippable) end, + ?NON_PC_TC_MAYBE_SKIP(Config, Condition), + %% </CONDITIONAL-SKIP> + + httpd_load:load_test(ssl, ?SSL_PORT, ?config(host, Config), + ?config(node, Config), + get_nof_clients(ssl, heavy)), + ok. + +%%------------------------------------------------------------------------- +ssl_dos_hostname(doc) -> + ["Denial Of Service (DOS) attack test case"]; +ssl_dos_hostname(suite) -> + []; +ssl_dos_hostname(Config) when is_list(Config) -> + dos_hostname(ssl, ?SSL_PORT, ?config(host, Config), + ?config(node, Config), ?MAX_HEADER_SIZE), + ok. +%%------------------------------------------------------------------------- +ssl_time_test(doc) -> + [""]; +ssl_time_test(suite) -> + []; +ssl_time_test(Config) when is_list(Config) -> + %% <CONDITIONAL-SKIP> + Condition = fun() -> true end, + ?NON_PC_TC_MAYBE_SKIP(Config, Condition), + %% </CONDITIONAL-SKIP> + + httpd_time_test:t(ssl, ?config(host, Config), ?SSL_PORT), + ok. + +%%------------------------------------------------------------------------- +ssl_block_503(doc) -> + ["Check that you will receive status code 503 when the server" + " is blocked and 200 when its not blocked."]; +ssl_block_503(suite) -> + []; +ssl_block_503(Config) when is_list(Config) -> + httpd_block:block_503(ssl, ?SSL_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_block_disturbing_idle(doc) -> + ["Check that you can block/unblock an idle server. The strategy " + "distribing does not really make a difference in this case."]; +ssl_block_disturbing_idle(suite) -> + []; +ssl_block_disturbing_idle(Config) when is_list(Config) -> + httpd_block:block_disturbing_idle(ssl, ?SSL_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_block_non_disturbing_idle(doc) -> + ["Check that you can block/unblock an idle server. The strategy " + "non distribing does not really make a difference in this case."]; +ssl_block_non_disturbing_idle(suite) -> + []; +ssl_block_non_disturbing_idle(Config) when is_list(Config) -> + httpd_block:block_non_disturbing_idle(ssl, ?SSL_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_block_disturbing_active(doc) -> + ["Check that you can block/unblock an active server. The strategy " + "distribing means ongoing requests should be terminated."]; +ssl_block_disturbing_active(suite) -> + []; +ssl_block_disturbing_active(Config) when is_list(Config) -> + httpd_block:block_disturbing_active(ssl, ?SSL_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_block_non_disturbing_active(doc) -> + ["Check that you can block/unblock an idle server. The strategy " + "non distribing means the ongoing requests should be compleated."]; +ssl_block_non_disturbing_active(suite) -> + []; +ssl_block_non_disturbing_active(Config) when is_list(Config) -> + httpd_block:block_non_disturbing_idle(ssl, ?SSL_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ssl_block_disturbing_active_timeout_not_released(doc) -> + ["Check that you can block an active server. The strategy " + "distribing means ongoing requests should be compleated" + "if the timeout does not occur."]; +ssl_block_disturbing_active_timeout_not_released(suite) -> + []; +ssl_block_disturbing_active_timeout_not_released(Config) + when is_list(Config) -> + httpd_block: + block_disturbing_active_timeout_not_released(ssl, + ?SSL_PORT, + ?config(host, + Config), + ?config(node, + Config)), + ok. +%%------------------------------------------------------------------------- +ssl_block_disturbing_active_timeout_released(doc) -> + ["Check that you can block an active server. The strategy " + "distribing means ongoing requests should be terminated when" + "the timeout occurs."]; +ssl_block_disturbing_active_timeout_released(suite) -> + []; +ssl_block_disturbing_active_timeout_released(Config) + when is_list(Config) -> + httpd_block:block_disturbing_active_timeout_released(ssl, + ?SSL_PORT, + ?config(host, + Config), + ?config(node, + Config)), + ok. + +%%------------------------------------------------------------------------- +ssl_block_non_disturbing_active_timeout_not_released(doc) -> + ["Check that you can block an active server. The strategy " + "non non distribing means ongoing requests should be completed."]; +ssl_block_non_disturbing_active_timeout_not_released(suite) -> + []; +ssl_block_non_disturbing_active_timeout_not_released(Config) + when is_list(Config) -> + httpd_block: + block_non_disturbing_active_timeout_not_released(ssl, + ?SSL_PORT, + ?config(host, + Config), + ?config(node, + Config)), + ok. +%%------------------------------------------------------------------------- +ssl_block_non_disturbing_active_timeout_released(doc) -> + ["Check that you can block an active server. The strategy " + "non non distribing means ongoing requests should be completed. " + "When the timeout occurs the block operation sohould be canceled." ]; +ssl_block_non_disturbing_active_timeout_released(suite) -> + []; +ssl_block_non_disturbing_active_timeout_released(Config) + when is_list(Config) -> + httpd_block: + block_non_disturbing_active_timeout_released(ssl, + ?SSL_PORT, + ?config(host, + Config), + ?config(node, + Config)), + ok. + +%%------------------------------------------------------------------------- +ssl_block_disturbing_blocker_dies(doc) -> + []; +ssl_block_disturbing_blocker_dies(suite) -> + []; +ssl_block_disturbing_blocker_dies(Config) when is_list(Config) -> + httpd_block:disturbing_blocker_dies(ssl, ?SSL_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_block_non_disturbing_blocker_dies(doc) -> + []; +ssl_block_non_disturbing_blocker_dies(suite) -> + []; +ssl_block_non_disturbing_blocker_dies(Config) when is_list(Config) -> + httpd_block:non_disturbing_blocker_dies(ssl, ?SSL_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_restart_no_block(doc) -> + [""]; +ssl_restart_no_block(suite) -> + []; +ssl_restart_no_block(Config) when is_list(Config) -> + httpd_block:restart_no_block(ssl, ?SSL_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ssl_restart_disturbing_block(doc) -> + [""]; +ssl_restart_disturbing_block(suite) -> + []; +ssl_restart_disturbing_block(Config) when is_list(Config) -> + %% <CONDITIONAL-SKIP> + Condition = + fun() -> + case os:type() of + {unix, linux} -> + HW = string:strip(os:cmd("uname -m"), right, $\n), + case HW of + "ppc" -> + case inet:gethostname() of + {ok, "peach"} -> + true; + _ -> + false + end; + _ -> + false + end; + _ -> + false + end + end, + ?NON_PC_TC_MAYBE_SKIP(Config, Condition), + %% </CONDITIONAL-SKIP> + + httpd_block:restart_disturbing_block(ssl, ?SSL_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ssl_restart_non_disturbing_block(doc) -> + [""]; +ssl_restart_non_disturbing_block(suite) -> + []; +ssl_restart_non_disturbing_block(Config) when is_list(Config) -> + %% <CONDITIONAL-SKIP> + Condition = + fun() -> + case os:type() of + {unix, linux} -> + HW = string:strip(os:cmd("uname -m"), right, $\n), + case HW of + "ppc" -> + case inet:gethostname() of + {ok, "peach"} -> + true; + _ -> + false + end; + _ -> + false + end; + _ -> + false + end + end, + ?NON_PC_TC_MAYBE_SKIP(Config, Condition), + %% </CONDITIONAL-SKIP> + + httpd_block:restart_non_disturbing_block(ssl, ?SSL_PORT, + ?config(host, Config), + ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ip_host(doc) -> + ["Control that the server accepts/rejects requests with/ without host"]; +ip_host(suite)-> + []; +ip_host(Config) when is_list(Config) -> + httpd_1_1:host(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_chunked(doc) -> + ["Control that the server accepts chunked requests"]; +ip_chunked(suite) -> + []; +ip_chunked(Config) when is_list(Config) -> + httpd_1_1:chunked(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_expect(doc) -> + ["Control that the server handles request with the expect header " + "field appropiate"]; +ip_expect(suite)-> + []; +ip_expect(Config) when is_list(Config) -> + httpd_1_1:expect(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_range(doc) -> + ["Control that the server can handle range requests to plain files"]; +ip_range(suite)-> + []; +ip_range(Config) when is_list(Config) -> + httpd_1_1:range(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_if_test(doc) -> + ["Test that the if - request header fields is handled correclty"]; +ip_if_test(suite) -> + []; +ip_if_test(Config) when is_list(Config) -> + ServerRoot = ?config(server_root, Config), + DocRoot = filename:join([ServerRoot, "htdocs"]), + httpd_1_1:if_test(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config), DocRoot), + ok. +%%------------------------------------------------------------------------- +ip_http_trace(doc) -> + ["Test the trace module "]; +ip_http_trace(suite) -> + []; +ip_http_trace(Config) when is_list(Config) -> + httpd_1_1:http_trace(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config)), + ok. +%%------------------------------------------------------------------------- +ip_http1_1_head(doc) -> + ["Test the trace module "]; +ip_http1_1_head(suite)-> + []; +ip_http1_1_head(Config) when is_list(Config) -> + httpd_1_1:head(ip_comm, ?IP_PORT, ?config(host, Config), + ?config(node, Config)), + ok. + +%%------------------------------------------------------------------------- +ip_get_0_9(doc) -> + ["Test simple HTTP/0.9 GET"]; +ip_get_0_9(suite)-> + []; +ip_get_0_9(Config) when is_list(Config) -> + Host = ?config(host, Config), + Node = ?config(node, Config), + ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, + "GET / \r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/0.9"} ]), + %% Without space after uri + ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, + "GET /\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/0.9"} ]), + ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, + "GET / HTTP/0.9\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/0.9"}]), + + ok. +%%------------------------------------------------------------------------- +ip_head_1_0(doc) -> + ["Test HTTP/1.0 HEAD"]; +ip_head_1_0(suite)-> + []; +ip_head_1_0(Config) when is_list(Config) -> + Host = ?config(host, Config), + Node = ?config(node, Config), + ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, + "HEAD / HTTP/1.0\r\n\r\n", [{statuscode, 200}, + {version, "HTTP/1.0"}]), + + ok. +%%------------------------------------------------------------------------- +ip_get_1_0(doc) -> + ["Test HTTP/1.0 GET"]; +ip_get_1_0(suite)-> + []; +ip_get_1_0(Config) when is_list(Config) -> + Host = ?config(host, Config), + Node = ?config(node, Config), + ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, + "GET / HTTP/1.0\r\n\r\n", [{statuscode, 200}, + {version, "HTTP/1.0"}]), + + ok. +%%------------------------------------------------------------------------- +ip_post_1_0(doc) -> + ["Test HTTP/1.0 POST"]; +ip_post_1_0(suite)-> + []; +ip_post_1_0(Config) when is_list(Config) -> + Host = ?config(host, Config), + Node = ?config(node, Config), + %% Test the post message formatin 1.0! Real post are testes elsewhere + ok = httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, Node, + "POST / HTTP/1.0\r\n\r\n " + "Content-Length:6 \r\n\r\nfoobar", + [{statuscode, 500}, {version, "HTTP/1.0"}]), + + ok. +%%------------------------------------------------------------------------- +ip_mod_cgi_chunked_encoding_test(doc) -> + ["Test the trace module "]; +ip_mod_cgi_chunked_encoding_test(suite)-> + []; +ip_mod_cgi_chunked_encoding_test(Config) when is_list(Config) -> + Host = ?config(host, Config), + Script = + case test_server:os_type() of + {win32, _} -> + "/cgi-bin/printenv.bat"; + _ -> + "/cgi-bin/printenv.sh" + end, + Requests = + ["GET " ++ Script ++ " HTTP/1.1\r\nHost:"++ Host ++"\r\n\r\n", + "GET /cgi-bin/erl/httpd_example/newformat HTTP/1.1\r\nHost:" + ++ Host ++"\r\n\r\n"], + httpd_1_1:mod_cgi_chunked_encoding_test(ip_comm, ?IP_PORT, + Host, + ?config(node, Config), + Requests), + ok. + +%------------------------------------------------------------------------- +ipv6_hostname(doc) -> + ["Test standard ipv6 address"]; +ipv6_hostname(suite)-> + []; +ipv6_hostname(Config) when is_list(Config) -> + Host = ?config(host, Config), + httpd_test_lib:verify_request(ip_comm, Host, ?IP_PORT, node(), + "GET / HTTP/1.1\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.1"}]), + ok. + +%%------------------------------------------------------------------------- +ipv6_address(doc) -> + ["Test standard ipv6 address"]; +ipv6_address(suite)-> + []; +ipv6_address(Config) when is_list(Config) -> + httpd_test_lib:verify_request(ip_comm, ?IPV6_LOCAL_HOST, ?IP_PORT, + node(), "GET / HTTP/1.1\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.1"}]), + ok. + +%%-------------------------------------------------------------------- +ticket_5775(doc) -> + ["Tests that content-length is correct"]; +ticket_5775(suite) -> + []; +ticket_5775(Config) -> + ok=httpd_test_lib:verify_request(ip_comm, ?config(host, Config), + ?IP_PORT, ?config(node, Config), + "GET /cgi-bin/erl/httpd_example:get_bin " + "HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok. +ticket_5865(doc) -> + ["Tests that a header without last-modified is handled"]; +ticket_5865(suite) -> + []; +ticket_5865(Config) -> + Host = ?config(host,Config), + ServerRoot = ?config(server_root, Config), + DocRoot = filename:join([ServerRoot, "htdocs"]), + File = filename:join([DocRoot,"last_modified.html"]), + + Bad_mtime = case test_server:os_type() of + {win32, _} -> + {{1600,12,31},{23,59,59}}; + {unix, _} -> + {{1969,12,31},{23,59,59}} + end, + + {ok,FI}=file:read_file_info(File), + + case file:write_file_info(File,FI#file_info{mtime=Bad_mtime}) of + ok -> + ok = httpd_test_lib:verify_request(ip_comm, Host, + ?IP_PORT, ?config(node, Config), + "GET /last_modified.html" + " HTTP/1.1\r\nHost:" + ++Host++"\r\n\r\n", + [{statuscode, 200}, + {no_last_modified, + "last-modified"}]), + ok; + {error, Reason} -> + Fault = + io_lib:format("Attempt to change the file info to set the" + " preconditions of the test case failed ~p~n", + [Reason]), + {skip, Fault} + end. + +ticket_5913(doc) -> + ["Tests that a header without last-modified is handled"]; +ticket_5913(suite) -> []; +ticket_5913(Config) -> + ok=httpd_test_lib:verify_request(ip_comm, ?config(host, Config), + ?IP_PORT, ?config(node, Config), + "GET /cgi-bin/erl/httpd_example:get_bin " + "HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok. + +ticket_6003(doc) -> + ["Tests that a URI with a bad hexadecimal code is handled"]; +ticket_6003(suite) -> []; +ticket_6003(Config) -> + ok=httpd_test_lib:verify_request(ip_comm, ?config(host, Config), + ?IP_PORT, ?config(node, Config), + "GET http://www.erlang.org/%skalle " + "HTTP/1.0\r\n\r\n", + [{statuscode, 400}, + {version, "HTTP/1.0"}]), + ok. + +ticket_7304(doc) -> + ["Tests missing CR in delimiter"]; +ticket_7304(suite) -> + []; +ticket_7304(Config) -> + ok = httpd_test_lib:verify_request(ip_comm, ?config(host, Config), + ?IP_PORT, ?config(node, Config), + "GET / HTTP/1.0\r\n\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok. + +%%-------------------------------------------------------------------- +%% Internal functions +%%-------------------------------------------------------------------- +dos_hostname(Type, Port, Host, Node, Max) -> + H1 = {"", 200}, + H2 = {"dummy-host.ericsson.se", 200}, + TooLongHeader = lists:append(lists:duplicate(Max + 1, "a")), + H3 = {TooLongHeader, 403}, + Hosts = [H1,H2,H3], + dos_hostname_poll(Type, Host, Port, Node, Hosts). + +%% make_ipv6(T) when is_tuple(T) andalso (size(T) =:= 8) -> +%% make_ipv6(tuple_to_list(T)); + +%% make_ipv6([_, _, _, _, _, _, _, _] = IPV6) -> +%% lists:flatten(io_lib:format("~s:~s:~s:~s:~s:~s:~s:~s", IPV6)). + + +%%-------------------------------------------------------------------- +%% Other help functions +create_config(Config, Access, FileName) -> + ServerRoot = ?config(server_root, Config), + TcTopDir = ?config(tc_top_dir, Config), + Port = ?config(port, Config), + Type = ?config(sock_type, Config), + Host = ?config(host, Config), + Mods = io_lib:format("~p", [httpd_mod]), + Funcs = io_lib:format("~p", [ssl_password_cb]), + MaxHdrSz = io_lib:format("~p", [256]), + MaxHdrAct = io_lib:format("~p", [close]), + SSL = + case Type of + ssl -> + [cline(["SSLCertificateFile ", + filename:join(ServerRoot, "ssl/ssl_server.pem")]), + cline(["SSLCertificateKeyFile ", + filename:join(ServerRoot, "ssl/ssl_server.pem")]), + cline(["SSLCACertificateFile ", + filename:join(ServerRoot, "ssl/ssl_server.pem")]), + cline(["SSLPasswordCallbackModule ", Mods]), + cline(["SSLPasswordCallbackFunction ", Funcs]), + cline(["SSLVerifyClient 0"]), + cline(["SSLVerifyDepth 1"])]; + _ -> + [] + end, + Mod_order = case Access of + mod_htaccess -> + "Modules mod_alias mod_htaccess mod_auth " + "mod_security " + "mod_responsecontrol mod_trace mod_esi " + "mod_actions mod_cgi mod_include mod_dir " + "mod_range mod_get " + "mod_head mod_log mod_disk_log"; + _ -> + "Modules mod_alias mod_auth mod_security " + "mod_responsecontrol mod_trace mod_esi " + "mod_actions mod_cgi mod_include mod_dir " + "mod_range mod_get " + "mod_head mod_log mod_disk_log" + end, + +%% The test suite currently does not handle an explicit BindAddress. +%% They assume any has been used, that is Addr is always set to undefined! + +%% {ok, Hostname} = inet:gethostname(), +%% {ok, Addr} = inet:getaddr(Hostname, inet6), +%% AddrStr = make_ipv6(Addr), +%% BindAddress = lists:flatten(io_lib:format("~s|inet6", [AddrStr])), + + %% BindAddress = "*|inet", + BindAddress = "*", + + HttpConfig = [ + cline(["Port ", integer_to_list(Port)]), + cline(["ServerName ", Host]), + cline(["SocketType ", atom_to_list(Type)]), + cline([Mod_order]), + %% cline(["LogFormat ", "erlang"]), + cline(["ServerAdmin [email protected]"]), + cline(["BindAddress ", BindAddress]), + cline(["ServerRoot ", ServerRoot]), + cline(["ErrorLog ", TcTopDir, + "/logs/error_log_", integer_to_list(Port)]), + cline(["TransferLog ", TcTopDir, + "/logs/access_log_", integer_to_list(Port)]), + cline(["SecurityLog ", TcTopDir, + "/logs/security_log_", integer_to_list(Port)]), + cline(["ErrorDiskLog ", TcTopDir, + "/logs/error_disk_log_", integer_to_list(Port)]), + cline(["ErrorDiskLogSize ", "190000 ", "11"]), + cline(["TransferDiskLog ", TcTopDir, + "/logs/access_disk_log_", integer_to_list(Port)]), + cline(["TransferDiskLogSize ", "200000 ", "10"]), + cline(["SecurityDiskLog ", TcTopDir, + "/logs/security_disk_log_", integer_to_list(Port)]), + cline(["SecurityDiskLogSize ", "210000 ", "9"]), + cline(["MaxClients 10"]), + cline(["MaxHeaderSize ", MaxHdrSz]), + cline(["MaxHeaderAction ", MaxHdrAct]), + cline(["DocumentRoot ", + filename:join(ServerRoot, "htdocs")]), + cline(["DirectoryIndex ", "index.html ", "welcome.html"]), + cline(["DefaultType ", "text/plain"]), + SSL, + mod_alias_config(ServerRoot), + + config_directory(filename:join([ServerRoot,"htdocs", + "open"]), + "Open Area", + filename:join(ServerRoot, "auth/passwd"), + filename:join(ServerRoot, "auth/group"), + plain, + "user one Aladdin", + filename:join(ServerRoot, "security_data")), + config_directory(filename:join([ServerRoot,"htdocs", + "secret"]), + "Secret Area", + filename:join(ServerRoot, "auth/passwd"), + filename:join(ServerRoot, "auth/group"), + plain, + "group group1 group2", + filename:join(ServerRoot, "security_data")), + config_directory(filename:join([ServerRoot,"htdocs", + "secret", + "top_secret"]), + "Top Secret Area", + filename:join(ServerRoot, "auth/passwd"), + filename:join(ServerRoot, "auth/group"), + plain, + "group group3", + filename:join(ServerRoot, "security_data")), + + config_directory(filename:join([ServerRoot,"htdocs", + "dets_open"]), + "Dets Open Area", + filename:join(ServerRoot, "passwd"), + filename:join(ServerRoot, "group"), + dets, + "user one Aladdin", + filename:join(ServerRoot, "security_data")), + config_directory(filename:join([ServerRoot,"htdocs", + "dets_secret"]), + "Dets Secret Area", + filename:join(ServerRoot, "passwd"), + filename:join(ServerRoot, "group"), + dets, + "group group1 group2", + filename:join(ServerRoot, "security_data")), + config_directory(filename:join([ServerRoot,"htdocs", + "dets_secret", + "top_secret"]), + "Dets Top Secret Area", + filename:join(ServerRoot, "passwd"), + filename:join(ServerRoot, "group"), + dets, + "group group3", + filename:join(ServerRoot, "security_data")), + + config_directory(filename:join([ServerRoot,"htdocs", + "mnesia_open"]), + "Mnesia Open Area", + false, + false, + mnesia, + "user one Aladdin", + filename:join(ServerRoot, "security_data")), + config_directory(filename:join([ServerRoot,"htdocs", + "mnesia_secret"]), + "Mnesia Secret Area", + false, + false, + mnesia, + "group group1 group2", + filename:join(ServerRoot, "security_data")), + config_directory(filename:join( + [ServerRoot, "htdocs", "mnesia_secret", + "top_secret"]), + "Mnesia Top Secret Area", + false, + false, + mnesia, + "group group3", + filename:join(ServerRoot, "security_data")) + ], + ConfigFile = filename:join([TcTopDir, FileName]), + {ok, Fd} = file:open(ConfigFile, [write]), + ok = file:write(Fd, lists:flatten(HttpConfig)), + ok = file:close(Fd). + +config_directory(Dir, AuthName, AuthUserFile, AuthGroupFile, AuthDBType, + Require, SF) -> + file:delete(SF), + [ + cline(["<Directory ", Dir, ">"]), + cline(["SecurityDataFile ", SF]), + cline(["SecurityMaxRetries 3"]), + cline(["SecurityFailExpireTime ", integer_to_list(?FAIL_EXPIRE_TIME)]), + cline(["SecurityBlockTime 1"]), + cline(["SecurityAuthTimeout ", integer_to_list(?AUTH_TIMEOUT)]), + cline(["SecurityCallbackModule ", "httpd_mod"]), + cline_if_set("AuthUserFile", AuthUserFile), + cline_if_set("AuthGroupFile", AuthGroupFile), + cline_if_set("AuthName", AuthName), + cline_if_set("AuthDBType", AuthDBType), + cline(["require ", Require]), + cline(["</Directory>\r\n"]) + ]. + +mod_alias_config(Root) -> + [ + cline(["Alias /icons/ ", filename:join(Root,"icons"), "/"]), + cline(["Alias /pics/ ", filename:join(Root, "icons"), "/"]), + cline(["ScriptAlias /cgi-bin/ ", filename:join(Root, "cgi-bin"), "/"]), + cline(["ScriptAlias /htbin/ ", filename:join(Root, "cgi-bin"), "/"]), + cline(["ErlScriptAlias /cgi-bin/erl httpd_example io"]), + cline(["EvalScriptAlias /eval httpd_example io"]) + ]. + +cline(List) -> + lists:flatten([List, "\r\n"]). + +cline_if_set(_, false) -> + []; +cline_if_set(Name, Var) when is_list(Var) -> + cline([Name, " ", Var]); +cline_if_set(Name, Var) when is_atom(Var) -> + cline([Name, " ", atom_to_list(Var)]). + +getaddr() -> + {ok,HostName} = inet:gethostname(), + {ok,{A1,A2,A3,A4}} = inet:getaddr(HostName,inet), + lists:flatten(io_lib:format("~p.~p.~p.~p",[A1,A2,A3,A4])). + +start_mnesia(Node) -> + case rpc:call(Node, ?MODULE, cleanup_mnesia, []) of + ok -> + ok; + Other -> + test_server:fail({failed_to_cleanup_mnesia, Other}) + end, + case rpc:call(Node, ?MODULE, setup_mnesia, []) of + {atomic, ok} -> + ok; + Other2 -> + test_server:fail({failed_to_setup_mnesia, Other2}) + end, + ok. + +setup_mnesia() -> + setup_mnesia([node()]). + +setup_mnesia(Nodes) -> + ok = mnesia:create_schema(Nodes), + ok = mnesia:start(), + {atomic, ok} = mnesia:create_table(httpd_user, + [{attributes, + record_info(fields, httpd_user)}, + {disc_copies,Nodes}, {type, set}]), + {atomic, ok} = mnesia:create_table(httpd_group, + [{attributes, + record_info(fields, + httpd_group)}, + {disc_copies,Nodes}, {type,bag}]). + +cleanup_mnesia() -> + mnesia:start(), + mnesia:delete_table(httpd_user), + mnesia:delete_table(httpd_group), + stopped = mnesia:stop(), + mnesia:delete_schema([node()]), + ok. + +create_htacess_data(Path, IpAddress)-> + create_htacess_dirs(Path), + + create_html_file(filename:join([Path,"ht/open/dummy.html"])), + create_html_file(filename:join([Path,"ht/blocknet/dummy.html"])), + create_html_file(filename:join([Path,"ht/secret/dummy.html"])), + create_html_file(filename:join([Path,"ht/secret/top_secret/dummy.html"])), + + create_htacess_file(filename:join([Path,"ht/open/.htaccess"]), + Path, "user one Aladdin"), + create_htacess_file(filename:join([Path,"ht/secret/.htaccess"]), + Path, "group group1 group2"), + create_htacess_file(filename:join([Path, + "ht/secret/top_secret/.htaccess"]), + Path, "user four"), + create_htacess_file(filename:join([Path,"ht/blocknet/.htaccess"]), + Path, nouser, IpAddress), + + create_user_group_file(filename:join([Path,"ht","users.file"]), + "one:OnePassword\ntwo:TwoPassword\nthree:" + "ThreePassword\nfour:FourPassword\nAladdin:" + "AladdinPassword"), + create_user_group_file(filename:join([Path,"ht","groups.file"]), + "group1: two one\ngroup2: two three"). + +create_html_file(PathAndFileName)-> + file:write_file(PathAndFileName,list_to_binary( + "<html><head><title>test</title></head> + <body>testar</body></html>")). + +create_htacess_file(PathAndFileName, BaseDir, RequireData)-> + file:write_file(PathAndFileName, + list_to_binary( + "AuthUserFile "++ BaseDir ++ + "/ht/users.file\nAuthGroupFile "++ BaseDir + ++ "/ht/groups.file\nAuthName Test\nAuthType" + " Basic\n<Limit>\nrequire " ++ RequireData ++ + "\n</Limit>")). + +create_htacess_file(PathAndFileName, BaseDir, nouser, IpAddress)-> + file:write_file(PathAndFileName,list_to_binary( + "AuthUserFile "++ BaseDir ++ + "/ht/users.file\nAuthGroupFile " ++ + BaseDir ++ "/ht/groups.file\nAuthName" + " Test\nAuthType" + " Basic\n<Limit GET>\n\tallow from " ++ + format_ip(IpAddress, + string:rchr(IpAddress,$.)) ++ + "\n</Limit>")). + +create_user_group_file(PathAndFileName, Data)-> + file:write_file(PathAndFileName, list_to_binary(Data)). + +create_htacess_dirs(Path)-> + ok = file:make_dir(filename:join([Path,"ht"])), + ok = file:make_dir(filename:join([Path,"ht/open"])), + ok = file:make_dir(filename:join([Path,"ht/blocknet"])), + ok = file:make_dir(filename:join([Path,"ht/secret"])), + ok = file:make_dir(filename:join([Path,"ht/secret/top_secret"])). + +remove_htacess_dirs(Path)-> + file:del_dir(filename:join([Path,"ht/secret/top_secret"])), + file:del_dir(filename:join([Path,"ht/secret"])), + file:del_dir(filename:join([Path,"ht/blocknet"])), + file:del_dir(filename:join([Path,"ht/open"])), + file:del_dir(filename:join([Path,"ht"])). + +format_ip(IpAddress,Pos)when Pos > 0-> + case lists:nth(Pos,IpAddress) of + $.-> + case lists:nth(Pos-2,IpAddress) of + $.-> + format_ip(IpAddress,Pos-3); + _-> + lists:sublist(IpAddress,Pos-2) ++ "." + end; + _ -> + format_ip(IpAddress,Pos-1) + end; + +format_ip(IpAddress, _Pos)-> + "1" ++ IpAddress. + +remove_htacess(Path)-> + file:delete(filename:join([Path,"ht/open/dummy.html"])), + file:delete(filename:join([Path,"ht/secret/dummy.html"])), + file:delete(filename:join([Path,"ht/secret/top_secret/dummy.html"])), + file:delete(filename:join([Path,"ht/blocknet/dummy.html"])), + file:delete(filename:join([Path,"ht/blocknet/.htaccess"])), + file:delete(filename:join([Path,"ht/open/.htaccess"])), + file:delete(filename:join([Path,"ht/secret/.htaccess"])), + file:delete(filename:join([Path,"ht/secret/top_secret/.htaccess"])), + file:delete(filename:join([Path,"ht","users.file"])), + file:delete(filename:join([Path,"ht","groups.file"])), + remove_htacess_dirs(Path). + + +dos_hostname_poll(Type, Host, Port, Node, Hosts) -> + [dos_hostname_poll1(Type, Host, Port, Node, Host1, Code) + || {Host1,Code} <- Hosts]. + +dos_hostname_poll1(Type, Host, Port, Node, Host1, Code) -> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + dos_hostname_request(Host1), + [{statuscode, Code}, + {version, "HTTP/1.0"}]). + +dos_hostname_request(Host) -> + "GET / HTTP/1.0\r\n" ++ Host ++ "\r\n\r\n". + +get_nof_clients(Mode, Load) -> + get_nof_clients(test_server:os_type(), Mode, Load). + +get_nof_clients(vxworks, _, light) -> 1; +get_nof_clients(vxworks, ip_comm, medium) -> 3; +get_nof_clients(vxworks, ssl, medium) -> 3; +get_nof_clients(vxworks, ip_comm, heavy) -> 5; +get_nof_clients(vxworks, ssl, heavy) -> 5; +get_nof_clients(_, ip_comm, light) -> 5; +get_nof_clients(_, ssl, light) -> 2; +get_nof_clients(_, ip_comm, medium) -> 10; +get_nof_clients(_, ssl, medium) -> 4; +get_nof_clients(_, ip_comm, heavy) -> 20; +get_nof_clients(_, ssl, heavy) -> 6. + +%% Make a file 100 bytes long containing 012...9*10 +create_range_data(Path)-> + PathAndFileName=filename:join([Path,"range.txt"]), + file:write_file(PathAndFileName,list_to_binary(["12345678901234567890", + "12345678901234567890", + "12345678901234567890", + "12345678901234567890", + "12345678901234567890"])). + +%% create_ipv6_config(Config, FileName, Ipv6Address) -> +%% ServerRoot = ?config(server_root, Config), +%% TcTopDir = ?config(tc_top_dir, Config), +%% Port = ?config(port, Config), +%% SockType = ?config(sock_type, Config), +%% +%% MaxHdrSz = io_lib:format("~p", [256]), +%% MaxHdrAct = io_lib:format("~p", [close]), +%% +%% Mod_order = "Modules mod_alias mod_auth mod_esi mod_actions mod_cgi" +%% " mod_include mod_dir mod_get mod_head" +%% " mod_log mod_disk_log mod_trace", +%% +%% HttpConfig = [cline(["BindAddress ", "[" ++ Ipv6Address ++"]|inet6"]), +%% cline(["Port ", integer_to_list(Port)]), +%% cline(["ServerName ", "httpc_test"]), +%% cline(["SocketType ", atom_to_list(SockType)]), +%% cline([Mod_order]), +%% cline(["ServerRoot ", ServerRoot]), +%% cline(["DocumentRoot ", +%% filename:join(ServerRoot, "htdocs")]), +%% cline(["MaxHeaderSize ",MaxHdrSz]), +%% cline(["MaxHeaderAction ",MaxHdrAct]), +%% cline(["DirectoryIndex ", "index.html "]), +%% cline(["DefaultType ", "text/plain"])], +%% ConfigFile = filename:join([TcTopDir,FileName]), +%% {ok, Fd} = file:open(ConfigFile, [write]), +%% ok = file:write(Fd, lists:flatten(HttpConfig)), +%% ok = file:close(Fd). diff --git a/lib/inets/test/httpd_SUITE_data/Makefile.src b/lib/inets/test/httpd_SUITE_data/Makefile.src new file mode 100644 index 0000000000..b0fdb43d8d --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/Makefile.src @@ -0,0 +1,14 @@ +CC = @CC@ +LD = @LD@ +CFLAGS = @CFLAGS@ -I@erl_include@ @DEFS@ +CROSSLDFLAGS = @CROSSLDFLAGS@ + +PROGS = cgi_echo@exe@ + +all: $(PROGS) + +cgi_echo@exe@: cgi_echo@obj@ + $(LD) $(CROSSLDFLAGS) -o cgi_echo cgi_echo@obj@ @LIBS@ + +cgi_echo@obj@: cgi_echo.c + $(CC) -c -o cgi_echo@obj@ $(CFLAGS) cgi_echo.c diff --git a/lib/inets/test/httpd_SUITE_data/cgi_echo.c b/lib/inets/test/httpd_SUITE_data/cgi_echo.c new file mode 100644 index 0000000000..580f860e96 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/cgi_echo.c @@ -0,0 +1,97 @@ +#include <stdlib.h> +#include <stdio.h> + +#if defined __WIN32__ +#include <windows.h> +#include <fcntl.h> +#endif + +static int read_exact(char *buffer, int len); +static int write_exact(char *buffer, int len); + +int main(void) +{ + char msg[100]; + int msg_len; +#ifdef __WIN32__ + _setmode(_fileno( stdin), _O_BINARY); + _setmode(_fileno( stdout), _O_BINARY); +#endif + msg_len = read_exact(msg, 100); + + write_exact("Content-type: text/plain\r\n\r\n", 28); + write_exact(msg, msg_len); + exit(EXIT_SUCCESS); +} + + +/* read from stdin */ +#ifdef __WIN32__ +static int read_exact(char *buffer, int len) +{ + HANDLE standard_input = GetStdHandle(STD_INPUT_HANDLE); + + unsigned read_result; + unsigned sofar = 0; + + if (!len) { /* Happens for "empty packages */ + return 0; + } + for (;;) { + if (!ReadFile(standard_input, buffer + sofar, + len - sofar, &read_result, NULL)) { + return -1; /* EOF */ + } + if (!read_result) { + return -2; /* Interrupted while reading? */ + } + sofar += read_result; + if (sofar == len) { + return len; + } + } +} +#else +static int read_exact(char *buffer, int len) { + int i, got = 0; + + do { + if ((i = read(0, buffer + got, len - got)) <= 0) + return(i); + got += i; + } while (got < len); + return len; + +} +#endif + +/* write to stdout */ +#ifdef __WIN32__ + static int write_exact(char *buffer, int len) + { + HANDLE standard_output = GetStdHandle(STD_OUTPUT_HANDLE); + unsigned written; + + if (!WriteFile(standard_output, buffer, len, &written, NULL)) { + return -1; /* Broken Pipe */ + } + if (written < ((unsigned) len)) { + /* This should not happen, standard output is not blocking? */ + return -2; + } + + return (int) written; +} + +#else + static int write_exact(char *buffer, int len) { + int i, wrote = 0; + + do { + if ((i = write(1, buffer + wrote, len - wrote)) <= 0) + return i; + wrote += i; + } while (wrote < len); + return len; + } +#endif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/auth/group b/lib/inets/test/httpd_SUITE_data/server_root/auth/group new file mode 100644 index 0000000000..b3da0ccbd3 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/auth/group @@ -0,0 +1,3 @@ +group1: one two +group2: two three +group3: three Aladdin diff --git a/lib/inets/test/httpd_SUITE_data/server_root/auth/passwd b/lib/inets/test/httpd_SUITE_data/server_root/auth/passwd new file mode 100644 index 0000000000..8c980ff547 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/auth/passwd @@ -0,0 +1,4 @@ +one:onePassword +two:twoPassword +three:threePassword +Aladdin:AladdinPassword diff --git a/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.bat b/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.bat new file mode 100644 index 0000000000..25a49a1536 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.bat @@ -0,0 +1,9 @@ +@echo off +echo tomrad > c:\cygwin\tmp\hej +echo Content-type: text/html +echo. +echo ^<HTML^> ^<HEAD^> ^<TITLE^>OS Environment^</TITLE^> ^</HEAD^> ^<BODY^>^<PRE^> +set +echo ^</PRE^>^</BODY^>^</HTML^> + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.sh b/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.sh new file mode 100755 index 0000000000..de81de9bde --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/cgi-bin/printenv.sh @@ -0,0 +1,6 @@ +#!/bin/sh +echo "Content-type: text/html" +echo "" +echo "<HTML> <HEAD> <TITLE>OS Environment</TITLE> </HEAD> <BODY><PRE>" +env +echo "</PRE></BODY></HTML>"
\ No newline at end of file diff --git a/lib/inets/test/httpd_SUITE_data/server_root/conf/8080.conf b/lib/inets/test/httpd_SUITE_data/server_root/conf/8080.conf new file mode 100644 index 0000000000..48e66f0114 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/conf/8080.conf @@ -0,0 +1,79 @@ +Port 8080 +#ServerName your.server.net +SocketType ip_comm +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log +ServerAdmin [email protected] +ServerRoot /var/tmp/server_root +ErrorLog logs/error_log_8080 +TransferLog logs/access_log_8080 +SecurityLog logs/security_log_8080 +ErrorDiskLog logs/error_disk_log_8080 +ErrorDiskLogSize 200000 10 +TransferDiskLog logs/access_disk_log_8080 +TransferDiskLogSize 200000 10 +SecurityDiskLog logs/security_disk_log +SecurityDiskLogSize 200000 10 +MaxClients 50 +#KeepAlive 5 +#KeepAliveTimeout 10 +DocumentRoot /var/tmp/server_root/htdocs +DirectoryIndex index.html welcome.html +DefaultType text/plain +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ +ErlScriptAlias /cgi-bin/erl httpd_example io +EvalScriptAlias /eval httpd_example io +#Script HEAD /cgi-bin/printenv.sh +#Action image/gif /cgi-bin/printenv.sh + +<Directory /var/tmp/server_root/htdocs/open> +AuthDBType plain +AuthName Open Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret> +AuthDBType plain +AuthName Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret/top_secret> +AuthDBType plain +AuthName Top Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group3 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_open> +AuthDBType mnesia +AuthName Open Area +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret> +AuthDBType mnesia +AuthName Secret Area +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret/top_secret> +AuthDBType mnesia +AuthName Top Secret Area +require group group3 +allow from 130.100.34 130.100.35 +deny from 100.234.22.12 194.100.34.1 130.100.34.25 +SecurityDataFile logs/security_data +SecurityMaxRetries 3 +SecurityBlockTime 10 +SecurityFailExpireTime 1 +SecurityAuthTimeout 1 +SecurityCallbackModule security_callback +</Directory> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/conf/8888.conf b/lib/inets/test/httpd_SUITE_data/server_root/conf/8888.conf new file mode 100644 index 0000000000..79bb7fcca4 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/conf/8888.conf @@ -0,0 +1,63 @@ +Port 8888 +#ServerName your.server.net +SocketType ip_comm +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log +ServerAdmin [email protected] +ServerRoot /var/tmp/server_root +ErrorLog logs/error_log_8888 +TransferLog logs/access_log_8888 +ErrorDiskLog logs/error_disk_log_8888 +ErrorDiskLogSize 200000 10 +TransferDiskLog logs/access_disk_log_8888 +TransferDiskLogSize 200000 10 +MaxClients 150 +DocumentRoot /var/tmp/server_root/htdocs +DirectoryIndex index.html welcome.html +DefaultType text/plain +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ +ErlScriptAlias /cgi-bin/erl httpd_example io +EvalScriptAlias /eval httpd_example io +#Script HEAD /cgi-bin/printenv.sh +#Action image/gif /cgi-bin/printenv.sh + +<Directory /var/tmp/server_root/htdocs/open> +AuthName Open Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret> +AuthName Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret/top_secret> +AuthName Top Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group3 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_open> +AuthName Open Area +AuthMnesiaDB On +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret> +AuthName Secret Area +AuthMnesiaDB On +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret/top_secret> +AuthName Top Secret Area +AuthMnesiaDB On +require group group3 +</Directory> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/conf/httpd.conf b/lib/inets/test/httpd_SUITE_data/server_root/conf/httpd.conf new file mode 100644 index 0000000000..8a74ed1afd --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/conf/httpd.conf @@ -0,0 +1,268 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1997-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# + +# Port: The port the standalone listens to. For ports < 1023, you will +# need httpd to be run as root initially. + +Port 8888 + +# BindAddress: This directive is used to tell the server which IP address +# to listen to. It can either contain "*", an IP address, or a fully +# qualified Internet domain name. +# +# It is also possible to specify the ip-family with the directive. +# There ar three possible value: inet, inet6 and inet6fb4 +# inet: Use IpFamily inet when retreiving the address and +# fail if that does not work. +# inet6: Use IpFamily inet6 when retreiving the address and +# fail if that does not work. +# inet6fb4: First IpFamily inet6 is tried and if that does not work, +# inet is used as fallback. +# Default value for ip-family is inet6fb4 +# +# The syntax is: <address>[|<ip-family>] +# +#BindAddress * +#BindAddress *|inet + + +# ServerName allows you to set a host name which is sent back to clients for +# your server if it's different than the one the program would get (i.e. use +# "www" instead of the host's real name). +# +# Note: You cannot just invent host names and hope they work. The name you +# define here must be a valid DNS name for your host. If you don't understand +# this, ask your network administrator. + +#ServerName your.server.net + +# SocketType is either ip_comm, sockets or ssl. + +SocketType ip_comm + +# Modules: Server run-time plug-in modules written using the Erlang +# Web Server API (EWSAPI). The server API make it easy to add functionality +# to the server. Read more about EWSAPI in the Reference Manual. +# WARNING! Do not tamper with this directive unless you are familiar with +# EWSAPI. + +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_responsecontrol mod_trace mod_range mod_head mod_include mod_dir mod_get mod_log mod_disk_log + +# ServerAdmin: Your address, where problems with the server should be +# e-mailed. + +ServerAdmin [email protected] + +# ServerRoot: The directory the server's config, error, and log files +# are kept in + +ServerRoot /var/tmp/server_root + +# ErrorLog: The location of the error log file. If this does not start +# with /, ServerRoot is prepended to it. + +ErrorLog logs/error_log + +# TransferLog: The location of the transfer log file. If this does not +# start with /, ServerRoot is prepended to it. + +TransferLog logs/access_log + +# SecurityLog: The location of the security log file (mod_security required) +# +SecurityLog logs/security_log + +# ErrorDiskLog: The location of the error log file. If this does not +# start with /, ServerRoot is prepended to it. This log file is managed +# with the disk_log module [See disk_log(3)]. The ErrorDiskLogSize directive +# takes two argument, i.e. MaxBytes and MaxFiles. The wrap log writes at most +# MaxBytes bytes on each file, and it uses MaxFiles files before it wraps, and +# truncates the first file. + +ErrorDiskLog logs/error_disk_log +ErrorDiskLogSize 200000 10 + +# TransferDiskLog: The location of the transfer log file. If this does not +# start with /, ServerRoot is prepended to it. This log file is managed +# with the disk_log module [See disk_log(3)]. The TransferDiskLogSize directive +# takes two argument, i.e. MaxBytes and MaxFiles. The wrap log writes at most +# MaxBytes bytes on each file, and it uses MaxFiles files before it wraps, and +# truncates the first file. + +TransferDiskLog logs/access_disk_log +TransferDiskLogSize 200000 10 + +# SecurityDiskLog: The location of the security log file. If this does not +# start with /, ServerRoot is prepended to it. This log file is managed +# with the disk_log module [See disk_log(3)]. The SecurityDiskLogSize directive +# takes two argument, i.e. MaxBytes and MaxFiles. The wrap log writes at most +# MaxBytes bytes on each file, and it uses MaxFiles files before it wraps, and +# truncates the first file. + +SecurityDiskLog logs/security_disk_log +SecurityDiskLogSize 200000 10 + +# Limit on total number of servers running, i.e., limit on the number +# of clients who can simultaneously connect --- if this limit is ever +# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW. +# It is intended mainly as a brake to keep a runaway server from taking +# the server with it as it spirals down... + +MaxClients 50 + +# KeepAlive set the flag for persistent connections. For peristent connections +# set KeepAlive to on. To use One request per connection set the flag to off +# Note: The value has changed since previous version of INETS. +KeepAlive on + +# KeepAliveTimeout sets the number of seconds before a persistent connection +# times out and closes. +KeepAliveTimeout 10 + +# MaxKeepAliveRequests sets the number of seconds before a persistent connection +# times out and closes. +MaxKeepAliveRequests 10 + + + +# DocumentRoot: The directory out of which you will serve your +# documents. By default, all requests are taken from this directory, but +# symbolic links and aliases may be used to point to other locations. + +DocumentRoot /var/tmp/server_root/htdocs + +# DirectoryIndex: Name of the file or files to use as a pre-written HTML +# directory index. Separate multiple entries with spaces. + +DirectoryIndex index.html welcome.html + +# DefaultType is the default MIME type for documents which the server +# cannot find the type of from filename extensions. + +DefaultType text/plain + +# Aliases: Add here as many aliases as you need (with no limit). The format is +# Alias fakename realname + +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ + +# ScriptAlias: This controls which directories contain server scripts. +# Format: ScriptAlias fakename realname + +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ + +# This directive adds an action, which will activate cgi-script when a +# file is requested using the method of method, which can be one of +# GET, POST and HEAD. It sends the URL and file path of the requested +# document using the standard CGI PATH_INFO and PATH_TRANSLATED +# environment variables. + +#Script HEAD /cgi-bin/printenv.sh + +# This directive adds an action, which will activate cgi-script when a +# file of content type mime-type is requested. It sends the URL and +# file path of the requested document using the standard CGI PATH_INFO +# and PATH_TRANSLATED environment variables. + +#Action image/gif /cgi-bin/printenv.sh + +# ErlScriptAlias: This specifies how "Erl" server scripts are called. +# Format: ErlScriptAlias fakename realname allowed_modules + +ErlScriptAlias /down/erl httpd_example io + +# EvalScriptAlias: This specifies how "Eval" server scripts are called. +# Format: EvalScriptAlias fakename realname allowed_modules + +EvalScriptAlias /eval httpd_example io + +# Point SSLCertificateFile at a PEM encoded certificate. + +SSLCertificateFile /var/tmp/server_root/ssl/ssl_server.pem + +# If the key is not combined with the certificate, use this directive to +# point at the key file. + +SSLCertificateKeyFile /var/tmp/server_root/ssl/ssl_server.pem + +# Set SSLVerifyClient to: +# 0 if no certicate is required +# 1 if the client may present a valid certificate +# 2 if the client must present a valid certificate +# 3 if the client may present a valid certificate but it is not required to +# have a valid CA + +SSLVerifyClient 0 + +# Each directory to which INETS has access, can be configured with respect +# to which services and features are allowed and/or disabled in that +# directory (and its subdirectories). + +<Directory /var/tmp/server_root/htdocs/open> +AuthDBType plain +AuthName Open Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret> +AuthDBType plain +AuthName Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret/top_secret> +AuthDBType plain +AuthName Top Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group3 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_open> +AuthDBType mnesia +AuthName Open Area +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret> +AuthDBType mnesia +AuthName Secret Area +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret/top_secret> +AuthDBType mnesia +AuthName Top Secret Area +require group group3 +allow from 130.100.34 130.100.35 +deny from 100.234.22.12 194.100.34.1 130.100.34.25 +SecurityDataFile logs/security_data +SecurityMaxRetries 3 +SecurityBlockTime 10 +SecurityFailExpireTime 1 +SecurityAuthTimeout 1 +SecurityCallbackModule security_callback +</Directory> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/conf/mime.types b/lib/inets/test/httpd_SUITE_data/server_root/conf/mime.types new file mode 100644 index 0000000000..d2f81e4e5e --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/conf/mime.types @@ -0,0 +1,465 @@ +# This is a comment. I love comments. + +# MIME type Extension +application/EDI-Consent +application/EDI-X12 +application/EDIFACT +application/activemessage +application/andrew-inset ez +application/applefile +application/atomicmail +application/batch-SMTP +application/beep+xml +application/cals-1840 +application/commonground +application/cybercash +application/dca-rft +application/dec-dx +application/dvcs +application/eshop +application/http +application/hyperstudio +application/iges +application/index +application/index.cmd +application/index.obj +application/index.response +application/index.vnd +application/iotp +application/ipp +application/isup +application/font-tdpfr +application/mac-binhex40 hqx +application/mac-compactpro cpt +application/macwriteii +application/marc +application/mathematica +application/mathematica-old +application/msword doc +application/news-message-id +application/news-transmission +application/ocsp-request +application/ocsp-response +application/octet-stream bin dms lha lzh exe class so dll +application/oda oda +application/parityfec +application/pdf pdf +application/pgp-encrypted +application/pgp-keys +application/pgp-signature +application/pkcs10 +application/pkcs7-mime +application/pkcs7-signature +application/pkix-cert +application/pkix-crl +application/pkixcmp +application/postscript ai eps ps +application/prs.alvestrand.titrax-sheet +application/prs.cww +application/prs.nprend +application/qsig +application/remote-printing +application/riscos +application/rtf +application/sdp +application/set-payment +application/set-payment-initiation +application/set-registration +application/set-registration-initiation +application/sgml +application/sgml-open-catalog +application/sieve +application/slate +application/smil smi smil +application/timestamp-query +application/timestamp-reply +application/vemmi +application/vnd.3M.Post-it-Notes +application/vnd.FloGraphIt +application/vnd.accpac.simply.aso +application/vnd.accpac.simply.imp +application/vnd.acucobol +application/vnd.aether.imp +application/vnd.anser-web-certificate-issue-initiation +application/vnd.anser-web-funds-transfer-initiation +application/vnd.audiograph +application/vnd.businessobjects +application/vnd.bmi +application/vnd.canon-cpdl +application/vnd.canon-lips +application/vnd.claymore +application/vnd.commerce-battelle +application/vnd.commonspace +application/vnd.comsocaller +application/vnd.contact.cmsg +application/vnd.cosmocaller +application/vnd.cups-postscript +application/vnd.cups-raster +application/vnd.cups-raw +application/vnd.ctc-posml +application/vnd.cybank +application/vnd.dna +application/vnd.dpgraph +application/vnd.dxr +application/vnd.ecdis-update +application/vnd.ecowin.chart +application/vnd.ecowin.filerequest +application/vnd.ecowin.fileupdate +application/vnd.ecowin.series +application/vnd.ecowin.seriesrequest +application/vnd.ecowin.seriesupdate +application/vnd.enliven +application/vnd.epson.esf +application/vnd.epson.msf +application/vnd.epson.quickanime +application/vnd.epson.salt +application/vnd.epson.ssf +application/vnd.ericsson.quickcall +application/vnd.eudora.data +application/vnd.fdf +application/vnd.ffsns +application/vnd.framemaker +application/vnd.fsc.weblaunch +application/vnd.fujitsu.oasys +application/vnd.fujitsu.oasys2 +application/vnd.fujitsu.oasys3 +application/vnd.fujitsu.oasysgp +application/vnd.fujitsu.oasysprs +application/vnd.fujixerox.ddd +application/vnd.fujixerox.docuworks +application/vnd.fujixerox.docuworks.binder +application/vnd.fut-misnet +application/vnd.grafeq +application/vnd.groove-account +application/vnd.groove-identity-message +application/vnd.groove-injector +application/vnd.groove-tool-message +application/vnd.groove-tool-template +application/vnd.groove-vcard +application/vnd.hhe.lesson-player +application/vnd.hp-HPGL +application/vnd.hp-PCL +application/vnd.hp-PCLXL +application/vnd.hp-hpid +application/vnd.hp-hps +application/vnd.httphone +application/vnd.hzn-3d-crossword +application/vnd.ibm.afplinedata +application/vnd.ibm.MiniPay +application/vnd.ibm.modcap +application/vnd.informix-visionary +application/vnd.intercon.formnet +application/vnd.intertrust.digibox +application/vnd.intertrust.nncp +application/vnd.intu.qbo +application/vnd.intu.qfx +application/vnd.irepository.package+xml +application/vnd.is-xpr +application/vnd.japannet-directory-service +application/vnd.japannet-jpnstore-wakeup +application/vnd.japannet-payment-wakeup +application/vnd.japannet-registration +application/vnd.japannet-registration-wakeup +application/vnd.japannet-setstore-wakeup +application/vnd.japannet-verification +application/vnd.japannet-verification-wakeup +application/vnd.koan +application/vnd.lotus-1-2-3 +application/vnd.lotus-approach +application/vnd.lotus-freelance +application/vnd.lotus-notes +application/vnd.lotus-organizer +application/vnd.lotus-screencam +application/vnd.lotus-wordpro +application/vnd.mcd +application/vnd.mediastation.cdkey +application/vnd.meridian-slingshot +application/vnd.mif mif +application/vnd.minisoft-hp3000-save +application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf +application/vnd.mobius.dis +application/vnd.mobius.msl +application/vnd.mobius.plc +application/vnd.mobius.txf +application/vnd.motorola.flexsuite +application/vnd.motorola.flexsuite.adsi +application/vnd.motorola.flexsuite.fis +application/vnd.motorola.flexsuite.gotap +application/vnd.motorola.flexsuite.kmr +application/vnd.motorola.flexsuite.ttc +application/vnd.motorola.flexsuite.wem +application/vnd.mozilla.xul+xml +application/vnd.ms-artgalry +application/vnd.ms-asf +application/vnd.ms-excel xls +application/vnd.ms-lrm +application/vnd.ms-powerpoint ppt +application/vnd.ms-project +application/vnd.ms-tnef +application/vnd.ms-works +application/vnd.mseq +application/vnd.msign +application/vnd.music-niff +application/vnd.musician +application/vnd.netfpx +application/vnd.noblenet-directory +application/vnd.noblenet-sealer +application/vnd.noblenet-web +application/vnd.novadigm.EDM +application/vnd.novadigm.EDX +application/vnd.novadigm.EXT +application/vnd.osa.netdeploy +application/vnd.palm +application/vnd.pg.format +application/vnd.pg.osasli +application/vnd.powerbuilder6 +application/vnd.powerbuilder6-s +application/vnd.powerbuilder7 +application/vnd.powerbuilder7-s +application/vnd.powerbuilder75 +application/vnd.powerbuilder75-s +application/vnd.previewsystems.box +application/vnd.publishare-delta-tree +application/vnd.pvi.ptid1 +application/vnd.pwg-xhtml-print+xml +application/vnd.rapid +application/vnd.s3sms +application/vnd.seemail +application/vnd.shana.informed.formdata +application/vnd.shana.informed.formtemplate +application/vnd.shana.informed.interchange +application/vnd.shana.informed.package +application/vnd.sss-cod +application/vnd.sss-dtf +application/vnd.sss-ntf +application/vnd.street-stream +application/vnd.svd +application/vnd.swiftview-ics +application/vnd.triscape.mxs +application/vnd.trueapp +application/vnd.truedoc +application/vnd.tve-trigger +application/vnd.ufdl +application/vnd.uplanet.alert +application/vnd.uplanet.alert-wbxml +application/vnd.uplanet.bearer-choice-wbxml +application/vnd.uplanet.bearer-choice +application/vnd.uplanet.cacheop +application/vnd.uplanet.cacheop-wbxml +application/vnd.uplanet.channel +application/vnd.uplanet.channel-wbxml +application/vnd.uplanet.list +application/vnd.uplanet.list-wbxml +application/vnd.uplanet.listcmd +application/vnd.uplanet.listcmd-wbxml +application/vnd.uplanet.signal +application/vnd.vcx +application/vnd.vectorworks +application/vnd.vidsoft.vidconference +application/vnd.visio +application/vnd.vividence.scriptfile +application/vnd.wap.sic +application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo +application/vnd.wrq-hp3000-labelled +application/vnd.wt.stf +application/vnd.xara +application/vnd.xfdl +application/vnd.yellowriver-custom-menu +application/whoispp-query +application/whoispp-response +application/wita +application/wordperfect5.1 +application/x-bcpio bcpio +application/x-cdlink vcd +application/x-chess-pgn pgn +application/x-compress +application/x-cpio cpio +application/x-csh csh +application/x-director dcr dir dxr +application/x-dvi dvi +application/x-futuresplash spl +application/x-gtar gtar +application/x-gzip +application/x-hdf hdf +application/x-javascript js +application/x-koan skp skd skt skm +application/x-latex latex +application/x-netcdf nc cdf +application/x-sh sh +application/x-shar shar +application/x-shockwave-flash swf +application/x-stuffit sit +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-tar tar +application/x-tcl tcl +application/x-tex tex +application/x-texinfo texinfo texi +application/x-troff t tr roff +application/x-troff-man man +application/x-troff-me me +application/x-troff-ms ms +application/x-ustar ustar +application/x-wais-source src +application/x400-bp +application/xml +application/xml-dtd +application/xml-external-parsed-entity +application/zip zip +audio/32kadpcm +audio/basic au snd +audio/g.722.1 +audio/l16 +audio/midi mid midi kar +audio/mp4a-latm +audio/mpa-robust +audio/mpeg mpga mp2 mp3 +audio/parityfec +audio/prs.sid +audio/telephone-event +audio/tone +audio/vnd.cisco.nse +audio/vnd.cns.anp1 +audio/vnd.cns.inf1 +audio/vnd.digital-winds +audio/vnd.everad.plj +audio/vnd.lucent.voice +audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 +audio/vnd.nuera.ecelp7470 +audio/vnd.nuera.ecelp9600 +audio/vnd.octel.sbc +audio/vnd.qcelp +audio/vnd.rhetorex.32kadpcm +audio/vnd.vmx.cvsd +audio/x-aiff aif aiff aifc +audio/x-mpegurl m3u +audio/x-pn-realaudio ram rm +audio/x-pn-realaudio-plugin rpm +audio/x-realaudio ra +audio/x-wav wav +chemical/x-pdb pdb +chemical/x-xyz xyz +image/bmp bmp +image/cgm +image/g3fax +image/gif gif +image/ief ief +image/jpeg jpeg jpg jpe +image/naplps +image/png png +image/prs.btif +image/prs.pti +image/tiff tiff tif +image/vnd.cns.inf2 +image/vnd.dwg +image/vnd.dxf +image/vnd.fastbidsheet +image/vnd.fpx +image/vnd.fst +image/vnd.fujixerox.edmics-mmr +image/vnd.fujixerox.edmics-rlc +image/vnd.mix +image/vnd.net-fpx +image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff +image/x-cmu-raster ras +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd +message/delivery-status +message/disposition-notification +message/external-body +message/http +message/news +message/partial +message/rfc822 +message/s-http +model/iges igs iges +model/mesh msh mesh silo +model/vnd.dwf +model/vnd.flatland.3dml +model/vnd.gdl +model/vnd.gs-gdl +model/vnd.gtw +model/vnd.mts +model/vnd.vtu +model/vrml wrl vrml +multipart/alternative +multipart/appledouble +multipart/byteranges +multipart/digest +multipart/encrypted +multipart/form-data +multipart/header-set +multipart/mixed +multipart/parallel +multipart/related +multipart/report +multipart/signed +multipart/voice-message +text/calendar +text/css css +text/directory +text/enriched +text/html html htm +text/parityfec +text/plain asc txt +text/prs.lines.tag +text/rfc822-headers +text/richtext rtx +text/rtf rtf +text/sgml sgml sgm +text/tab-separated-values tsv +text/t140 +text/uri-list +text/vnd.DMClientScript +text/vnd.IPTC.NITF +text/vnd.IPTC.NewsML +text/vnd.abc +text/vnd.curl +text/vnd.flatland.3dml +text/vnd.fly +text/vnd.fmi.flexstor +text/vnd.in3d.3dml +text/vnd.in3d.spot +text/vnd.latex-z +text/vnd.motorola.reflex +text/vnd.ms-mediapackage +text/vnd.wap.si +text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-setext etx +text/x-server-parsed-html shtml +text/xml xml xsl +text/xml-external-parsed-entity +video/mp4v-es +video/mpeg mpeg mpg mpe +video/parityfec +video/pointer +video/quicktime qt mov +video/vnd.fvt +video/vnd.motorola.video +video/vnd.motorola.videop +video/vnd.mpegurl mxu +video/vnd.mts +video/vnd.nokia.interleaved-multimedia +video/vnd.vivo +video/x-msvideo avi +video/x-sgi-movie movie +x-conference/x-cooltalk ice + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/conf/ssl.conf b/lib/inets/test/httpd_SUITE_data/server_root/conf/ssl.conf new file mode 100644 index 0000000000..8b8c57a98b --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/conf/ssl.conf @@ -0,0 +1,66 @@ +Port 8088 +#ServerName your.server.net +SocketType ssl +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log +ServerAdmin [email protected] +ServerRoot /var/tmp/server_root +ErrorLog logs/error_log_8088 +TransferLog logs/access_log_8088 +ErrorDiskLog logs/error_disk_log_8088 +ErrorDiskLogSize 200000 10 +TransferDiskLog logs/access_disk_log_8088 +TransferDiskLogSize 200000 10 +MaxClients 150 +DocumentRoot /var/tmp/server_root/htdocs +DirectoryIndex index.html welcome.html +DefaultType text/plain +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ +ErlScriptAlias /cgi-bin/erl httpd_example io +EvalScriptAlias /eval httpd_example io +SSLCertificateFile /var/tmp/server_root/ssl/ssl_server.pem +SSLCertificateKeyFile /var/tmp/server_root/ssl/ssl_server.pem +SSLVerifyClient 0 +#Script HEAD /cgi-bin/printenv.sh +#Action image/gif /cgi-bin/printenv.sh + +<Directory /var/tmp/server_root/htdocs/open> +AuthName Open Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret> +AuthName Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret/top_secret> +AuthName Top Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group3 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_open> +AuthName Open Area +AuthMnesiaDB On +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret> +AuthName Secret Area +AuthMnesiaDB On +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret/top_secret> +AuthName Top Secret Area +AuthMnesiaDB On +require group group3 +</Directory> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/config.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/config.shtml new file mode 100644 index 0000000000..107e3ff610 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/config.shtml @@ -0,0 +1,70 @@ +<HTML> +<HEAD> +<TITLE>/ssi.html (17-Apr-1997)</TITLE> +</HEAD> +<BODY> +<H1>/ssi.html</H1> + +<!-- ************* CONFIG ************* --> + +<!--#config timefmt="%a %b %e %T %Z %Y" sizefmt="abbrev"--> +<!--#config errmsg="[an especially ugly error occurred while processing this directive]"--> + +<!-- ************* INCLUDE ************* --> + +<P>Include /misc/friedrich.html: +<!--#include virtual="/misc/friedrich.html"--> +<P>Include /misc/not_defined.html: <!--#include virtual="/misc/not_defined.html"--> +<P>Include misc/friedrich.html: +<!--#include file="misc/friedrich.html"--> +<P>Include not_defined.html: <!--#include file="not_defined.html"--> + +<P><HR> + +<!-- ************* ECHO ************* --> + +<P>DOCUMENT_NAME: <!--#echo var="DOCUMENT_NAME"--> +<P>DOCUMENT_URI: <!--#echo var="DOCUMENT_URI"--> +<P>QUERY_STRING_UNESCAPED: <!--#echo var="QUERY_STRING_UNESCAPED"--> +<P>DATE_LOCAL: <!--#echo var="DATE_LOCAL"--> +<P>DATE_GMT: <!--#echo var="DATE_GMT"--> +<P>LAST_MODIFIED: <!--#echo var="LAST_MODIFIED"--> +<P>NOT_DEFINED: <!--#echo var="NOT_DEFINED"--> + +<P><HR> + +<!-- ************* FSIZE ************* --> + +<P>Size of index.html: <!--#fsize file="index.html"--> +<P>Size of not_defined.html: <!--#fsize file="not_defined.html"--> +<!--#config sizefmt="bytes"--> +<P>Size of /misc/friedrich.html: <!--#fsize virtual="/misc/friedrich.html"--> +<P>Size of /misc/not_defined.html: <!--#fsize virtual="/misc/not_defined.html"--> + +<P><HR> + +<!-- ************* FLASTMOD ************* --> + +<P>Last modification of index.html: <!--#flastmod file="index.html"--> +<P>Last modification of not_defined.html: <!--#flastmod file="not_defined.html"--> +<P>Last modification of /misc/friedrich.html: <!--#flastmod virtual="/misc/friedrich.html"--> +<P>Last modification of /misc/not_defined.html: <!--#flastmod virtual="/misc/not_defined.html"--> + +<!--#exec cmd="ls"--> +<!--#exec cmd="printenv"--> +<!--#exec cmd="sunemaja"--> + +<!--#exec cgi="/cgi-bin/printenv.sh"--> + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_open/dummy.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_open/dummy.html new file mode 100644 index 0000000000..a6e8a35a04 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_open/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/open/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/open/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_secret/dummy.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_secret/dummy.html new file mode 100644 index 0000000000..016b04e540 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_secret/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/secret/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/secret/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_secret/top_secret/index.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_secret/top_secret/index.html new file mode 100644 index 0000000000..34db3d5d1a --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/dets_secret/top_secret/index.html @@ -0,0 +1,9 @@ +<HTML> +<HEAD> +<TITLE>/secret/top_secret/index.html (04-Feb-1998)</TITLE> +<!-- Created by: Mattias Nilsson, 04-Feb-1998 --> +</HEAD> +<BODY> +<H1>/secret/top_secret/index.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/echo.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/echo.shtml new file mode 100644 index 0000000000..141db5be59 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/echo.shtml @@ -0,0 +1,35 @@ +<HTML> +<HEAD> +<TITLE>/echo.shtml</TITLE> +</HEAD> +<BODY> +<H1>/echo.shtml</H1> + +<P>DOCUMENT_NAME: <!--#echo var="DOCUMENT_NAME"--> + +<P>DOCUMENT_URI: <!--#echo var="DOCUMENT_URI"--> + +<P>QUERY_STRING_UNESCAPED: <!--#echo var="QUERY_STRING_UNESCAPED"--> + +<P>DATE_LOCAL: <!--#echo var="DATE_LOCAL"--> + +<P>DATE_GMT: <!--#echo var="DATE_GMT"--> + +<P>LAST_MODIFIED: <!--#echo var="LAST_MODIFIED"--> + +<P>NOT_DEFINED: <!--#echo var="NOT_DEFINED"--> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/exec.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/exec.shtml new file mode 100644 index 0000000000..97333da898 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/exec.shtml @@ -0,0 +1,30 @@ +<HTML> +<HEAD> +<TITLE>/exec.shtml</TITLE> +</HEAD> +<BODY> +<H1>/exec.shtml</H1> +<PRE> +<!--#exec cmd="ls"--> +<HR> +<!--#exec cmd="printenv"--> +<HR> +<!--#exec cmd="sunemaja"--> +<HR> +<!--#exec cgi="/cgi-bin/printenv.sh"--> +</PRE> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/flastmod.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/flastmod.shtml new file mode 100644 index 0000000000..d54c36fe50 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/flastmod.shtml @@ -0,0 +1,29 @@ +<HTML> +<HEAD> +<TITLE>/flastmod.shtml</TITLE> +</HEAD> +<BODY> +<H1>/flastmod.shtml</H1> + +<P>Last modification of index.html: <!--#flastmod file="index.html"--> + +<P>Last modification of not_defined.html: <!--#flastmod file="not_defined.html"--> + +<P>Last modification of /misc/friedrich.html: <!--#flastmod virtual="/misc/friedrich.html"--> + +<P>Last modification of /misc/not_defined.html: <!--#flastmod virtual="/misc/not_defined.html"--> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/fsize.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/fsize.shtml new file mode 100644 index 0000000000..570ee9cf6d --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/fsize.shtml @@ -0,0 +1,29 @@ +<HTML> +<HEAD> +<TITLE>/fsize.shtml</TITLE> +</HEAD> +<BODY> +<H1>/fsize.shtml</H1> + +<P>Size of index.html: <!--#fsize file="index.html"--> + +<P>Size of not_defined.html: <!--#fsize file="not_defined.html"--> + +<P>Size of /misc/friedrich.html: <!--#fsize virtual="/misc/friedrich.html"--> + +<P>Size of /misc/not_defined.html: <!--#fsize virtual="/misc/not_defined.html"--> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/include.shtml b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/include.shtml new file mode 100644 index 0000000000..529aad0437 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/include.shtml @@ -0,0 +1,33 @@ +<HTML> +<HEAD> +<TITLE>/include.shtml</TITLE> +</HEAD> +<BODY> +<H1>/include.shtml</H1> + +<P>Include /misc/friedrich.html: +<!--#include virtual="/misc/friedrich.html"--> + +<P>Include /misc/not_defined.html: +<!--#include virtual="/misc/not_defined.html"--> + +<P>Include misc/friedrich.html: +<!--#include file="misc/friedrich.html"--> + +<P>Include not_defined.html: +<!--#include file="not_defined.html"--> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/index.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/index.html new file mode 100644 index 0000000000..cfdc9f9ab7 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/index.html @@ -0,0 +1,25 @@ +<HTML> +<HEAD> +<TITLE>/index.html</TITLE> +</HEAD> +<BODY> +<H1>/index.html</H1> + +<STRONG>Server-Side Include (SSI) commands:</STRONG><BR> +<A HREF="config.shtml">config</A><BR> +<A HREF="echo.shtml">echo</A><BR> +<A HREF="exec.shtml">exec</A><BR> +<A HREF="flastmod.shtml">flastmod</A><BR> +<A HREF="fsize.shtml">fsize</A><BR> +<A HREF="include.shtml">include</A><BR> + +<BR> +<BR> + +<STRONG>ESI callback:</STRING><BR> +<A HREF="cgi-bin/erl/httpd_example/get">cgi-bin/erl/httpd_example/get</A><BR> +<A HREF="cgi-bin/erl/httpd_example/yahoo">cgi-bin/erl/httpd_example/yahoo</A><BR> +<A HREF="cgi-bin/erl/httpd_example/test1">cgi-bin/erl/httpd_example/test1</A><BR> + +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/last_modified.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/last_modified.html new file mode 100644 index 0000000000..65c1790813 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/last_modified.html @@ -0,0 +1,22 @@ +<HTML> +<HEAD> +<TITLE>/last_modified.html</TITLE> +</HEAD> +<BODY> +<H1>/last_modified.html</H1> + +<P>This document is only used for test of illegal last-modified date.</P> + + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/friedrich.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/friedrich.html new file mode 100644 index 0000000000..d7953d5df4 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/friedrich.html @@ -0,0 +1,7 @@ +<P><CITE> +Talking much about oneself can also be a means to conceal oneself.<BR> +-- Friedrich Nietzsche +</CITE> + +<P>Nested Include: +<!--#include file="misc/oech.html"--> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/oech.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/oech.html new file mode 100644 index 0000000000..506064bf04 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/oech.html @@ -0,0 +1,4 @@ +<P><CITE> +What excuses stand in your way? How can you eliminate them?<BR> +-- Roger von Oech +</CITE> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/welcome.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/welcome.html new file mode 100644 index 0000000000..8c17451f91 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/misc/welcome.html @@ -0,0 +1 @@ +<HTML></HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_open/dummy.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_open/dummy.html new file mode 100644 index 0000000000..a6e8a35a04 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_open/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/open/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/open/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_secret/dummy.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_secret/dummy.html new file mode 100644 index 0000000000..016b04e540 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_secret/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/secret/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/secret/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_secret/top_secret/index.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_secret/top_secret/index.html new file mode 100644 index 0000000000..2d17e8b596 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/mnesia_secret/top_secret/index.html @@ -0,0 +1,9 @@ +<HTML> +<HEAD> +<TITLE>/mnesia_secret/top_secret/index.html (04-Feb-1998)</TITLE> +<!-- Created by: Mattias Nilsson, 04-Feb-1998 --> +</HEAD> +<BODY> +<H1>/mnesia_secret/top_secret/index.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/open/dummy.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/open/dummy.html new file mode 100644 index 0000000000..a6e8a35a04 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/open/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/open/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/open/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/secret/dummy.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/secret/dummy.html new file mode 100644 index 0000000000..016b04e540 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/secret/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/secret/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/secret/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/secret/top_secret/index.html b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/secret/top_secret/index.html new file mode 100644 index 0000000000..34db3d5d1a --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/secret/top_secret/index.html @@ -0,0 +1,9 @@ +<HTML> +<HEAD> +<TITLE>/secret/top_secret/index.html (04-Feb-1998)</TITLE> +<!-- Created by: Mattias Nilsson, 04-Feb-1998 --> +</HEAD> +<BODY> +<H1>/secret/top_secret/index.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/README b/lib/inets/test/httpd_SUITE_data/server_root/icons/README new file mode 100644 index 0000000000..a1fc5a5a9c --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/README @@ -0,0 +1,161 @@ +Public Domain Icons + + These icons were originally made for Mosaic for X and have been + included in the NCSA httpd and Apache server distributions in the + past. They are in the public domain and may be freely included in any + application. The originals were done by Kevin Hughes ([email protected]). + + Many thanks to Andy Polyakov for tuning the icon colors and adding a + few new images. If you'd like to contribute additions or ideas to + this set, please let me know. + + The distribution site for these icons is at: + + http://www.eit.com/goodies/www.icons/ + + Kevin Hughes + September 11, 1995 + + +Suggested Uses + +The following are a few suggestions, to serve as a starting point for ideas. +Please feel free to tweak and rename the icons as you like. + + a.gif + This might be used to represent PostScript or text layout + languages. + + alert.black.gif, alert.red.gif + These can be used to highlight any important items, such as a + README file in a directory. + + back.gif, forward.gif + These can be used as links to go to previous and next areas. + + ball.gray.gif, ball.red.gif + These might be used as bullets. + + binary.gif + This can be used to represent binary files. + + binhex.gif + This can represent BinHex-encoded data. + + blank.gif + This can be used as a placeholder or a spacing element. + + bomb.gif + This can be used to repreesnt core files. + + box1.gif, box2.gif + These icons can be used to represent generic 3D applications and + related files. + + broken.gif + This can represent corrupted data. + + burst.gif + This can call attention to new and important items. + + c.gif + This might represent C source code. + + comp.blue.gif, comp.red.gif + These little computer icons can stand for telnet or FTP + sessions. + + compressed.gif + This may represent compressed data. + + continued.gif + This can be a link to a continued listing of a directory. + + down.gif, up.gif, left.gif, right.gif + These can be used to scroll up, down, left and right in a + listing or may be used to denote items in an outline. + + dvi.gif + This can represent DVI files. + + f.gif + This might represent FORTRAN or Forth source code. + + folder.gif, folder.open.gif, folder.sec.gif + The folder can represent directories. There is also a version + that can represent secure directories or directories that cannot + be viewed. + + generic.gif, generic.sec.gif, generic.red.gif + These can represent generic files, secure files, and important + files, respectively. + + hand.right.gif, hand.up.gif + These can point out important items (pun intended). + + image1.gif, image2.gif, image3.gif + These can represent image formats of various types. + + index.gif + This might represent a WAIS index or search facility. + + layout.gif + This might represent files and formats that contain graphics as + well as text layout, such as HTML and PDF files. + + link.gif + This might represent files that are symbolic links. + + movie.gif + This can represent various movie formats. + + p.gif + This may stand for Perl or Python source code. + + pie0.gif ... pie8.gif + These icons can be used in applications where a list of + documents is returned from a search. The little pie chart images + can denote how relevant the documents may be to your search + query. + + patch.gif + This may stand for patches and diff files. + + portal.gif + This might be a link to an online service or a 3D world. + + ps.gif, quill.gif + These may represent PostScript files. + + screw1.gif, screw2.gif + These may represent CAD or engineering data and formats. + + script.gif + This can represent any of various interpreted languages, such as + Perl, python, TCL, and shell scripts, as well as server + configuration files. + + sound1.gif, sound2.gif + These can represent sound files. + + sphere1.gif, sphere2.gif + These can represent 3D worlds or rendering applications and + formats. + + tex.gif + This can represent TeX files. + + text.gif + This can represent generic (plain) text files. + + transfer.gif + This can represent FTP transfers or uploads/downloads. + + unknown.gif + This may represent a file of an unknown type. + + uuencoded.gif + This can stand for uuencoded data. + + world1.gif, world2.gif + These can represent 3D worlds or other 3D formats. diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/a.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/a.gif Binary files differnew file mode 100644 index 0000000000..bb23d971f4 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/a.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/alert.black.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/alert.black.gif Binary files differnew file mode 100644 index 0000000000..eaecd2172a --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/alert.black.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/alert.red.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/alert.red.gif Binary files differnew file mode 100644 index 0000000000..a423894043 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/alert.red.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/apache_pb.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/apache_pb.gif Binary files differnew file mode 100644 index 0000000000..3a1c139fc4 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/apache_pb.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/back.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/back.gif Binary files differnew file mode 100644 index 0000000000..a694ae1ec3 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/back.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/ball.gray.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/ball.gray.gif Binary files differnew file mode 100644 index 0000000000..eb84268c4c --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/ball.gray.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/ball.red.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/ball.red.gif Binary files differnew file mode 100644 index 0000000000..a8425cb574 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/ball.red.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/binary.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/binary.gif Binary files differnew file mode 100644 index 0000000000..9a15cbae04 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/binary.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/binhex.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/binhex.gif Binary files differnew file mode 100644 index 0000000000..62d0363108 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/binhex.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/blank.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/blank.gif Binary files differnew file mode 100644 index 0000000000..0ccf01e198 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/blank.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/bomb.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/bomb.gif Binary files differnew file mode 100644 index 0000000000..270fdb1c06 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/bomb.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/box1.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/box1.gif Binary files differnew file mode 100644 index 0000000000..65dcd002ea --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/box1.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/box2.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/box2.gif Binary files differnew file mode 100644 index 0000000000..c43bc4faec --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/box2.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/broken.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/broken.gif Binary files differnew file mode 100644 index 0000000000..9f8cbe9f76 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/broken.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/burst.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/burst.gif Binary files differnew file mode 100644 index 0000000000..fbdcf575f7 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/burst.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button1.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button1.gif Binary files differnew file mode 100644 index 0000000000..eb97cb7333 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button1.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button10.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button10.gif Binary files differnew file mode 100644 index 0000000000..fe0c97998c --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button10.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button2.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button2.gif Binary files differnew file mode 100644 index 0000000000..7698455bf9 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button2.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button3.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button3.gif Binary files differnew file mode 100644 index 0000000000..a8b8319232 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button3.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button4.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button4.gif Binary files differnew file mode 100644 index 0000000000..0fd15a0d7f --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button4.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button5.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button5.gif Binary files differnew file mode 100644 index 0000000000..64241e5c5d --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button5.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button6.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button6.gif Binary files differnew file mode 100644 index 0000000000..867cfd1212 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button6.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button7.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button7.gif Binary files differnew file mode 100644 index 0000000000..b3f5fb248f --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button7.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button8.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button8.gif Binary files differnew file mode 100644 index 0000000000..7a308be8f6 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button8.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/button9.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/button9.gif Binary files differnew file mode 100644 index 0000000000..9acba576c0 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/button9.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/buttonl.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/buttonl.gif Binary files differnew file mode 100644 index 0000000000..3883088e7a --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/buttonl.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/buttonr.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/buttonr.gif Binary files differnew file mode 100644 index 0000000000..c4dc3887db --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/buttonr.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/c.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/c.gif Binary files differnew file mode 100644 index 0000000000..7555b6c164 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/c.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/comp.blue.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/comp.blue.gif Binary files differnew file mode 100644 index 0000000000..f8d76a8c23 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/comp.blue.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/comp.gray.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/comp.gray.gif Binary files differnew file mode 100644 index 0000000000..7664cd0364 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/comp.gray.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/compressed.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/compressed.gif Binary files differnew file mode 100644 index 0000000000..39e732739f --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/compressed.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/continued.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/continued.gif Binary files differnew file mode 100644 index 0000000000..b0ffb7e0cc --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/continued.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/dir.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/dir.gif Binary files differnew file mode 100644 index 0000000000..48264601ae --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/dir.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/down.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/down.gif Binary files differnew file mode 100644 index 0000000000..a354c871cd --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/down.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/dvi.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/dvi.gif Binary files differnew file mode 100644 index 0000000000..791be33105 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/dvi.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/f.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/f.gif Binary files differnew file mode 100644 index 0000000000..fbe353c282 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/f.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.gif Binary files differnew file mode 100644 index 0000000000..48264601ae --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.open.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.open.gif Binary files differnew file mode 100644 index 0000000000..30979cb528 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.open.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.sec.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.sec.gif Binary files differnew file mode 100644 index 0000000000..75332d9e59 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/folder.sec.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/forward.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/forward.gif Binary files differnew file mode 100644 index 0000000000..b2959b4c85 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/forward.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.gif Binary files differnew file mode 100644 index 0000000000..de60b2940f --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.red.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.red.gif Binary files differnew file mode 100644 index 0000000000..94743981d9 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.red.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.sec.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.sec.gif Binary files differnew file mode 100644 index 0000000000..88d5240c3c --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/generic.sec.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/hand.right.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/hand.right.gif Binary files differnew file mode 100644 index 0000000000..5cdbc7206d --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/hand.right.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/hand.up.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/hand.up.gif Binary files differnew file mode 100644 index 0000000000..85a5d68317 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/hand.up.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/htdig.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/htdig.gif Binary files differnew file mode 100644 index 0000000000..35443fb63a --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/htdig.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/icon.sheet.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/icon.sheet.gif Binary files differnew file mode 100644 index 0000000000..ad1686e448 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/icon.sheet.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/image1.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/image1.gif Binary files differnew file mode 100644 index 0000000000..01e442bfa9 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/image1.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/image2.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/image2.gif Binary files differnew file mode 100644 index 0000000000..751faeea36 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/image2.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/image3.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/image3.gif Binary files differnew file mode 100644 index 0000000000..4f30484ff6 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/image3.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/index.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/index.gif Binary files differnew file mode 100644 index 0000000000..162478fb3a --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/index.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/layout.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/layout.gif Binary files differnew file mode 100644 index 0000000000..c96338a152 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/layout.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/left.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/left.gif Binary files differnew file mode 100644 index 0000000000..279e6710d4 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/left.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/link.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/link.gif Binary files differnew file mode 100644 index 0000000000..c5b6889a76 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/link.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/movie.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/movie.gif Binary files differnew file mode 100644 index 0000000000..0035183774 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/movie.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/p.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/p.gif Binary files differnew file mode 100644 index 0000000000..7b917b4e91 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/p.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/patch.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/patch.gif Binary files differnew file mode 100644 index 0000000000..39bc90e795 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/patch.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pdf.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pdf.gif Binary files differnew file mode 100644 index 0000000000..c88fd777c4 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pdf.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie0.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie0.gif Binary files differnew file mode 100644 index 0000000000..6f7a0ae7a7 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie0.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie1.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie1.gif Binary files differnew file mode 100644 index 0000000000..03aa6be71e --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie1.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie2.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie2.gif Binary files differnew file mode 100644 index 0000000000..b04c5e0908 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie2.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie3.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie3.gif Binary files differnew file mode 100644 index 0000000000..4db9d023ed --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie3.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie4.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie4.gif Binary files differnew file mode 100644 index 0000000000..93471fdd88 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie4.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie5.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie5.gif Binary files differnew file mode 100644 index 0000000000..57aee93f07 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie5.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie6.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie6.gif Binary files differnew file mode 100644 index 0000000000..0dc327b569 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie6.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie7.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie7.gif Binary files differnew file mode 100644 index 0000000000..8661337f06 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie7.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/pie8.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie8.gif Binary files differnew file mode 100644 index 0000000000..59ddb34ce0 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/pie8.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/portal.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/portal.gif Binary files differnew file mode 100644 index 0000000000..0e6e506e00 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/portal.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/poweredby.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/poweredby.gif Binary files differnew file mode 100644 index 0000000000..d324ab80ea --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/poweredby.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/ps.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/ps.gif Binary files differnew file mode 100644 index 0000000000..0f565bc1db --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/ps.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/quill.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/quill.gif Binary files differnew file mode 100644 index 0000000000..818a5cdc7e --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/quill.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/right.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/right.gif Binary files differnew file mode 100644 index 0000000000..b256e5f75f --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/right.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/screw1.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/screw1.gif Binary files differnew file mode 100644 index 0000000000..af6ba2b097 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/screw1.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/screw2.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/screw2.gif Binary files differnew file mode 100644 index 0000000000..06dccb3e44 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/screw2.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/script.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/script.gif Binary files differnew file mode 100644 index 0000000000..d8a853bc58 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/script.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/sound1.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/sound1.gif Binary files differnew file mode 100644 index 0000000000..8efb49f55d --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/sound1.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/sound2.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/sound2.gif Binary files differnew file mode 100644 index 0000000000..48e6a7fb2f --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/sound2.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/sphere1.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/sphere1.gif Binary files differnew file mode 100644 index 0000000000..7067070da2 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/sphere1.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/sphere2.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/sphere2.gif Binary files differnew file mode 100644 index 0000000000..a9e462a377 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/sphere2.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/star.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/star.gif Binary files differnew file mode 100644 index 0000000000..4cfe0a5e0f --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/star.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/star_blank.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/star_blank.gif Binary files differnew file mode 100644 index 0000000000..a0c83cb85b --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/star_blank.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/tar.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/tar.gif Binary files differnew file mode 100644 index 0000000000..617e779efa --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/tar.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/tex.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/tex.gif Binary files differnew file mode 100644 index 0000000000..45e43233b8 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/tex.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/text.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/text.gif Binary files differnew file mode 100644 index 0000000000..4c623909fb --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/text.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/transfer.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/transfer.gif Binary files differnew file mode 100644 index 0000000000..33697dbb66 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/transfer.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/unknown.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/unknown.gif Binary files differnew file mode 100644 index 0000000000..32b1ea23fb --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/unknown.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/up.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/up.gif Binary files differnew file mode 100644 index 0000000000..6d6d6d1ebf --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/up.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/uu.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/uu.gif Binary files differnew file mode 100644 index 0000000000..4387d529f6 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/uu.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/uuencoded.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/uuencoded.gif Binary files differnew file mode 100644 index 0000000000..4387d529f6 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/uuencoded.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/world1.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/world1.gif Binary files differnew file mode 100644 index 0000000000..05b4ec2058 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/world1.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/icons/world2.gif b/lib/inets/test/httpd_SUITE_data/server_root/icons/world2.gif Binary files differnew file mode 100644 index 0000000000..e3203f7a88 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/icons/world2.gif diff --git a/lib/inets/test/httpd_SUITE_data/server_root/logs/Dummy_File_Needed_By_WinZip b/lib/inets/test/httpd_SUITE_data/server_root/logs/Dummy_File_Needed_By_WinZip new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/logs/Dummy_File_Needed_By_WinZip @@ -0,0 +1 @@ + diff --git a/lib/inets/test/httpd_SUITE_data/server_root/ssl/ssl_client.pem b/lib/inets/test/httpd_SUITE_data/server_root/ssl/ssl_client.pem new file mode 100644 index 0000000000..8221139eb4 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/ssl/ssl_client.pem @@ -0,0 +1,22 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBPAIBAAJBAL6Ym/bgUvhhnPkw08sggGg8Tnp759ThGMEjkmDzhuJ3w3PfnF65 +mgHcgunku4G6LxAQfEUougJWf9Phmjj3oRUCAwEAAQJBAKMjvVvzZxFzfAlP4flc +OI0AEayFokp04dtvtzuFN09f+aBo2dP18xHmKLCZvxrBOaRAROoQYscALiIVpN07 +GAECIQDfi+sSfAFaDlT3vzpL3xE5UEH6IzY8jWpaZfM1QaToJQIhANpEF50H4wGO +8Sbh7dUutNd+s+NYUjsMySW2DjLKMsoxAiEAzzb2ftrdsempD0F+O0gZwiPIFKLB +Kp33YLYyHEKuJtUCIDGi+pvDh2R7VWw6RRQOIyI+tjolg83aAoSI+oGiahqBAiEA +xzmNNajwoaokvWvlaz0na8rhxu45grOvDrflBT9XvSQ= +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICDDCCAbYCAQAwDQYJKoZIhvcNAQEEBQAwgZAxCzAJBgNVBAYTAlNFMRIwEAYD +VQQIEwlTdG9ja2hvbG0xDzANBgNVBAcTBkFsdnNqbzEMMAoGA1UEChMDRVRYMQ4w +DAYDVQQLEwVETi9TUDEXMBUGA1UEAxMOSm9ha2ltIEdyZWJlbm8xJTAjBgkqhkiG +9w0BCQEWFmpvY2tlQGVyaXguZXJpY3Nzb24uc2UwHhcNOTcwNzE1MTUzNDM2WhcN +MDMwMjIyMTUzNDM2WjCBkDELMAkGA1UEBhMCU0UxEjAQBgNVBAgTCVN0b2NraG9s +bTEPMA0GA1UEBxMGQWx2c2pvMQwwCgYDVQQKEwNFVFgxDjAMBgNVBAsTBUROL1NQ +MRcwFQYDVQQDEw5Kb2FraW0gR3JlYmVubzElMCMGCSqGSIb3DQEJARYWam9ja2VA +ZXJpeC5lcmljc3Nvbi5zZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC+mJv24FL4 +YZz5MNPLIIBoPE56e+fU4RjBI5Jg84bid8Nz35xeuZoB3ILp5LuBui8QEHxFKLoC +Vn/T4Zo496EVAgMBAAEwDQYJKoZIhvcNAQEEBQADQQBYxQVfTydyZCE0UXvZd7Ei +josNsAaWJk9fFIJaG9uyXCEfg2dVgoT2eBk3D9DI+7OB+78isM5CVlFbL7hilvP8 +-----END CERTIFICATE----- diff --git a/lib/inets/test/httpd_SUITE_data/server_root/ssl/ssl_server.pem b/lib/inets/test/httpd_SUITE_data/server_root/ssl/ssl_server.pem new file mode 100644 index 0000000000..fe739c15f7 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/ssl/ssl_server.pem @@ -0,0 +1,22 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBOwIBAAJBAL9Bozj3BIjL5Cy8b3rjMT2kPZRychX4wz9bHoIIiKnKo1xXHYjw +g3N9zWM1f1ZzMADwVry1uAInA8q09+7hL20CAwEAAQJACwu2ao7RozjrV64WXimK +6X131P/7GMvCMwGHNIlbozqoOqmZcYrbKaF61l+XuwA2QvTo3ywW1Ivxcyr6TeAr +PQIhAOX+WXT6yiqqwjt08kjBCJyMgfZtdAO6pc/6pKjNWiZfAiEA1OH1iPW/OQe5 +tlQXpiRVdLyneNsPygPRJc4Bdwu3hbMCIQDbI5pA56QxOzqOREOGJsb5wrciAfAE +jZbnr72sSN2YqQIgAWFpvzagw9Tp/mWzNY+cwkIK7/yzsIKv04fveH8p9IMCIQCr +td4IiukeUwXmPSvYM4uCE/+J89wEL9qU8Mlc3gDLXA== +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICDDCCAbYCAQAwDQYJKoZIhvcNAQEEBQAwgZAxCzAJBgNVBAYTAlNFMRIwEAYD +VQQIEwlTdG9ja2hvbG0xDzANBgNVBAcTBkFsdnNqbzEMMAoGA1UEChMDRVRYMQ4w +DAYDVQQLEwVETi9TUDEXMBUGA1UEAxMOSm9ha2ltIEdyZWJlbm8xJTAjBgkqhkiG +9w0BCQEWFmpvY2tlQGVyaXguZXJpY3Nzb24uc2UwHhcNOTcwNzE1MTUzMzQxWhcN +MDMwMjIyMTUzMzQxWjCBkDELMAkGA1UEBhMCU0UxEjAQBgNVBAgTCVN0b2NraG9s +bTEPMA0GA1UEBxMGQWx2c2pvMQwwCgYDVQQKEwNFVFgxDjAMBgNVBAsTBUROL1NQ +MRcwFQYDVQQDEw5Kb2FraW0gR3JlYmVubzElMCMGCSqGSIb3DQEJARYWam9ja2VA +ZXJpeC5lcmljc3Nvbi5zZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC/QaM49wSI +y+QsvG964zE9pD2UcnIV+MM/Wx6CCIipyqNcVx2I8INzfc1jNX9WczAA8Fa8tbgC +JwPKtPfu4S9tAgMBAAEwDQYJKoZIhvcNAQEEBQADQQAmXDY1CyJjzvQZX442kkHG +ic9QFY1UuVfzokzNMwlHYl1Qx9zaodx0cJCrcH5GF9O9LJbhhV77LzoxT1Q5wZp5 +-----END CERTIFICATE----- diff --git a/lib/inets/test/httpd_basic_SUITE.erl b/lib/inets/test/httpd_basic_SUITE.erl new file mode 100644 index 0000000000..f86c1fcb49 --- /dev/null +++ b/lib/inets/test/httpd_basic_SUITE.erl @@ -0,0 +1,136 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2007-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(httpd_basic_SUITE). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +all(doc) -> + ["Basic test of httpd."]; + +all(suite) -> + [ + uri_too_long_414, + header_too_long_413 + ]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + ok = inets:start(), + PrivDir = ?config(priv_dir, Config), + HttpdConf = [{port, 0}, {ipfamily, inet}, + {server_name, "httpd_test"}, {server_root, PrivDir}, + {document_root, PrivDir}, {bind_address, "localhost"}], + [{httpd_conf, HttpdConf} | Config]. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + inets:stop(), + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(Case, Config) -> Config +% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(Case, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(_, Config) -> + Config. + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +uri_too_long_414(doc) -> + ["Test that too long uri's get 414 HTTP code"]; +uri_too_long_414(suite) -> + []; +uri_too_long_414(Config) when is_list(Config) -> + HttpdConf = ?config(httpd_conf, Config), + {ok, Pid} = inets:start(httpd, [{port, 0}, {max_uri_size, 10} + | HttpdConf]), + Info = httpd:info(Pid), + Port = proplists:get_value(port, Info), + Address = proplists:get_value(bind_address, Info), + ok = httpd_test_lib:verify_request(ip_comm, Address, Port, node(), + "GET /morethantenchars " + "HTTP/1.1\r\n\r\n", + [{statuscode, 414}, + %% Server will send lowest version + %% as it will not get to the + %% client version + %% before aborting + {version, "HTTP/0.9"}]), + inets:stop(httpd, Pid). + +header_too_long_413(doc) -> + ["Test that too long headers's get 413 HTTP code"]; +header_too_long_413(suite) -> + []; +header_too_long_413(Config) when is_list(Config) -> + HttpdConf = ?config(httpd_conf, Config), + {ok, Pid} = inets:start(httpd, [{port, 0}, {max_header_size, 10} + | HttpdConf]), + Info = httpd:info(Pid), + Port = proplists:get_value(port, Info), + Address = proplists:get_value(bind_address, Info), + ok = httpd_test_lib:verify_request(ip_comm, Address, Port, node(), + "GET index.html " + "HTTP/1.1\r\n" + "Connection:close \r\n\r\n ", + [{statuscode, 413}, + {version, "HTTP/1.1"}]), + inets:stop(httpd, Pid). + + + + diff --git a/lib/inets/test/httpd_block.erl b/lib/inets/test/httpd_block.erl new file mode 100644 index 0000000000..f967d8172a --- /dev/null +++ b/lib/inets/test/httpd_block.erl @@ -0,0 +1,299 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(httpd_block). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +%% General testcases bodies called from httpd_SUITE +-export([block_disturbing_idle/4, block_non_disturbing_idle/4, + block_503/4, block_disturbing_active/4, + block_non_disturbing_active/4, + block_disturbing_active_timeout_not_released/4, + block_disturbing_active_timeout_released/4, + block_non_disturbing_active_timeout_not_released/4, + block_non_disturbing_active_timeout_released/4, + disturbing_blocker_dies/4, + non_disturbing_blocker_dies/4, restart_no_block/4, + restart_disturbing_block/4, restart_non_disturbing_block/4 + ]). + +%% Help functions +-export([do_block_server/4, do_block_nd_server/5, do_long_poll/6]). + +-define(report(Label, Content), + inets:report_event(20, Label, test_case, + [{module, ?MODULE}, {line, ?LINE} | Content])). + + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +block_disturbing_idle(_Type, Port, Host, Node) -> + unblocked = get_admin_state(Node, Host, Port), + block_server(Node, Host, Port), + blocked = get_admin_state(Node, Host, Port), + unblock_server(Node, Host, Port), + unblocked = get_admin_state(Node, Host, Port). +%%-------------------------------------------------------------------- +block_non_disturbing_idle(_Type, Port, Host, Node) -> + unblocked = get_admin_state(Node, Host, Port), + block_nd_server(Node, Host, Port), + blocked = get_admin_state(Node, Host, Port), + unblock_server(Node, Host, Port), + unblocked = get_admin_state(Node, Host, Port). +%%-------------------------------------------------------------------- +block_503(Type, Port, Host, Node) -> + Req = "GET / HTTP/1.0\r\ndummy-host.ericsson.se:\r\n\r\n", + unblocked = get_admin_state(Node, Host, Port), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, Req, + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = block_server(Node, Host, Port), + blocked = get_admin_state(Node, Host, Port), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, Req, + [{statuscode, 503}, + {version, "HTTP/1.0"}]), + ok = unblock_server(Node, Host, Port), + unblocked = get_admin_state(Node, Host, Port), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, Req, + [{statuscode, 200}, + {version, "HTTP/1.0"}]). +%%-------------------------------------------------------------------- +block_disturbing_active(Type, Port, Host, Node) -> + process_flag(trap_exit, true), + Pid = long_poll(Type, Host, Port, Node, 200, 60000), + test_server:sleep(15000), + block_server(Node, Host, Port), + await_suite_failed_process_exit(Pid, "poller", 60000, + connection_closed), + blocked = get_admin_state(Node, Host, Port), + process_flag(trap_exit, false), + ok. +%%-------------------------------------------------------------------- +block_non_disturbing_active(Type, Port, Host, Node) -> + process_flag(trap_exit, true), + Poller = long_poll(Type, Host, Port, Node, 200, 60000), + test_server:sleep(15000), + ok = block_nd_server(Node, Host, Port), + await_normal_process_exit(Poller, "poller", 60000), + blocked = get_admin_state(Node, Host, Port), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- +block_disturbing_active_timeout_not_released(Type, Port, Host, Node) -> + process_flag(trap_exit, true), + Poller = long_poll(Type, Host, Port, Node, 200, 60000), + test_server:sleep(15000), + Blocker = blocker(Node, Host, Port, 50000), + await_normal_process_exit(Blocker, "blocker", 50000), + await_normal_process_exit(Poller, "poller", 30000), + blocked = get_admin_state(Node, Host, Port), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- +block_disturbing_active_timeout_released(Type, Port, Host, Node) -> + process_flag(trap_exit, true), + Poller = long_poll(Type, Host, Port, Node, 200, 40000), + test_server:sleep(5000), + Blocker = blocker(Node, Host, Port, 10000), + await_normal_process_exit(Blocker, "blocker", 15000), + await_suite_failed_process_exit(Poller, "poller", 40000, + connection_closed), + blocked = get_admin_state(Node, Host, Port), + process_flag(trap_exit, false), + ok. +%%-------------------------------------------------------------------- +block_non_disturbing_active_timeout_not_released(Type, Port, Host, Node) -> + process_flag(trap_exit, true), + Poller = long_poll(Type, Host, Port, Node, 200, 60000), + test_server:sleep(5000), + ok = block_nd_server(Node, Host, Port, 40000), + await_normal_process_exit(Poller, "poller", 60000), + blocked = get_admin_state(Node, Host, Port), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- +block_non_disturbing_active_timeout_released(Type, Port, Host, Node) -> + process_flag(trap_exit, true), + Poller = long_poll(Type, Host, Port, Node, 200, 45000), + test_server:sleep(5000), + Blocker = blocker_nd(Node, Host, Port ,10000, {error,timeout}), + await_normal_process_exit(Blocker, "blocker", 15000), + await_normal_process_exit(Poller, "poller", 50000), + unblocked = get_admin_state(Node, Host, Port), + process_flag(trap_exit, false), + ok. +%%-------------------------------------------------------------------- +disturbing_blocker_dies(Type, Port, Host, Node) -> + process_flag(trap_exit, true), + Poller = long_poll(Type, Host, Port, Node, 200, 60000), + test_server:sleep(5000), + Blocker = blocker(Node, Host, Port, 10000), + test_server:sleep(5000), + exit(Blocker,simulate_blocker_crash), + await_normal_process_exit(Poller, "poller", 60000), + unblocked = get_admin_state(Node, Host, Port), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- +non_disturbing_blocker_dies(Type, Port, Host, Node) -> + process_flag(trap_exit, true), + Poller = long_poll(Type, Host, Port, Node, 200, 60000), + test_server:sleep(5000), + Blocker = blocker_nd(Node, Host, Port, 10000, ok), + test_server:sleep(5000), + exit(Blocker, simulate_blocker_crash), + await_normal_process_exit(Poller, "poller", 60000), + unblocked = get_admin_state(Node, Host, Port), + process_flag(trap_exit, false), + ok. +%%-------------------------------------------------------------------- +restart_no_block(_, Port, Host, Node) -> + {error,_Reason} = restart_server(Node, Host, Port). + +%%-------------------------------------------------------------------- +restart_disturbing_block(_, Port, Host, Node) -> + ?report("restart_disturbing_block - get_admin_state (unblocked)", []), + unblocked = get_admin_state(Node, Host, Port), + ?report("restart_disturbing_block - block_server", []), + ok = block_server(Node, Host, Port), + ?report("restart_disturbing_block - restart_server", []), + ok = restart_server(Node, Host, Port), + ?report("restart_disturbing_block - unblock_server", []), + ok = unblock_server(Node, Host, Port), + ?report("restart_disturbing_block - get_admin_state (unblocked)", []), + unblocked = get_admin_state(Node, Host, Port). + +%%-------------------------------------------------------------------- +restart_non_disturbing_block(_, Port, Host, Node) -> + ?report("restart_non_disturbing_block - get_admin_state (unblocked)", []), + unblocked = get_admin_state(Node, Host, Port), + ?report("restart_non_disturbing_block - block_nd_server", []), + ok = block_nd_server(Node, Host, Port), + ?report("restart_non_disturbing_block - restart_server", []), + ok = restart_server(Node, Host, Port), + ?report("restart_non_disturbing_block - unblock_server", []), + ok = unblock_server(Node, Host, Port), + ?report("restart_non_disturbing_block - get_admin_state (unblocked)", []), + unblocked = get_admin_state(Node, Host, Port). + +%%-------------------------------------------------------------------- +%% Internal functions +%%-------------------------------------------------------------------- +blocker(Node, Host, Port, Timeout) -> + spawn_link(?MODULE, do_block_server,[Node, Host, Port,Timeout]). + +do_block_server(Node, Host, Port, Timeout) -> + ok = block_server(Node, Host, Port, Timeout), + exit(normal). + +blocker_nd(Node, Host, Port, Timeout, Reply) -> + spawn_link(?MODULE, do_block_nd_server, + [Node, Host, Port, Timeout, Reply]). + +do_block_nd_server(Node, Host, Port, Timeout, Reply) -> + Reply = block_nd_server(Node, Host, Port, Timeout), + exit(normal). + +restart_server(Node, _Host, Port) -> + Addr = undefined, + rpc:call(Node, httpd, restart, [Addr, Port]). + +block_server(Node, _Host, Port) -> + Addr = undefined, + rpc:call(Node, httpd, block, [Addr, Port]). + +block_server(Node, _Host, Port, Timeout) -> + Addr = undefined, + rpc:call(Node, httpd, block, [Addr, Port, disturbing, Timeout]). + +block_nd_server(Node, _Host, Port) -> + Addr = undefined, + rpc:call(Node, httpd, block, [Addr, Port, non_disturbing]). + +block_nd_server(Node, _Host, Port, Timeout) -> + Addr = undefined, + rpc:call(Node, httpd, block, [Addr, Port, non_disturbing, Timeout]). + +unblock_server(Node, _Host, Port) -> + Addr = undefined, + rpc:call(Node, httpd, unblock, [Addr, Port]). + +get_admin_state(Node,_Host,Port) -> + Addr = undefined, + rpc:call(Node, httpd, get_admin_state, [Addr, Port]). + +await_normal_process_exit(Pid, Name, Timeout) -> + receive + {'EXIT', Pid, normal} -> + ok; + {'EXIT', Pid, Reason} -> + Err = + lists:flatten( + io_lib:format("expected normal exit, " + "unexpected exit of ~s process: ~p", + [Name, Reason])), + test_server:fail(Err) + after Timeout -> + test_server:fail("timeout while waiting for " ++ Name) + end. + +await_suite_failed_process_exit(Pid, Name, Timeout, Why) -> + receive + {'EXIT', Pid, {suite_failed, Why}} -> + ok; + {'EXIT', Pid, Reason} -> + Err = + lists:flatten( + io_lib:format("expected connection_closed, " + "unexpected exit of ~s process: ~p", + [Name, Reason])), + test_server:fail(Err) + after Timeout -> + test_server:fail("timeout while waiting for " ++ Name) + end. + +long_poll(Type, Host, Port, Node, StatusCode, Timeout) -> + spawn_link(?MODULE, do_long_poll, [Type, Host, Port, Node, + StatusCode, Timeout]). + +do_long_poll(Type, Host, Port, Node, StatusCode, Timeout) -> + Mod = "httpd_example", + Func = "delay", + Req = lists:flatten(io_lib:format("GET /eval?" ++ Mod ++ ":" ++ Func ++ + "(~p) HTTP/1.0\r\n\r\n",[30000])), + case httpd_test_lib:verify_request(Type, Host, Port, Node, Req, + [{statuscode, StatusCode}, + {version, "HTTP/1.0"}], Timeout) of + ok -> + exit(normal); + Reason -> + test_server:fail(Reason) + end. + + + + + diff --git a/lib/inets/test/httpd_load.erl b/lib/inets/test/httpd_load.erl new file mode 100644 index 0000000000..9bb9f9f94e --- /dev/null +++ b/lib/inets/test/httpd_load.erl @@ -0,0 +1,99 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(httpd_load). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +%% General testcases bodies called from httpd_SUITE +-export([load_test/5]). + +%% Help functions +-export([load_test_client/8]). + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +load_test(Type, Port, Host, Node, NofTesters) -> + URIs = + [ + "/index.html", + "/echo.shtml", + "/", + "/flastmod.shtml", + "/misc/" + ], + Fun = fun(Mod, Host1, Port1, Node1, Req, Exp) -> + ok = httpd_test_lib:verify_request(Mod, Host1, Port1, + Node1, Req, Exp) + end, + load_test(Fun, URIs ++ URIs, Type, Host, Port, Node, NofTesters, []). +%%-------------------------------------------------------------------- +%% Internal functions +%%-------------------------------------------------------------------- + +load_test(_, _, _, _, _, _, 0, []) -> + ok; +load_test(Fun, URIs, Type, Host, Port, Node, 0, List) -> + receive + {Pid, done} -> + load_test(Fun, URIs, Type, Host, Port, Node, 0, + lists:delete(Pid, List)); + {'EXIT', Pid, normal} -> + load_test(Fun, URIs, Type, Host, Port, Node, 0, + lists:delete(Pid, List)); + {'EXIT', Pid, Reason} -> + Str = lists:flatten(io_lib:format("client ~p exited: ~p", + [Pid,Reason])), + test_server:fail(Str); + _ -> + load_test(Fun, URIs, Type, Host, Port, Node, 0, List) + end; + +load_test(Fun, URIs, Type, Host, Port, Node, X, List) -> + Pid = spawn_link(?MODULE, load_test_client, + [Fun, URIs, Type, Host, Port, Node, self(), 100]), + load_test(Fun, lists:reverse(URIs), Type, Host, Port, Node, X-1, + [Pid | List]). + +load_test_client(_Fun, [], _Type, _Host, _Port, _Node, Boss, _Timeout) -> + load_test_client_done(Boss); +load_test_client(Fun, [URI|URIs], Type, Host, Port, Node, Boss, Timeout) -> + Req = "GET "++URI++" HTTP/1.0\r\nConnection: Close\r\n" + "From: m@erix\r\nReferer: http://www.ericsson.se/\r\n\r\n", + Timeout1 = + case (catch Fun(Type, Host, Port, Node, Req, + [{statuscode, 200}, {statuscode, 500}, + {statuscode, 503}, {version, "HTTP/1.0"}])) of + {'EXIT', {suite_failed, connection_closed, _, _}} -> + %% Some platforms seems to handle heavy load badly. + %% So, back off and see if this helps + %%?LOG("load_test_client->requestfailed:connection_closed"[]), + 2 * Timeout; + _ -> + Timeout + end, + test_server:sleep(Timeout1), + load_test_client(Fun, URIs, Type, Host, Port, Node, Boss, Timeout1). + +load_test_client_done(Boss) -> + Boss ! {self(), done}. + diff --git a/lib/inets/test/httpd_mod.erl b/lib/inets/test/httpd_mod.erl new file mode 100644 index 0000000000..b03f842e7c --- /dev/null +++ b/lib/inets/test/httpd_mod.erl @@ -0,0 +1,947 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(httpd_mod). +-author('[email protected]'). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +%% General testcases bodies called from httpd_SUITE +-export([alias/4, actions/4, security/5, auth/4, auth_api/6, + auth_mnesia_api/4, htaccess/4, + cgi/4, esi/4, get/4, head/4, all/4]). + +%% Help functions +-export([event/4, ssl_password_cb/0]). + +%% Seconds before successful auths timeout. +-define(AUTH_TIMEOUT,5). + + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +alias(Type, Port, Host, Node) -> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /pics/icon.sheet.gif " + "HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {header, "Content-Type","image/gif"}, + {header, "Server"}, + {header, "Date"}, + {version, "HTTP/1.0"}]), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {header, "Content-Type","text/html"}, + {header, "Server"}, + {header, "Date"}, + {version, "HTTP/1.0"}]), + + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET /misc/ HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {header, "Content-Type","text/html"}, + {header, "Server"}, + {header, "Date"}, + {version, "HTTP/1.0"}]), + + %% Check redirection if trailing slash is missing. + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET /misc HTTP/1.0\r\n\r\n", + [{statuscode, 301}, + {header, "Location"}, + {header, "Content-Type","text/html"}, + {version, "HTTP/1.0"}]). + +%%------------------------------------------------------------------------- +actions(Type, Port, Host, Node) -> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD / HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]). + +%%------------------------------------------------------------------------- +security(ServerRoot, Type, Port, Host, Node) -> + io:format(user, "~w:security -> entry with" + "~n ServerRoot: ~p" + "~n Type: ~p" + "~n Port: ~p" + "~n Host: ~p" + "~n Node: ~p" + "~n", [?MODULE, ServerRoot, Type, Port, Host, Node]), + + global:register_name(mod_security_test, self()), % Receive events + + test_server:sleep(5000), + + OpenDir = filename:join([ServerRoot, "htdocs", "open"]), + + %% Test blocking / unblocking of users. + + %% /open, require user one Aladdin + remove_users(Node, ServerRoot, Host, Port, "open"), + + auth_request(Type, Host, Port, Node, "/open/", "one", "onePassword", + [{statuscode, 401}]), + receive_security_event({event, auth_fail, Port, OpenDir, + [{user, "one"}, {password, "onePassword"}]}, + Node, Port), + + auth_request(Type,Host,Port,Node,"/open/", "two", "twoPassword", + [{statuscode, 401}]), + receive_security_event({event, auth_fail, Port, OpenDir, + [{user, "two"}, {password, "twoPassword"}]}, + Node, Port), + + auth_request(Type, Host, Port, Node,"/open/", "Aladdin", + "AladdinPassword", [{statuscode, 401}]), + receive_security_event({event, auth_fail, Port, OpenDir, + [{user, "Aladdin"}, + {password, "AladdinPassword"}]}, + Node, Port), + + add_user(Node, ServerRoot, Port, "open", "one", "onePassword", []), + add_user(Node, ServerRoot, Port, "open", "two", "twoPassword", []), + + auth_request(Type, Host, Port, Node,"/open/", "one", "WrongPassword", + [{statuscode, 401}]), + receive_security_event({event, auth_fail, Port, OpenDir, + [{user, "one"}, {password, "WrongPassword"}]}, + Node, Port), + + auth_request(Type, Host, Port, Node,"/open/", "one", "WrongPassword", + [{statuscode, 401}]), + receive_security_event({event, auth_fail, Port, OpenDir, + [{user, "one"}, {password, "WrongPassword"}]}, + Node, Port), + + receive_security_event({event, user_block, Port, OpenDir, + [{user, "one"}]}, Node, Port), + + global:unregister_name(mod_security_test), % No more events. + + auth_request(Type, Host, Port, Node,"/open/", "one", "WrongPassword", + [{statuscode, 401}]), + auth_request(Type, Host, Port, Node,"/open/", "one", "onePassword", + [{statuscode, 403}]), + + %% User "one" should be blocked now.. + %% [{"one",_, Port, OpenDir,_}] = list_blocked_users(Node,Port), + case list_blocked_users(Node, Port) of + [{"one",_, Port, OpenDir,_}] -> + ok; + Blocked -> + io:format(user, "~w:security -> Blocked: ~p" + "~n", [?MODULE, Blocked]), + exit({unexpected_blocked, Blocked}) + end, + + [{"one",_, Port, OpenDir,_}] = list_blocked_users(Node,Port,OpenDir), + + true = unblock_user(Node, "one", Port, OpenDir), + %% User "one" should not be blocked any more.. + [] = list_blocked_users(Node, Port), + [] = list_blocked_users(Node, Port, OpenDir), + auth_request(Type, Host, Port, Node,"/open/", "one", "onePassword", + [{statuscode, 200}]), + + %% Test list_auth_users & auth_timeout + ["one"] = list_auth_users(Node, Port), + ["one"] = list_auth_users(Node, Port, OpenDir), + auth_request(Type, Host, Port, Node,"/open/", "two", "onePassword", + [{statuscode, 401}]), + ["one"] = list_auth_users(Node, Port), + ["one"] = list_auth_users(Node, Port, OpenDir), + auth_request(Type, Host, Port, Node,"/open/", "two", "twoPassword", + [{statuscode, 401}]), + ["one"] = list_auth_users(Node, Port), + ["one"] = list_auth_users(Node, Port, OpenDir), + %% Wait for successful auth to timeout. + test_server:sleep(?AUTH_TIMEOUT*1001), + [] = list_auth_users(Node, Port), + [] = list_auth_users(Node, Port, OpenDir), + %% "two" is blocked. + true = unblock_user(Node, "two", Port, OpenDir), + %% Test explicit blocking. Block user 'two'. + [] = list_blocked_users(Node,Port,OpenDir), + true = block_user(Node, "two", Port, OpenDir, 10), + auth_request(Type, Host, Port, Node,"/open/", "two", "twoPassword", + [{statuscode, 401}]). + +%%------------------------------------------------------------------------- +auth(Type, Port, Host, Node) -> + %% Authentication required! + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET /open/ HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET /secret/ HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + ok = httpd_test_lib:verify_request(Type,Host,Port,Node, + "GET /secret/top_secret/" + " HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + + %% Authentication OK! ["one:OnePassword" user first in user list] + auth_request(Type, Host, Port, Node, "/open/dummy.html", "one", + "onePassword", [{statuscode, 200}]), + %% Authentication OK and a directory listing is supplied! + %% ["Aladdin:open sesame" user second in user list] + auth_request(Type, Host, Port, Node, "/open/","Aladdin", + "AladdinPassword", [{statuscode, 200}]), + + %% User correct but wrong password! ["one:one" user first in user list] + auth_request(Type, Host, Port, Node, "/open/", "one", "one", + [{statuscode, 401},{header, "WWW-Authenticate"}]), + %% Make sure Authenticate header is received even the second time + %% we try a incorrect password! Otherwise a browser client will hang! + auth_request(Type, Host, Port, Node, "/open/", "one", "one", + [{statuscode, 401},{header, "WWW-Authenticate"}]), + + %% Neither user or password correct! ["dummy:dummy"] + auth_request(Type, Host, Port, Node, "/open/", "dummy", "dummy", + [{statuscode, 401}]), + + %% Authentication OK! ["two:TwoPassword" user in first group] + auth_request(Type, Host, Port, Node, "/secret/dummy.html", "two", + "twoPassword", [{statuscode, 200}]), + %% Authentication OK and a directory listing is supplied! + %% ["three:ThreePassword" user in second group] + auth_request(Type, Host, Port, Node,"/secret/", "three", + "threePassword", [{statuscode, 200}]), + + %% User correct but wrong password! ["two:two" user in first group] + auth_request(Type, Host, Port, Node, "/secret/", "two", "two", + [{statuscode, 401}]), + %% Neither user or password correct! ["dummy:dummy"] + auth_request(Type, Host, Port, Node,"/secret/", "dummy", "dummy", + [{statuscode, 401}]), + + %% Nested secret/top_secret OK! ["Aladdin:open sesame"] + auth_request(Type, Host, Port, Node, "/secret/top_secret/", "Aladdin", + "AladdinPassword", [{statuscode, 200}]), + %% Authentication still required! + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /open/ " + "HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /secret/ " + "HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /secret/top_secret/ " + "HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]). + + +%%------------------------------------------------------------------------- +%% What to test here: +%% +%% /open - plain, require user one Aladdin +%% /secret - plain, require group group1 group2 +%% /secret/top_secret - plain, require group group3 +%% /dets_open - dets, require user one Aladdin +%% /dets_secret - dets, require group group1 group2 +%% /dets_secret/top_secret - dets, require group group3 +%% /mnesia_open/ - mnesia, require user one Aladdin +%% /mnesia_secret/ - mnesia, require group group1 group2 +%% /mnesia_secret/top_secret/ - mnesia, require group group3 +auth_api(ServerRoot, AuthStoreType, Type, Port, Host, Node) -> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET / HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + auth_request(Type, Host, Port, Node, "/", "one", "WrongPassword", + [{statuscode, 200}]), + + %% Make sure Authenticate header is received even the second time + %% we try a incorrect password! Otherwise a browser client will hang! + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "open/", + "dummy", "WrongPassword", [{statuscode, 401}, + {header, "WWW-Authenticate"}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "open/", + "dummy", "WrongPassword", [{statuscode, 401}, + {header, "WWW-Authenticate"}]), + + %% Change the password to DummyPassword then try to add a user + %% Get an error and set it to NoPassword + ok = update_password(Node, ServerRoot, Host, Port, AuthStoreType ++ + "open", "NoPassword", "DummyPassword"), + {error,bad_password} = + add_user(Node, ServerRoot, Port, AuthStoreType ++ "open", "one", + "onePassword", []), + ok = update_password(Node, ServerRoot, Host, Port, AuthStoreType ++"open", + "DummyPassword", "NoPassword"), + + %% Test /*open, require user one Aladdin + remove_users(Node, ServerRoot, Host, Port, AuthStoreType ++ "open"), + + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "open/", + "one", "onePassword", [{statuscode, 401}]), + + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "open/", + "two", "twoPassword", [{statuscode, 401}]), + + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "open/", + "Aladdin", "onePassword", [{statuscode, 401}]), + + add_user(Node, ServerRoot, Port, AuthStoreType ++ "open", "one", + "onePassword", []), + add_user(Node, ServerRoot, Port, AuthStoreType ++ "open", "two", + "twoPassword", []), + add_user(Node, ServerRoot, Port, AuthStoreType ++ "open", "Aladdin", + "AladdinPassword", []), + + {ok, [_|_]} = list_users(Node, ServerRoot, Host, Port, + AuthStoreType++"open"), + auth_request(Type, Host, Port, Node, "/" ++ AuthStoreType ++ "open/", + "one", "WrongPassword", [{statuscode, 401}]), + auth_request(Type, Host, Port, Node, "/" ++ AuthStoreType ++ "open/", + "one", "onePassword", [{statuscode, 200}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "open/", + "two", "twoPassword", [{statuscode, 401}]), + auth_request(Type, Host, Port, Node, "/" ++ AuthStoreType ++ "open/", + "Aladdin", "WrongPassword", [{statuscode, 401}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "open/", + "Aladdin", "AladdinPassword", [{statuscode, 200}]), + + remove_users(Node, ServerRoot, Host, Port, AuthStoreType++"open"), + {ok, []} = list_users(Node, ServerRoot, Host, Port, + AuthStoreType++"open"), + + %% Phase 2 + remove_users(Node, ServerRoot, Host, Port, AuthStoreType++"secret"), + {ok, []} = list_users(Node, ServerRoot, Host, Port, AuthStoreType ++ + "secret"), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "secret/", + "one", "onePassword", [{statuscode, 401}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "secret/", + "two", "twoPassword", [{statuscode, 401}]), + auth_request(Type, Host, Port, Node, "/" ++ AuthStoreType ++ "secret/", + "three", "threePassword", [{statuscode, 401}]), + add_user(Node, ServerRoot, Port, AuthStoreType ++ "secret", "one", + "onePassword", + []), + add_user(Node, ServerRoot, Port, AuthStoreType ++ "secret", + "two", "twoPassword", []), + add_user(Node, ServerRoot, Port, AuthStoreType++"secret", "Aladdin", + "AladdinPassword",[]), + add_group_member(Node, ServerRoot, Port, AuthStoreType ++ "secret", + "one", "group1"), + add_group_member(Node, ServerRoot, Port, AuthStoreType ++ "secret", + "two", "group1"), + add_group_member(Node, ServerRoot, Port, AuthStoreType ++ + "secret", "Aladdin", "group2"), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "secret/", + "one", "onePassword", [{statuscode, 200}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "secret/", + "two", "twoPassword", [{statuscode, 200}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "secret/", + "Aladdin", "AladdinPassword", [{statuscode, 200}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ "secret/", + "three", "threePassword", [{statuscode, 401}]), + remove_users(Node, ServerRoot, Host, Port, AuthStoreType ++ "secret"), + {ok, []} = list_users(Node, ServerRoot, Host, Port, + AuthStoreType ++ "secret"), + remove_groups(Node, ServerRoot, Host, Port, AuthStoreType ++ "secret"), + Directory = filename:join([ServerRoot, "htdocs", AuthStoreType ++ + "secret"]), + {ok, []} = list_groups(Node, ServerRoot, Host, Port, Directory), + + %% Phase 3 + remove_users(Node, ServerRoot, Host, Port, AuthStoreType ++ + "secret/top_secret"), + remove_groups(Node, ServerRoot, Host, Port, AuthStoreType ++ + "secret/top_secret"), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ + "secret/top_secret/", + "three", "threePassword", [{statuscode, 401}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ + "secret/top_secret/", "two", "twoPassword", + [{statuscode, 401}]), + add_user(Node, ServerRoot, Port, AuthStoreType ++ + "secret/top_secret","three", + "threePassword",[]), + add_user(Node, ServerRoot, Port, AuthStoreType ++ "secret/top_secret", + "two","twoPassword", []), + add_group_member(Node, ServerRoot, Port, AuthStoreType ++ + "secret/top_secret", + "three", "group3"), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ + "secret/top_secret/", "three", "threePassword", + [{statuscode, 200}]), + auth_request(Type, Host, Port, Node,"/" ++ AuthStoreType ++ + "secret/top_secret/", "two", "twoPassword", + [{statuscode, 401}]), + add_group_member(Node, ServerRoot, Port, AuthStoreType ++ + "secret/top_secret", + "two", "group3"), + auth_request(Type,Host,Port,Node,"/" ++ AuthStoreType ++ + "secret/top_secret/", + "two", "twoPassword", [{statuscode, 200}]), + remove_users(Node, ServerRoot, Host, Port, AuthStoreType ++ + "secret/top_secret"), + {ok, []} = list_users(Node, ServerRoot, Host, Port, + AuthStoreType ++ "secret/top_secret"), + remove_groups(Node, ServerRoot, Host, Port, AuthStoreType ++ + "secret/top_secret"), + Directory2 = filename:join([ServerRoot, "htdocs", + AuthStoreType ++ "secret/top_secret"]), + {ok, []} = list_groups(Node, ServerRoot, Host, Port, Directory2), + auth_request(Type, Host, Port, Node, "/" ++ AuthStoreType ++ + "secret/top_secret/", "two", "twoPassword", + [{statuscode, 401}]), + auth_request(Type, Host, Port, Node, "/" ++ AuthStoreType ++ + "secret/top_secret/","three", "threePassword", + [{statuscode, 401}]). + +%%-------------------------------------------------------------------------- +auth_mnesia_api(_Type, Port, _Host, _Node) -> + %% Create three groups: + %% group1 : one Aladdin + %% group2 : two + %% group3 : three + mod_auth_mnesia:store_user("one", "onePassword", Port, + "/mnesia_open", ""), + mod_auth_mnesia:store_user("Aladdin", "AladdinPassword", Port, + "/mnesia_open", ""), + mod_auth_mnesia:store_user("two", "twoPassword", Port, + "/mnesia_open", ""), + mod_auth_mnesia:store_user("three", "threePassword", Port, + "/mnesia_open", ""), + Users = mod_auth_mnesia:list_users(Port, "/mnesia_open"), + + ok = check_lists_members(Users,["Aladdin","one","two","three"]), + + true = mod_auth_mnesia:store_group_member("group1", "one", Port, + "/mnesia_open", ""), + true = mod_auth_mnesia:store_group_member("group1","Aladdin", Port, + "/mnesia_open", ""), + true = mod_auth_mnesia:store_group_member("group2","two", Port, + "/mnesia_open", ""), + true = mod_auth_mnesia:store_group_member("group3","three", Port, + "/mnesia_open", ""), + %% Check that all three created groups exist. + Groups = mod_auth_mnesia:list_groups(Port, "/mnesia_open"), + ok = check_lists_members(Groups, ["group1","group2","group3"]), + + %% Check that the members of all groups are correct. + Group1 = mod_auth_mnesia:list_group_members("group1", Port, + "/mnesia_open"), + ok = check_lists_members(Group1,["one","Aladdin"]), + {ok,["two"]} = mod_auth_mnesia:list_group_members("group2", Port, + "/mnesia_open"), + + {ok,["three"]} = mod_auth_mnesia:list_group_members("group3", Port, + "/mnesia_open"), + + %% Delete user 'one' from group one and check that he was removed + %% correctly. + true = mod_auth_mnesia:remove_group_member("group1", "one", Port, + "/mnesia_open", ""), + {ok,["Aladdin"]} = mod_auth_mnesia:list_group_members("group1", Port, + "/mnesia_open"), + + %% Remove group1 and check that the group was removed correctly. + true = mod_auth_mnesia:remove_group("group1", Port, "/mnesia_open", ""), + Groups_1 = mod_auth_mnesia:list_groups(Port, "/mnesia_open"), + ok = check_lists_members(Groups_1,["group2","group3"]), + + %% Check that the other users still exist in their groups. + Users_1 = mod_auth_mnesia:list_users(Port, "/mnesia_open"), + ok = check_lists_members(Users_1,["Aladdin","one","two","three"]), + {ok,["two"]} = mod_auth_mnesia:list_group_members("group2", Port, + "/mnesia_open"), + {ok,["three"]} = mod_auth_mnesia:list_group_members("group3", Port, + "/mnesia_open"), + + %% Remove the remaining groups/users and check that all + %% users/groups are removed. + true = mod_auth_mnesia:remove_group("group2", Port, "/mnesia_open", ""), + true = mod_auth_mnesia:remove_group("group3", Port, "/mnesia_open", ""), + {ok, []} = mod_auth_mnesia:list_groups(Port, "/mnesia_open"), + true = mod_auth_mnesia:remove_user("one", Port, "/mnesia_open", ""), + true = mod_auth_mnesia:remove_user("Aladdin", Port, "/mnesia_open", ""), + true = mod_auth_mnesia:remove_user("two", Port, "/mnesia_open", ""), + true = mod_auth_mnesia:remove_user("three", Port, "/mnesia_open", ""), + {ok, []} = mod_auth_mnesia:list_users(Port, "/mnesia_open"), + ok. +%%-------------------------------------------------------------------------- +htaccess(Type, Port, Host, Node) -> + %% Control that authentication required! + %% Control that the pages that shall be + %% authenticated really need authenticatin + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /ht/open/ HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /ht/secret/ HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /ht/secret/top_secret/ " + "HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + + %% Make sure Authenticate header is received even the second time + %% we try a incorrect password! Otherwise a browser client will hang! + auth_request(Type, Host, Port, Node,"/ht/open/", + "dummy", "WrongPassword", [{statuscode, 401}, + {header, "WWW-Authenticate"}]), + auth_request(Type, Host, Port, Node,"/ht/open/", + "dummy", "WrongPassword", [{statuscode, 401}, + {header, "WWW-Authenticate"}]), + + %% Control that not just the first user in the list is valid + %% Control the first user + %% Authennticating ["one:OnePassword" user first in user list] + auth_request(Type, Host, Port, Node, "/ht/open/dummy.html", "one", + "OnePassword", [{statuscode, 200}]), + + %% Control the second user + %% Authentication OK and a directory listing is supplied! + %% ["Aladdin:open sesame" user second in user list] + auth_request(Type, Host, Port, Node, "/ht/open/","Aladdin", + "AladdinPassword", [{statuscode, 200}]), + + %% Contro that bad passwords and userids get a good denial + %% User correct but wrong password! ["one:one" user first in user list] + auth_request(Type, Host, Port, Node, "/ht/open/", "one", "one", + [{statuscode, 401}]), + %% Neither user or password correct! ["dummy:dummy"] + auth_request(Type, Host, Port, Node, "/ht/open/", "dummy", "dummy", + [{statuscode, 401}]), + + %% Control that authetication still works, even if its a member in a group + %% Authentication OK! ["two:TwoPassword" user in first group] + auth_request(Type, Host, Port, Node, "/ht/secret/dummy.html", "two", + "TwoPassword", [{statuscode, 200}]), + + %% Authentication OK and a directory listing is supplied! + %% ["three:ThreePassword" user in second group] + auth_request(Type, Host, Port, Node,"/ht/secret/", "three", + "ThreePassword", [{statuscode, 200}]), + + %% Deny users with bad passwords even if the user is a group member + %% User correct but wrong password! ["two:two" user in first group] + auth_request(Type, Host, Port, Node, "/ht/secret/", "two", "two", + [{statuscode, 401}]), + %% Neither user or password correct! ["dummy:dummy"] + auth_request(Type, Host, Port, Node,"/ht/secret/", "dummy", "dummy", + [{statuscode, 401}]), + + %% control that we deny the users that are in subnet above the allowed + auth_request(Type, Host, Port, Node,"/ht/blocknet/dummy.html", "four", + "FourPassword", [{statuscode, 403}]), + %% Control that we only applies the rules to the right methods + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /ht/blocknet/dummy.html" + " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + + %% Control that the rerquire directive can be overrideen + auth_request(Type, Host, Port, Node, + "/ht/secret/top_secret/", "Aladdin", "AladdinPassword", + [{statuscode, 401}]), + + %% Authentication still required! + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, "GET /ht/open/ " + "HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /ht/secret/ HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /ht/secret/top_secret/ " + "HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {version, "HTTP/1.0"}, + {header, "WWW-Authenticate"}]). +%%-------------------------------------------------------------------- +cgi(Type, Port, Host, Node) -> + {Script, Script2, Script3} = + case test_server:os_type() of + {win32, _} -> + {"printenv.bat", "printenv.sh", "cgi_echo.exe"}; + _ -> + {"printenv.sh", "printenv.bat", "cgi_echo"} + end, + + %% The length (> 100) is intentional + ok = httpd_test_lib: + verify_request(Type, Host, Port, Node, + "POST /cgi-bin/" ++ Script3 ++ + " HTTP/1.0\r\n" + "Content-Length:100 \r\n\r\n " + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" + " \r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}, + {header, "content-type", "text/plain"}]), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/"++ Script ++ + " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/not_there " + "HTTP/1.0\r\n\r\n", + [{statuscode, 404},{statuscode, 500}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/"++ Script ++ + "?Nisse:kkk?sss/lll HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "POST /cgi-bin/"++ Script ++ + " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /htbin/"++ Script ++ + " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /htbin/not_there " + "HTTP/1.0\r\n\r\n", + [{statuscode, 404},{statuscode, 500}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /htbin/"++ Script ++ + "?Nisse:kkk?sss/lll HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "POST /htbin/"++ Script ++ + " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "POST /htbin/"++ Script ++ + " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + + %% Execute an existing, but bad CGI script.. + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "POST /htbin/"++ Script2 ++ + " HTTP/1.0\r\n\r\n", + [{statuscode, 404}, + {version, "HTTP/1.0"}]), + + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "POST /cgi-bin/"++ Script2 ++ + " HTTP/1.0\r\n\r\n", + [{statuscode, 404}, + {version, "HTTP/1.0"}]), + ok. + +%%-------------------------------------------------------------------- +esi(Type, Port, Host, Node) -> + %% Check "ErlScriptAlias" and "EvalScriptAlias" directives + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /eval?httpd_example:print(\"Hi!\")" + " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /eval?not_allowed:print(\"Hi!\")" + " HTTP/1.0\r\n\r\n", + [{statuscode, 403}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /eval?httpd_example:undef(\"Hi!\")" + " HTTP/1.0\r\n\r\n", + [{statuscode, 500}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/erl/httpd_example " + "HTTP/1.0\r\n\r\n", + [{statuscode, 400}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/erl/httpd_example:get " + "HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/erl/httpd_example:" + "get?input=4711" + " HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/erl/httpd_example:" + "post HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/erl/not_allowed:post " + "HTTP/1.0\r\n\r\n", + [{statuscode, 403}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/erl/httpd_example:undef " + "HTTP/1.0\r\n\r\n", + [{statuscode, 404}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /cgi-bin/erl/httpd_example/yahoo" + " HTTP/1.0\r\n\r\n", + [{statuscode, 302}, + {version, "HTTP/1.0"}]), + ok. +%%-------------------------------------------------------------------- +get(Type, Port, Host, Node) -> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /index.html HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {header, "Content-Type", "text/html"}, + {header, "Date"}, + {header, "Server"}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /fsize.shtml HTTP/1.1\r\nHost:" + ++ Host ++ "\r\n\r\n", + [{statuscode, 200}, + {header, "Content-Type", "text/html"}, + {header, "Date"}, + {header, "Server"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /fsize.shtml HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {header, "Content-Type"}, + {header, "Server"}, + {header, "Date"}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /secret/dummy.html " + "HTTP/1.0\r\n\r\n", + [{statuscode, 401}, + {header, "WWW-Authenticate"}, + {version, "HTTP/1.0"}]), + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "GET /index.html HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {header, "Server"}, + {header, "Date"}, + {header, "Content-Type", + "text/html"}, + {version, "HTTP/1.0"}]), + ok. + +%%-------------------------------------------------------------------- +head(Type, Port, Host, Node) -> + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + "HEAD /index.html HTTP/1.0\r\n\r\n", + [{statuscode, 200}, + {version, "HTTP/1.0"}]), + ok. +%%-------------------------------------------------------------------- +all(Type, Port, Host, Node) -> + actions(Type, Port, Host, Node), + alias(Type, Port, Host, Node), + auth(Type, Port, Host, Node), + cgi(Type, Port, Host, Node), + esi(Type, Port, Host, Node), + get(Type, Port, Host, Node), + head(Type, Port, Host, Node), + ok. + +%%-------------------------------------------------------------------- +%% Internal functions +%%-------------------------------------------------------------------- +auth_request(Type, Host, Port, Node, URI, User, Passwd, Expect) -> + Req = ["GET ", URI, " HTTP/1.0\r\n", + "Authorization: Basic ", + base64:encode_to_string(User++":"++Passwd), + "\r\n\r\n"], + ok = httpd_test_lib:verify_request(Type, Host, Port, Node, + lists:flatten(Req), + [{version, "HTTP/1.0"} | Expect]). + +remove_users(Node, ServerRoot, Host, Port, Dir) -> + %% List users, delete them, and make sure they are gone. + case list_users(Node, ServerRoot, Host, Port, Dir) of + {ok, Users} -> + lists:foreach(fun(User) -> + delete_user(Node, ServerRoot, Host, + Port, Dir, User) + end, + Users), + {ok, []} = list_users(Node, ServerRoot, Host, Port, Dir); + _ -> + ok + end. + +add_user(Node, Root, Port, Dir, User, Password, UserData) -> + Addr = undefined, + Directory = filename:join([Root, "htdocs", Dir]), + rpc:call(Node, mod_auth, add_user, + [User, Password, UserData, Addr, Port, Directory]). + +delete_user(Node, Root, _Host, Port, Dir, User) -> + Addr = undefined, + Directory = filename:join([Root, "htdocs", Dir]), + rpc:call(Node, mod_auth, delete_user, [User, Addr, Port, Directory]). + +list_users(Node, Root, _Host, Port, Dir) -> + Addr = undefined, + Directory = filename:join([Root, "htdocs", Dir]), + rpc:call(Node, mod_auth, list_users, [Addr, Port, Directory]). + +receive_security_event(Event, Node, Port) -> + io:format(user, "~w:receive_security_event -> entry with" + "~n Event: ~p" + "~n Node: ~p" + "~n Port: ~p" + "~n", [?MODULE, Event, Node, Port]), + receive + Event -> + ok; + {'EXIT', _, _} -> + receive_security_event(Event, Node, Port); + Other -> + test_server:fail({unexpected_event, + {expected, Event}, {received, Other}}) + after 5000 -> + test_server:fail(no_event_recived) + + end. + +list_blocked_users(Node,Port) -> + Addr = undefined, % Assumed to be on the same host + rpc:call(Node, mod_security, list_blocked_users, [Addr,Port]). + +list_blocked_users(Node,Port,Dir) -> + Addr = undefined, % Assumed to be on the same host + rpc:call(Node, mod_security, list_blocked_users, [Addr,Port,Dir]). + +block_user(Node,User,Port,Dir,Sec) -> + Addr = undefined, % Assumed to be on the same host + rpc:call(Node, mod_security, block_user, [User, Addr, Port, Dir, Sec]). + +unblock_user(Node,User,Port,Dir) -> + Addr = undefined, % Assumed to be on the same host + rpc:call(Node, mod_security, unblock_user, [User, Addr, Port, Dir]). + +list_auth_users(Node,Port) -> + Addr = undefined, % Assumed to be on the same host + rpc:call(Node, mod_security, list_auth_users, [Addr,Port]). + +list_auth_users(Node,Port,Dir) -> + Addr = undefined, % Assumed to be on the same host + rpc:call(Node, mod_security, list_auth_users, [Addr,Port,Dir]). + +update_password(Node, ServerRoot, _Address, Port, Dir, Old, New)-> + Directory = filename:join([ServerRoot, "htdocs", Dir]), + rpc:call(Node, mod_auth, update_password, + [undefined, Port, Directory, Old, New, New]). + +remove_groups(Node, ServerRoot, Host, Port, Dir) -> + Directory = filename:join([ServerRoot, "htdocs", Dir]), + {ok, Groups} = list_groups(Node, ServerRoot, Host, Port, Directory), + lists:foreach(fun(Group) -> + delete_group(Node, Group, Port, Directory) + end, + Groups), + {ok, []} = list_groups(Node, ServerRoot, Host, Port, Directory), + ok. + +delete_group(Node, Group, Port, Dir) -> + Addr = undefined, + rpc:call(Node, mod_auth, delete_group, [Group, Addr, Port, Dir]). + +list_groups(Node, _, _, Port, Dir) -> + Addr = undefined, + rpc:call(Node, mod_auth, list_groups, [Addr, Port, Dir]). + +add_group_member(Node, ServerRoot, Port, Dir, User, Group) -> + Addr = undefined, + rpc:call(Node, mod_auth, add_group_member, [Group, User, Addr, Port, + filename:join( + [ServerRoot, + "htdocs",Dir])]). +event(What, Port, Dir, Data) -> + Msg = {event, What, Port, Dir, Data}, + case global:whereis_name(mod_security_test) of + undefined -> + ok; + _Pid -> + global:send(mod_security_test, Msg) + end. + +ssl_password_cb() -> + "dummy-ssl-password". + +check_lists_members({ok,L},L) -> + ok; +check_lists_members({ok,L1},L2) -> + check_lists_members1(lists:sort(L1),lists:sort(L2)); +check_lists_members(Error,_L) -> + Error. + +check_lists_members1(L,L) -> + ok; +check_lists_members1(L1,L2) -> + {error,{lists_not_equal,L1,L2}}. diff --git a/lib/inets/test/httpd_poll.erl b/lib/inets/test/httpd_poll.erl new file mode 100644 index 0000000000..1cc10365a7 --- /dev/null +++ b/lib/inets/test/httpd_poll.erl @@ -0,0 +1,496 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(httpd_poll). +-behaviour(gen_server). + + +%% External API +-export([start/0, start_appup/2, start/3,stop/0,verbosity/1,poll_time/1]). + +%% gen_server exports +-export([init/1, + handle_call/3, handle_cast/2, handle_info/2, terminate/2]). + + +-define(default_verbosity,error). +-define(default_poll_time,60000). %% 60 seconds + + +-record(state,{host = "", port = -1, ptime = -1, tref = none, uris = []}). + + +%% start/0 +%% +%% Description: Start polling HTTPD with default values +%% +start() -> + Options = default_options(otp), + start("gandalf", 8000, Options). + +start_appup(Host, Port) -> + Options = default_options(top), + start(Host, Port, Options). + +%% start/3 +%% +%% Description: Start polling HTTPD +%% +%% Parameters: +%% Host = string() +%% Host name of HTTPD +%% Port = integer() +%% Port number of HTTPD +%% Options = [Option] +%% Option = {poll_time,integer()} | {verbosity,verbosity()} | +%% {log_file,string()} | {uris,[uri()]} +%% verbosity() = silence | error | log | debug | trace +%% uri() = {string(),string} +%% First part is a descriptive string and the second +%% part is the actual URI. +%% +start(Host,Port,Options) -> + gen_server:start({local,httpd_tester},?MODULE,[Host,Port,Options],[]). + +stop() -> + gen_server:call(httpd_tester,stop). + + +default_options(UriDesc) -> + Verbosity = {verbosity,?default_verbosity}, + Uris = {uris,uris(UriDesc)}, + PollTime = {poll_time,?default_poll_time}, + Logging = {log_file,"httpd_poll.log"}, + [Verbosity, Uris, PollTime, Logging]. + + +options(Options) -> + options(Options, default_options(otp), []). + +options([], Defaults, Options) -> + Options ++ Defaults; +options([{Key,Val} = Opt|Opts], Defaults, Options) -> + options(Opts, lists:keydelete(Key, 1, Defaults), [Opt|Options]). + + +verbosity(silence) -> + set_verbosity(silence); +verbosity(error) -> + set_verbosity(error); +verbosity(log) -> + set_verbosity(log); +verbosity(debug) -> + set_verbosity(debug); +verbosity(trace) -> + set_verbosity(trace). + +set_verbosity(Verbosity) -> + gen_server:cast(httpd_tester,{verbosity,Verbosity}). + +poll_time(NewTime) -> + gen_server:call(httpd_tester,{poll_time,NewTime}). + + +%% ---------------------------------------------------------------------- + + +init([Host, Port, Options0]) -> + process_flag(trap_exit,true), + Options = options(Options0), + put(verbosity,get_verbosity(Options)), + log_open(get_log_file(Options)), + tstart(), + PollTime = get_poll_time(Options), + Ref = tcreate(PollTime), + log("created"), + {ok,#state{host = Host, + port = Port, + ptime = PollTime, + tref = Ref, + uris = get_uris(Options)}}. + +uris(top) -> + [uri_top_index()]; + +uris(otp) -> + [ + uri_top_index(), + uri_internal_product1(), + uri_internal_product2(), + uri_p7a_test_results(), + uri_bjorn1(), + uri_bjorn2(), + uri_top_ronja() + ]. + +uri_top_index() -> + {"top page","/"}. + +uri_internal_product1() -> + {"product internal page (1)","/product/internal/"}. + +uri_internal_product2() -> + {"product internal page (2)","/product/internal"}. + +uri_p7a_test_results() -> + {"test summery index page", + "/product/internal/test/test_results/progress_P7A/index.html"}. + +uri_bjorn1() -> + {"bjorns home page (1)","/~bjorn/"}. + +uri_bjorn2() -> + {"bjorns home page (2)","/~bjorn"}. + +uri_top_ronja() -> + {"ronja top page","/ronja/"}. + + +handle_call(stop, _From, State) -> + vlog("stop request"), + {stop, normal, ok, State}; + +handle_call({poll_time,NewTime}, _From, State) -> + vlog("set new poll time: ~p",[NewTime]), + OldTime = State#state.ptime, + {stop, normal, OldTime, State#state{ptime = NewTime}}; + +handle_call(Request, _From, State) -> + vlog("unexpected request(call): ~p",[Request]), + {reply, ok, State}. + + +handle_cast({verbosity,Verbosity}, State) -> + vlog("set (new) verbosity to: ~p",[Verbosity]), + put(verbosity,Verbosity), + {noreply, State}; + +handle_cast(Message, State) -> + vlog("unexpected message(call): ~p",[Message]), + {noreply, State}. + + +handle_info(poll_time,State) -> + {{Description,Uri},Uris} = get_uri(State#state.uris), + vlog("poll time for ~s",[Description]), + do_poll(State#state.host,State#state.port,Uri), + Ref = tcreate(State#state.ptime), + {noreply, State#state{tref = Ref, uris = Uris}}; + +handle_info(Info, State) -> + vlog("unexpected message(info): ~p",[Info]), + {noreply, State}. + + +terminate(Reason,State) -> + tcancel(State#state.tref), + log_close(get(log_file)), + ok. + + +get_uri([Uri|Uris]) -> + {Uri,Uris++[Uri]}. + + +do_poll(Host,Port,Uri) -> + (catch poll(create(Host,Port),Uri,"200")). + +poll({ok,Socket},Uri,ExpStatus) -> + vtrace("poll -> entry with Socket: ~p",[Socket]), + put(latest_requested_uri,Uri), + Req = "GET " ++ Uri ++ " HTTP/1.0\r\n\r\n", + await_poll_response(send(Socket,Req),Socket,ExpStatus); +poll({error,Reason},_Req,_ExpStatus) -> + verror("failed creating socket: ~p",[Reason]), + log("failed creating socket: ~p",[Reason]), + exit({error,Reason}); +poll(O,_Req,_ExpStatus) -> + verror("unexpected result from socket create: ~p",[O]), + log("unexpected result from socket create: ~p",[O]), + exit({unexpected_result,O}). + +await_poll_response(ok,Socket,ExpStatusCode) -> + vtrace("await_poll_response -> awaiting response with status ~s", + [ExpStatusCode]), + receive + {tcp_closed,Socket} -> + verror("connection closed when awaiting poll response"), + log("connection closed when awaiting reply to GET of '~s'", + [get(latest_requested_uri)]), + exit(connection_closed); + {tcp,Socket,Response} -> + vdebug("received response"), + validate(ExpStatusCode,Socket,Response) + after 10000 -> + verror("connection timeout waiting for poll response",[]), + log("connection timeout waiting for reply to GET of '~s'", + [get(latest_requested_uri)]), + exit(connection_timed_out) + end; +await_poll_response(Error,_Socket,_ExpStatusCode) -> + verror("failed sending GET request for '~s' for reason: ~p", + [get(latest_requested_uri),Error]), + log("failed sending GET request for '~s' for reason: ~p", + [get(latest_requested_uri),Error]), + exit(Error). + + +validate(ExpStatusCode,Socket,Response) -> + Sz = sz(Response), + vtrace("validate -> Entry with ~p bytes response",[Sz]), + Size = trash_the_rest(Socket,Sz), + close(Socket), + case inets_regexp:split(Response," ") of + {ok,["HTTP/1.0",ExpStatusCode|_]} -> + vlog("response (~p bytes) was ok",[Size]), + ok; + {ok,["HTTP/1.0",StatusCode|_]} -> + verror("unexpected response status received: ~s => ~s", + [StatusCode,status_to_message(StatusCode)]), + log("unexpected result to GET of '~s': ~s => ~s", + [get(latest_requested_uri),StatusCode, + status_to_message(StatusCode)]), + exit({unexpected_response_code,StatusCode,ExpStatusCode}) + end. + + +%% ------------------------------------------------------------------ + +trash_the_rest(Socket,N) -> + receive + {tcp, Socket, Trash} -> + vtrace("trash_the_rest -> trash ~p bytes",[sz(Trash)]), + trash_the_rest(Socket,add(N,sz(Trash))); + {tcp_closed, Socket} -> + vdebug("socket closed after receiving ~p bytes",[N]), + N + after 10000 -> + verror("connection timeout waiting for message"), + exit(connection_timed_out) + end. + + +add(N1,N2) when integer(N1),integer(N2) -> + N1 + N2; +add(N1,N2) when integer(N1) -> + N1; +add(N1,N2) when integer(N2) -> + N2. + +sz(L) when list(L) -> + length(lists:flatten(L)); +sz(B) when binary(B) -> + size(B); +sz(O) -> + {unknown_size,O}. + + +%% -------------------------------------------------------------- +%% +%% Status code to printable string +%% + +status_to_message(L) when list(L) -> + case (catch list_to_integer(L)) of + I when integer(I) -> + status_to_message(I); + _ -> + io_lib:format("UNKNOWN STATUS CODE: '~p'",[L]) + end; +status_to_message(100) -> "Section 10.1.1: Continue"; +status_to_message(101) -> "Section 10.1.2: Switching Protocols"; +status_to_message(200) -> "Section 10.2.1: OK"; +status_to_message(201) -> "Section 10.2.2: Created"; +status_to_message(202) -> "Section 10.2.3: Accepted"; +status_to_message(203) -> "Section 10.2.4: Non-Authoritative Information"; +status_to_message(204) -> "Section 10.2.5: No Content"; +status_to_message(205) -> "Section 10.2.6: Reset Content"; +status_to_message(206) -> "Section 10.2.7: Partial Content"; +status_to_message(300) -> "Section 10.3.1: Multiple Choices"; +status_to_message(301) -> "Section 10.3.2: Moved Permanently"; +status_to_message(302) -> "Section 10.3.3: Found"; +status_to_message(303) -> "Section 10.3.4: See Other"; +status_to_message(304) -> "Section 10.3.5: Not Modified"; +status_to_message(305) -> "Section 10.3.6: Use Proxy"; +status_to_message(307) -> "Section 10.3.8: Temporary Redirect"; +status_to_message(400) -> "Section 10.4.1: Bad Request"; +status_to_message(401) -> "Section 10.4.2: Unauthorized"; +status_to_message(402) -> "Section 10.4.3: Peyment Required"; +status_to_message(403) -> "Section 10.4.4: Forbidden"; +status_to_message(404) -> "Section 10.4.5: Not Found"; +status_to_message(405) -> "Section 10.4.6: Method Not Allowed"; +status_to_message(406) -> "Section 10.4.7: Not Acceptable"; +status_to_message(407) -> "Section 10.4.8: Proxy Authentication Required"; +status_to_message(408) -> "Section 10.4.9: Request Time-Out"; +status_to_message(409) -> "Section 10.4.10: Conflict"; +status_to_message(410) -> "Section 10.4.11: Gone"; +status_to_message(411) -> "Section 10.4.12: Length Required"; +status_to_message(412) -> "Section 10.4.13: Precondition Failed"; +status_to_message(413) -> "Section 10.4.14: Request Entity Too Large"; +status_to_message(414) -> "Section 10.4.15: Request-URI Too Large"; +status_to_message(415) -> "Section 10.4.16: Unsupported Media Type"; +status_to_message(416) -> "Section 10.4.17: Requested range not satisfiable"; +status_to_message(417) -> "Section 10.4.18: Expectation Failed"; +status_to_message(500) -> "Section 10.5.1: Internal Server Error"; +status_to_message(501) -> "Section 10.5.2: Not Implemented"; +status_to_message(502) -> "Section 10.5.3: Bad Gatteway"; +status_to_message(503) -> "Section 10.5.4: Service Unavailable"; +status_to_message(504) -> "Section 10.5.5: Gateway Time-out"; +status_to_message(505) -> "Section 10.5.6: HTTP Version not supported"; +status_to_message(Code) -> io_lib:format("Unknown status code: ~p",[Code]). + + +%% ---------------------------------------------------------------- + +create(Host,Port) -> + vtrace("create -> ~n\tHost: ~s~n\tPort: ~p",[Host,Port]), + case gen_tcp:connect(Host,Port,[{packet,0},{reuseaddr,true}]) of + {ok,Socket} -> + {ok,Socket}; + {error,{enfile,_}} -> + {error,enfile}; + Error -> + Error + end. + +close(Socket) -> + gen_tcp:close(Socket). + + +send(Socket,Data) -> + vtrace("send -> send ~p bytes of data",[length(Data)]), + gen_tcp:send(Socket,Data). + + +%% ---------------------------------------------------------------- + +tstart() -> + timer:start(). + +tcreate(Time) -> + {ok,Ref} = timer:send_after(Time,poll_time), + Ref. + +tcancel(Ref) -> + timer:cancel(Ref). + +%% ---------------------------------------------------------------- + +log_open(undefined) -> + ok; +log_open(FileName) -> + put(log_file,fopen(FileName)). + +log_close(undefined) -> + ok; +log_close(Fd) -> + fclose(Fd). + +log(F) -> + log(F,[]). + +log(F,A) -> + {{Year,Month,Day},{Hour,Min,Sec}} = local_time(), + fwrite(get(log_file), + "~w.~w.~w ~w.~w.~w " ++ F ++ "~n", + [Year,Month,Day,Hour,Min,Sec] ++ A). + +%% ---------------------------------------------------------------- + +fopen(Name) -> + {ok,Fd} = file:open(Name,[write]), + Fd. + +fclose(Fd) -> + file:close(Fd). + +fwrite(undefined,_F,_A) -> + ok; +fwrite(Fd,F,A) -> + io:format(Fd,F,A). + + +%% ---------------------------------------------------------------- + +get_poll_time(Opts) -> + get_option(poll_time,Opts,?default_poll_time). + +get_log_file(Opts) -> + get_option(log_file,Opts). + +get_uris(Opts) -> + get_option(uris,Opts,[]). + +get_verbosity(Opts) -> + get_option(verbosity,Opts,?default_verbosity). + +get_option(Opt,Opts) -> + get_option(Opt,Opts,undefined). + +get_option(Opt,Opts,Default) -> + case lists:keysearch(Opt,1,Opts) of + {value,{Opt,Value}} -> + Value; + false -> + Default + end. + +%% ---------------------------------------------------------------- + +%% sleep(T) -> receive after T -> ok end. + +%% ---------------------------------------------------------------- + +%% vtrace(F) -> vprint(get(verbosity),trace,F,[]). +vtrace(F,A) -> vprint(get(verbosity),trace,F,A). + +vdebug(F) -> vprint(get(verbosity),debug,F,[]). +vdebug(F,A) -> vprint(get(verbosity),debug,F,A). + +vlog(F) -> vprint(get(verbosity),log,F,[]). +vlog(F,A) -> vprint(get(verbosity),log,F,A). + +verror(F) -> vprint(get(verbosity),error,F,[]). +verror(F,A) -> vprint(get(verbosity),error,F,A). + +vprint(trace,Severity,F,A) -> vprint(Severity,F,A); +vprint(debug,trace,F,A) -> ok; +vprint(debug,Severity,F,A) -> vprint(Severity,F,A); +vprint(log,log,F,A) -> vprint(log,F,A); +vprint(log,error,F,A) -> vprint(log,F,A); +vprint(error,error,F,A) -> vprint(error,F,A); +vprint(_Verbosity,_Severity,_F,_A) -> ok. + +vprint(Severity,F,A) -> + {{Year,Month,Day},{Hour,Min,Sec}} = local_time(), + io:format("~w.~w.~w ~w.~w.~w " ++ image_of(Severity) ++ F ++ "~n", + [Year,Month,Day,Hour,Min,Sec] ++ A). + +image_of(error) -> "ERR: "; +image_of(log) -> "LOG: "; +image_of(debug) -> "DBG: "; +image_of(trace) -> "TRC: ". + +local_time() -> calendar:local_time(). + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/auth/group b/lib/inets/test/httpd_test_data/server_root/auth/group new file mode 100644 index 0000000000..b3da0ccbd3 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/auth/group @@ -0,0 +1,3 @@ +group1: one two +group2: two three +group3: three Aladdin diff --git a/lib/inets/test/httpd_test_data/server_root/auth/passwd b/lib/inets/test/httpd_test_data/server_root/auth/passwd new file mode 100644 index 0000000000..8c980ff547 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/auth/passwd @@ -0,0 +1,4 @@ +one:onePassword +two:twoPassword +three:threePassword +Aladdin:AladdinPassword diff --git a/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.bat b/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.bat new file mode 100644 index 0000000000..25a49a1536 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.bat @@ -0,0 +1,9 @@ +@echo off +echo tomrad > c:\cygwin\tmp\hej +echo Content-type: text/html +echo. +echo ^<HTML^> ^<HEAD^> ^<TITLE^>OS Environment^</TITLE^> ^</HEAD^> ^<BODY^>^<PRE^> +set +echo ^</PRE^>^</BODY^>^</HTML^> + + diff --git a/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.sh b/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.sh new file mode 100755 index 0000000000..de81de9bde --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/cgi-bin/printenv.sh @@ -0,0 +1,6 @@ +#!/bin/sh +echo "Content-type: text/html" +echo "" +echo "<HTML> <HEAD> <TITLE>OS Environment</TITLE> </HEAD> <BODY><PRE>" +env +echo "</PRE></BODY></HTML>"
\ No newline at end of file diff --git a/lib/inets/test/httpd_test_data/server_root/conf/8080.conf b/lib/inets/test/httpd_test_data/server_root/conf/8080.conf new file mode 100644 index 0000000000..48e66f0114 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/conf/8080.conf @@ -0,0 +1,79 @@ +Port 8080 +#ServerName your.server.net +SocketType ip_comm +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log +ServerAdmin [email protected] +ServerRoot /var/tmp/server_root +ErrorLog logs/error_log_8080 +TransferLog logs/access_log_8080 +SecurityLog logs/security_log_8080 +ErrorDiskLog logs/error_disk_log_8080 +ErrorDiskLogSize 200000 10 +TransferDiskLog logs/access_disk_log_8080 +TransferDiskLogSize 200000 10 +SecurityDiskLog logs/security_disk_log +SecurityDiskLogSize 200000 10 +MaxClients 50 +#KeepAlive 5 +#KeepAliveTimeout 10 +DocumentRoot /var/tmp/server_root/htdocs +DirectoryIndex index.html welcome.html +DefaultType text/plain +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ +ErlScriptAlias /cgi-bin/erl httpd_example io +EvalScriptAlias /eval httpd_example io +#Script HEAD /cgi-bin/printenv.sh +#Action image/gif /cgi-bin/printenv.sh + +<Directory /var/tmp/server_root/htdocs/open> +AuthDBType plain +AuthName Open Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret> +AuthDBType plain +AuthName Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret/top_secret> +AuthDBType plain +AuthName Top Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group3 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_open> +AuthDBType mnesia +AuthName Open Area +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret> +AuthDBType mnesia +AuthName Secret Area +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret/top_secret> +AuthDBType mnesia +AuthName Top Secret Area +require group group3 +allow from 130.100.34 130.100.35 +deny from 100.234.22.12 194.100.34.1 130.100.34.25 +SecurityDataFile logs/security_data +SecurityMaxRetries 3 +SecurityBlockTime 10 +SecurityFailExpireTime 1 +SecurityAuthTimeout 1 +SecurityCallbackModule security_callback +</Directory> diff --git a/lib/inets/test/httpd_test_data/server_root/conf/8888.conf b/lib/inets/test/httpd_test_data/server_root/conf/8888.conf new file mode 100644 index 0000000000..79bb7fcca4 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/conf/8888.conf @@ -0,0 +1,63 @@ +Port 8888 +#ServerName your.server.net +SocketType ip_comm +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log +ServerAdmin [email protected] +ServerRoot /var/tmp/server_root +ErrorLog logs/error_log_8888 +TransferLog logs/access_log_8888 +ErrorDiskLog logs/error_disk_log_8888 +ErrorDiskLogSize 200000 10 +TransferDiskLog logs/access_disk_log_8888 +TransferDiskLogSize 200000 10 +MaxClients 150 +DocumentRoot /var/tmp/server_root/htdocs +DirectoryIndex index.html welcome.html +DefaultType text/plain +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ +ErlScriptAlias /cgi-bin/erl httpd_example io +EvalScriptAlias /eval httpd_example io +#Script HEAD /cgi-bin/printenv.sh +#Action image/gif /cgi-bin/printenv.sh + +<Directory /var/tmp/server_root/htdocs/open> +AuthName Open Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret> +AuthName Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret/top_secret> +AuthName Top Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group3 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_open> +AuthName Open Area +AuthMnesiaDB On +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret> +AuthName Secret Area +AuthMnesiaDB On +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret/top_secret> +AuthName Top Secret Area +AuthMnesiaDB On +require group group3 +</Directory> diff --git a/lib/inets/test/httpd_test_data/server_root/conf/httpd.conf b/lib/inets/test/httpd_test_data/server_root/conf/httpd.conf new file mode 100644 index 0000000000..8a74ed1afd --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/conf/httpd.conf @@ -0,0 +1,268 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1997-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# + +# Port: The port the standalone listens to. For ports < 1023, you will +# need httpd to be run as root initially. + +Port 8888 + +# BindAddress: This directive is used to tell the server which IP address +# to listen to. It can either contain "*", an IP address, or a fully +# qualified Internet domain name. +# +# It is also possible to specify the ip-family with the directive. +# There ar three possible value: inet, inet6 and inet6fb4 +# inet: Use IpFamily inet when retreiving the address and +# fail if that does not work. +# inet6: Use IpFamily inet6 when retreiving the address and +# fail if that does not work. +# inet6fb4: First IpFamily inet6 is tried and if that does not work, +# inet is used as fallback. +# Default value for ip-family is inet6fb4 +# +# The syntax is: <address>[|<ip-family>] +# +#BindAddress * +#BindAddress *|inet + + +# ServerName allows you to set a host name which is sent back to clients for +# your server if it's different than the one the program would get (i.e. use +# "www" instead of the host's real name). +# +# Note: You cannot just invent host names and hope they work. The name you +# define here must be a valid DNS name for your host. If you don't understand +# this, ask your network administrator. + +#ServerName your.server.net + +# SocketType is either ip_comm, sockets or ssl. + +SocketType ip_comm + +# Modules: Server run-time plug-in modules written using the Erlang +# Web Server API (EWSAPI). The server API make it easy to add functionality +# to the server. Read more about EWSAPI in the Reference Manual. +# WARNING! Do not tamper with this directive unless you are familiar with +# EWSAPI. + +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_responsecontrol mod_trace mod_range mod_head mod_include mod_dir mod_get mod_log mod_disk_log + +# ServerAdmin: Your address, where problems with the server should be +# e-mailed. + +ServerAdmin [email protected] + +# ServerRoot: The directory the server's config, error, and log files +# are kept in + +ServerRoot /var/tmp/server_root + +# ErrorLog: The location of the error log file. If this does not start +# with /, ServerRoot is prepended to it. + +ErrorLog logs/error_log + +# TransferLog: The location of the transfer log file. If this does not +# start with /, ServerRoot is prepended to it. + +TransferLog logs/access_log + +# SecurityLog: The location of the security log file (mod_security required) +# +SecurityLog logs/security_log + +# ErrorDiskLog: The location of the error log file. If this does not +# start with /, ServerRoot is prepended to it. This log file is managed +# with the disk_log module [See disk_log(3)]. The ErrorDiskLogSize directive +# takes two argument, i.e. MaxBytes and MaxFiles. The wrap log writes at most +# MaxBytes bytes on each file, and it uses MaxFiles files before it wraps, and +# truncates the first file. + +ErrorDiskLog logs/error_disk_log +ErrorDiskLogSize 200000 10 + +# TransferDiskLog: The location of the transfer log file. If this does not +# start with /, ServerRoot is prepended to it. This log file is managed +# with the disk_log module [See disk_log(3)]. The TransferDiskLogSize directive +# takes two argument, i.e. MaxBytes and MaxFiles. The wrap log writes at most +# MaxBytes bytes on each file, and it uses MaxFiles files before it wraps, and +# truncates the first file. + +TransferDiskLog logs/access_disk_log +TransferDiskLogSize 200000 10 + +# SecurityDiskLog: The location of the security log file. If this does not +# start with /, ServerRoot is prepended to it. This log file is managed +# with the disk_log module [See disk_log(3)]. The SecurityDiskLogSize directive +# takes two argument, i.e. MaxBytes and MaxFiles. The wrap log writes at most +# MaxBytes bytes on each file, and it uses MaxFiles files before it wraps, and +# truncates the first file. + +SecurityDiskLog logs/security_disk_log +SecurityDiskLogSize 200000 10 + +# Limit on total number of servers running, i.e., limit on the number +# of clients who can simultaneously connect --- if this limit is ever +# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW. +# It is intended mainly as a brake to keep a runaway server from taking +# the server with it as it spirals down... + +MaxClients 50 + +# KeepAlive set the flag for persistent connections. For peristent connections +# set KeepAlive to on. To use One request per connection set the flag to off +# Note: The value has changed since previous version of INETS. +KeepAlive on + +# KeepAliveTimeout sets the number of seconds before a persistent connection +# times out and closes. +KeepAliveTimeout 10 + +# MaxKeepAliveRequests sets the number of seconds before a persistent connection +# times out and closes. +MaxKeepAliveRequests 10 + + + +# DocumentRoot: The directory out of which you will serve your +# documents. By default, all requests are taken from this directory, but +# symbolic links and aliases may be used to point to other locations. + +DocumentRoot /var/tmp/server_root/htdocs + +# DirectoryIndex: Name of the file or files to use as a pre-written HTML +# directory index. Separate multiple entries with spaces. + +DirectoryIndex index.html welcome.html + +# DefaultType is the default MIME type for documents which the server +# cannot find the type of from filename extensions. + +DefaultType text/plain + +# Aliases: Add here as many aliases as you need (with no limit). The format is +# Alias fakename realname + +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ + +# ScriptAlias: This controls which directories contain server scripts. +# Format: ScriptAlias fakename realname + +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ + +# This directive adds an action, which will activate cgi-script when a +# file is requested using the method of method, which can be one of +# GET, POST and HEAD. It sends the URL and file path of the requested +# document using the standard CGI PATH_INFO and PATH_TRANSLATED +# environment variables. + +#Script HEAD /cgi-bin/printenv.sh + +# This directive adds an action, which will activate cgi-script when a +# file of content type mime-type is requested. It sends the URL and +# file path of the requested document using the standard CGI PATH_INFO +# and PATH_TRANSLATED environment variables. + +#Action image/gif /cgi-bin/printenv.sh + +# ErlScriptAlias: This specifies how "Erl" server scripts are called. +# Format: ErlScriptAlias fakename realname allowed_modules + +ErlScriptAlias /down/erl httpd_example io + +# EvalScriptAlias: This specifies how "Eval" server scripts are called. +# Format: EvalScriptAlias fakename realname allowed_modules + +EvalScriptAlias /eval httpd_example io + +# Point SSLCertificateFile at a PEM encoded certificate. + +SSLCertificateFile /var/tmp/server_root/ssl/ssl_server.pem + +# If the key is not combined with the certificate, use this directive to +# point at the key file. + +SSLCertificateKeyFile /var/tmp/server_root/ssl/ssl_server.pem + +# Set SSLVerifyClient to: +# 0 if no certicate is required +# 1 if the client may present a valid certificate +# 2 if the client must present a valid certificate +# 3 if the client may present a valid certificate but it is not required to +# have a valid CA + +SSLVerifyClient 0 + +# Each directory to which INETS has access, can be configured with respect +# to which services and features are allowed and/or disabled in that +# directory (and its subdirectories). + +<Directory /var/tmp/server_root/htdocs/open> +AuthDBType plain +AuthName Open Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret> +AuthDBType plain +AuthName Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret/top_secret> +AuthDBType plain +AuthName Top Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group3 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_open> +AuthDBType mnesia +AuthName Open Area +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret> +AuthDBType mnesia +AuthName Secret Area +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret/top_secret> +AuthDBType mnesia +AuthName Top Secret Area +require group group3 +allow from 130.100.34 130.100.35 +deny from 100.234.22.12 194.100.34.1 130.100.34.25 +SecurityDataFile logs/security_data +SecurityMaxRetries 3 +SecurityBlockTime 10 +SecurityFailExpireTime 1 +SecurityAuthTimeout 1 +SecurityCallbackModule security_callback +</Directory> diff --git a/lib/inets/test/httpd_test_data/server_root/conf/mime.types b/lib/inets/test/httpd_test_data/server_root/conf/mime.types new file mode 100644 index 0000000000..d2f81e4e5e --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/conf/mime.types @@ -0,0 +1,465 @@ +# This is a comment. I love comments. + +# MIME type Extension +application/EDI-Consent +application/EDI-X12 +application/EDIFACT +application/activemessage +application/andrew-inset ez +application/applefile +application/atomicmail +application/batch-SMTP +application/beep+xml +application/cals-1840 +application/commonground +application/cybercash +application/dca-rft +application/dec-dx +application/dvcs +application/eshop +application/http +application/hyperstudio +application/iges +application/index +application/index.cmd +application/index.obj +application/index.response +application/index.vnd +application/iotp +application/ipp +application/isup +application/font-tdpfr +application/mac-binhex40 hqx +application/mac-compactpro cpt +application/macwriteii +application/marc +application/mathematica +application/mathematica-old +application/msword doc +application/news-message-id +application/news-transmission +application/ocsp-request +application/ocsp-response +application/octet-stream bin dms lha lzh exe class so dll +application/oda oda +application/parityfec +application/pdf pdf +application/pgp-encrypted +application/pgp-keys +application/pgp-signature +application/pkcs10 +application/pkcs7-mime +application/pkcs7-signature +application/pkix-cert +application/pkix-crl +application/pkixcmp +application/postscript ai eps ps +application/prs.alvestrand.titrax-sheet +application/prs.cww +application/prs.nprend +application/qsig +application/remote-printing +application/riscos +application/rtf +application/sdp +application/set-payment +application/set-payment-initiation +application/set-registration +application/set-registration-initiation +application/sgml +application/sgml-open-catalog +application/sieve +application/slate +application/smil smi smil +application/timestamp-query +application/timestamp-reply +application/vemmi +application/vnd.3M.Post-it-Notes +application/vnd.FloGraphIt +application/vnd.accpac.simply.aso +application/vnd.accpac.simply.imp +application/vnd.acucobol +application/vnd.aether.imp +application/vnd.anser-web-certificate-issue-initiation +application/vnd.anser-web-funds-transfer-initiation +application/vnd.audiograph +application/vnd.businessobjects +application/vnd.bmi +application/vnd.canon-cpdl +application/vnd.canon-lips +application/vnd.claymore +application/vnd.commerce-battelle +application/vnd.commonspace +application/vnd.comsocaller +application/vnd.contact.cmsg +application/vnd.cosmocaller +application/vnd.cups-postscript +application/vnd.cups-raster +application/vnd.cups-raw +application/vnd.ctc-posml +application/vnd.cybank +application/vnd.dna +application/vnd.dpgraph +application/vnd.dxr +application/vnd.ecdis-update +application/vnd.ecowin.chart +application/vnd.ecowin.filerequest +application/vnd.ecowin.fileupdate +application/vnd.ecowin.series +application/vnd.ecowin.seriesrequest +application/vnd.ecowin.seriesupdate +application/vnd.enliven +application/vnd.epson.esf +application/vnd.epson.msf +application/vnd.epson.quickanime +application/vnd.epson.salt +application/vnd.epson.ssf +application/vnd.ericsson.quickcall +application/vnd.eudora.data +application/vnd.fdf +application/vnd.ffsns +application/vnd.framemaker +application/vnd.fsc.weblaunch +application/vnd.fujitsu.oasys +application/vnd.fujitsu.oasys2 +application/vnd.fujitsu.oasys3 +application/vnd.fujitsu.oasysgp +application/vnd.fujitsu.oasysprs +application/vnd.fujixerox.ddd +application/vnd.fujixerox.docuworks +application/vnd.fujixerox.docuworks.binder +application/vnd.fut-misnet +application/vnd.grafeq +application/vnd.groove-account +application/vnd.groove-identity-message +application/vnd.groove-injector +application/vnd.groove-tool-message +application/vnd.groove-tool-template +application/vnd.groove-vcard +application/vnd.hhe.lesson-player +application/vnd.hp-HPGL +application/vnd.hp-PCL +application/vnd.hp-PCLXL +application/vnd.hp-hpid +application/vnd.hp-hps +application/vnd.httphone +application/vnd.hzn-3d-crossword +application/vnd.ibm.afplinedata +application/vnd.ibm.MiniPay +application/vnd.ibm.modcap +application/vnd.informix-visionary +application/vnd.intercon.formnet +application/vnd.intertrust.digibox +application/vnd.intertrust.nncp +application/vnd.intu.qbo +application/vnd.intu.qfx +application/vnd.irepository.package+xml +application/vnd.is-xpr +application/vnd.japannet-directory-service +application/vnd.japannet-jpnstore-wakeup +application/vnd.japannet-payment-wakeup +application/vnd.japannet-registration +application/vnd.japannet-registration-wakeup +application/vnd.japannet-setstore-wakeup +application/vnd.japannet-verification +application/vnd.japannet-verification-wakeup +application/vnd.koan +application/vnd.lotus-1-2-3 +application/vnd.lotus-approach +application/vnd.lotus-freelance +application/vnd.lotus-notes +application/vnd.lotus-organizer +application/vnd.lotus-screencam +application/vnd.lotus-wordpro +application/vnd.mcd +application/vnd.mediastation.cdkey +application/vnd.meridian-slingshot +application/vnd.mif mif +application/vnd.minisoft-hp3000-save +application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf +application/vnd.mobius.dis +application/vnd.mobius.msl +application/vnd.mobius.plc +application/vnd.mobius.txf +application/vnd.motorola.flexsuite +application/vnd.motorola.flexsuite.adsi +application/vnd.motorola.flexsuite.fis +application/vnd.motorola.flexsuite.gotap +application/vnd.motorola.flexsuite.kmr +application/vnd.motorola.flexsuite.ttc +application/vnd.motorola.flexsuite.wem +application/vnd.mozilla.xul+xml +application/vnd.ms-artgalry +application/vnd.ms-asf +application/vnd.ms-excel xls +application/vnd.ms-lrm +application/vnd.ms-powerpoint ppt +application/vnd.ms-project +application/vnd.ms-tnef +application/vnd.ms-works +application/vnd.mseq +application/vnd.msign +application/vnd.music-niff +application/vnd.musician +application/vnd.netfpx +application/vnd.noblenet-directory +application/vnd.noblenet-sealer +application/vnd.noblenet-web +application/vnd.novadigm.EDM +application/vnd.novadigm.EDX +application/vnd.novadigm.EXT +application/vnd.osa.netdeploy +application/vnd.palm +application/vnd.pg.format +application/vnd.pg.osasli +application/vnd.powerbuilder6 +application/vnd.powerbuilder6-s +application/vnd.powerbuilder7 +application/vnd.powerbuilder7-s +application/vnd.powerbuilder75 +application/vnd.powerbuilder75-s +application/vnd.previewsystems.box +application/vnd.publishare-delta-tree +application/vnd.pvi.ptid1 +application/vnd.pwg-xhtml-print+xml +application/vnd.rapid +application/vnd.s3sms +application/vnd.seemail +application/vnd.shana.informed.formdata +application/vnd.shana.informed.formtemplate +application/vnd.shana.informed.interchange +application/vnd.shana.informed.package +application/vnd.sss-cod +application/vnd.sss-dtf +application/vnd.sss-ntf +application/vnd.street-stream +application/vnd.svd +application/vnd.swiftview-ics +application/vnd.triscape.mxs +application/vnd.trueapp +application/vnd.truedoc +application/vnd.tve-trigger +application/vnd.ufdl +application/vnd.uplanet.alert +application/vnd.uplanet.alert-wbxml +application/vnd.uplanet.bearer-choice-wbxml +application/vnd.uplanet.bearer-choice +application/vnd.uplanet.cacheop +application/vnd.uplanet.cacheop-wbxml +application/vnd.uplanet.channel +application/vnd.uplanet.channel-wbxml +application/vnd.uplanet.list +application/vnd.uplanet.list-wbxml +application/vnd.uplanet.listcmd +application/vnd.uplanet.listcmd-wbxml +application/vnd.uplanet.signal +application/vnd.vcx +application/vnd.vectorworks +application/vnd.vidsoft.vidconference +application/vnd.visio +application/vnd.vividence.scriptfile +application/vnd.wap.sic +application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo +application/vnd.wrq-hp3000-labelled +application/vnd.wt.stf +application/vnd.xara +application/vnd.xfdl +application/vnd.yellowriver-custom-menu +application/whoispp-query +application/whoispp-response +application/wita +application/wordperfect5.1 +application/x-bcpio bcpio +application/x-cdlink vcd +application/x-chess-pgn pgn +application/x-compress +application/x-cpio cpio +application/x-csh csh +application/x-director dcr dir dxr +application/x-dvi dvi +application/x-futuresplash spl +application/x-gtar gtar +application/x-gzip +application/x-hdf hdf +application/x-javascript js +application/x-koan skp skd skt skm +application/x-latex latex +application/x-netcdf nc cdf +application/x-sh sh +application/x-shar shar +application/x-shockwave-flash swf +application/x-stuffit sit +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-tar tar +application/x-tcl tcl +application/x-tex tex +application/x-texinfo texinfo texi +application/x-troff t tr roff +application/x-troff-man man +application/x-troff-me me +application/x-troff-ms ms +application/x-ustar ustar +application/x-wais-source src +application/x400-bp +application/xml +application/xml-dtd +application/xml-external-parsed-entity +application/zip zip +audio/32kadpcm +audio/basic au snd +audio/g.722.1 +audio/l16 +audio/midi mid midi kar +audio/mp4a-latm +audio/mpa-robust +audio/mpeg mpga mp2 mp3 +audio/parityfec +audio/prs.sid +audio/telephone-event +audio/tone +audio/vnd.cisco.nse +audio/vnd.cns.anp1 +audio/vnd.cns.inf1 +audio/vnd.digital-winds +audio/vnd.everad.plj +audio/vnd.lucent.voice +audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 +audio/vnd.nuera.ecelp7470 +audio/vnd.nuera.ecelp9600 +audio/vnd.octel.sbc +audio/vnd.qcelp +audio/vnd.rhetorex.32kadpcm +audio/vnd.vmx.cvsd +audio/x-aiff aif aiff aifc +audio/x-mpegurl m3u +audio/x-pn-realaudio ram rm +audio/x-pn-realaudio-plugin rpm +audio/x-realaudio ra +audio/x-wav wav +chemical/x-pdb pdb +chemical/x-xyz xyz +image/bmp bmp +image/cgm +image/g3fax +image/gif gif +image/ief ief +image/jpeg jpeg jpg jpe +image/naplps +image/png png +image/prs.btif +image/prs.pti +image/tiff tiff tif +image/vnd.cns.inf2 +image/vnd.dwg +image/vnd.dxf +image/vnd.fastbidsheet +image/vnd.fpx +image/vnd.fst +image/vnd.fujixerox.edmics-mmr +image/vnd.fujixerox.edmics-rlc +image/vnd.mix +image/vnd.net-fpx +image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff +image/x-cmu-raster ras +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd +message/delivery-status +message/disposition-notification +message/external-body +message/http +message/news +message/partial +message/rfc822 +message/s-http +model/iges igs iges +model/mesh msh mesh silo +model/vnd.dwf +model/vnd.flatland.3dml +model/vnd.gdl +model/vnd.gs-gdl +model/vnd.gtw +model/vnd.mts +model/vnd.vtu +model/vrml wrl vrml +multipart/alternative +multipart/appledouble +multipart/byteranges +multipart/digest +multipart/encrypted +multipart/form-data +multipart/header-set +multipart/mixed +multipart/parallel +multipart/related +multipart/report +multipart/signed +multipart/voice-message +text/calendar +text/css css +text/directory +text/enriched +text/html html htm +text/parityfec +text/plain asc txt +text/prs.lines.tag +text/rfc822-headers +text/richtext rtx +text/rtf rtf +text/sgml sgml sgm +text/tab-separated-values tsv +text/t140 +text/uri-list +text/vnd.DMClientScript +text/vnd.IPTC.NITF +text/vnd.IPTC.NewsML +text/vnd.abc +text/vnd.curl +text/vnd.flatland.3dml +text/vnd.fly +text/vnd.fmi.flexstor +text/vnd.in3d.3dml +text/vnd.in3d.spot +text/vnd.latex-z +text/vnd.motorola.reflex +text/vnd.ms-mediapackage +text/vnd.wap.si +text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-setext etx +text/x-server-parsed-html shtml +text/xml xml xsl +text/xml-external-parsed-entity +video/mp4v-es +video/mpeg mpeg mpg mpe +video/parityfec +video/pointer +video/quicktime qt mov +video/vnd.fvt +video/vnd.motorola.video +video/vnd.motorola.videop +video/vnd.mpegurl mxu +video/vnd.mts +video/vnd.nokia.interleaved-multimedia +video/vnd.vivo +video/x-msvideo avi +video/x-sgi-movie movie +x-conference/x-cooltalk ice + + + diff --git a/lib/inets/test/httpd_test_data/server_root/conf/ssl.conf b/lib/inets/test/httpd_test_data/server_root/conf/ssl.conf new file mode 100644 index 0000000000..8b8c57a98b --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/conf/ssl.conf @@ -0,0 +1,66 @@ +Port 8088 +#ServerName your.server.net +SocketType ssl +Modules mod_alias mod_auth mod_esi mod_actions mod_cgi mod_include mod_dir mod_get mod_head mod_log mod_disk_log +ServerAdmin [email protected] +ServerRoot /var/tmp/server_root +ErrorLog logs/error_log_8088 +TransferLog logs/access_log_8088 +ErrorDiskLog logs/error_disk_log_8088 +ErrorDiskLogSize 200000 10 +TransferDiskLog logs/access_disk_log_8088 +TransferDiskLogSize 200000 10 +MaxClients 150 +DocumentRoot /var/tmp/server_root/htdocs +DirectoryIndex index.html welcome.html +DefaultType text/plain +Alias /icons/ /var/tmp/server_root/icons/ +Alias /pics/ /var/tmp/server_root/icons/ +ScriptAlias /cgi-bin/ /var/tmp/server_root/cgi-bin/ +ScriptAlias /htbin/ /var/tmp/server_root/cgi-bin/ +ErlScriptAlias /cgi-bin/erl httpd_example io +EvalScriptAlias /eval httpd_example io +SSLCertificateFile /var/tmp/server_root/ssl/ssl_server.pem +SSLCertificateKeyFile /var/tmp/server_root/ssl/ssl_server.pem +SSLVerifyClient 0 +#Script HEAD /cgi-bin/printenv.sh +#Action image/gif /cgi-bin/printenv.sh + +<Directory /var/tmp/server_root/htdocs/open> +AuthName Open Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret> +AuthName Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/secret/top_secret> +AuthName Top Secret Area +AuthUserFile /var/tmp/server_root/auth/passwd +AuthGroupFile /var/tmp/server_root/auth/group +require group group3 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_open> +AuthName Open Area +AuthMnesiaDB On +require user one Aladdin +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret> +AuthName Secret Area +AuthMnesiaDB On +require group group1 group2 +</Directory> + +<Directory /var/tmp/server_root/htdocs/mnesia_secret/top_secret> +AuthName Top Secret Area +AuthMnesiaDB On +require group group3 +</Directory> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/config.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/config.shtml new file mode 100644 index 0000000000..107e3ff610 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/config.shtml @@ -0,0 +1,70 @@ +<HTML> +<HEAD> +<TITLE>/ssi.html (17-Apr-1997)</TITLE> +</HEAD> +<BODY> +<H1>/ssi.html</H1> + +<!-- ************* CONFIG ************* --> + +<!--#config timefmt="%a %b %e %T %Z %Y" sizefmt="abbrev"--> +<!--#config errmsg="[an especially ugly error occurred while processing this directive]"--> + +<!-- ************* INCLUDE ************* --> + +<P>Include /misc/friedrich.html: +<!--#include virtual="/misc/friedrich.html"--> +<P>Include /misc/not_defined.html: <!--#include virtual="/misc/not_defined.html"--> +<P>Include misc/friedrich.html: +<!--#include file="misc/friedrich.html"--> +<P>Include not_defined.html: <!--#include file="not_defined.html"--> + +<P><HR> + +<!-- ************* ECHO ************* --> + +<P>DOCUMENT_NAME: <!--#echo var="DOCUMENT_NAME"--> +<P>DOCUMENT_URI: <!--#echo var="DOCUMENT_URI"--> +<P>QUERY_STRING_UNESCAPED: <!--#echo var="QUERY_STRING_UNESCAPED"--> +<P>DATE_LOCAL: <!--#echo var="DATE_LOCAL"--> +<P>DATE_GMT: <!--#echo var="DATE_GMT"--> +<P>LAST_MODIFIED: <!--#echo var="LAST_MODIFIED"--> +<P>NOT_DEFINED: <!--#echo var="NOT_DEFINED"--> + +<P><HR> + +<!-- ************* FSIZE ************* --> + +<P>Size of index.html: <!--#fsize file="index.html"--> +<P>Size of not_defined.html: <!--#fsize file="not_defined.html"--> +<!--#config sizefmt="bytes"--> +<P>Size of /misc/friedrich.html: <!--#fsize virtual="/misc/friedrich.html"--> +<P>Size of /misc/not_defined.html: <!--#fsize virtual="/misc/not_defined.html"--> + +<P><HR> + +<!-- ************* FLASTMOD ************* --> + +<P>Last modification of index.html: <!--#flastmod file="index.html"--> +<P>Last modification of not_defined.html: <!--#flastmod file="not_defined.html"--> +<P>Last modification of /misc/friedrich.html: <!--#flastmod virtual="/misc/friedrich.html"--> +<P>Last modification of /misc/not_defined.html: <!--#flastmod virtual="/misc/not_defined.html"--> + +<!--#exec cmd="ls"--> +<!--#exec cmd="printenv"--> +<!--#exec cmd="sunemaja"--> + +<!--#exec cgi="/cgi-bin/printenv.sh"--> + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/dets_open/dummy.html b/lib/inets/test/httpd_test_data/server_root/htdocs/dets_open/dummy.html new file mode 100644 index 0000000000..a6e8a35a04 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/dets_open/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/open/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/open/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/dets_secret/dummy.html b/lib/inets/test/httpd_test_data/server_root/htdocs/dets_secret/dummy.html new file mode 100644 index 0000000000..016b04e540 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/dets_secret/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/secret/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/secret/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/dets_secret/top_secret/index.html b/lib/inets/test/httpd_test_data/server_root/htdocs/dets_secret/top_secret/index.html new file mode 100644 index 0000000000..34db3d5d1a --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/dets_secret/top_secret/index.html @@ -0,0 +1,9 @@ +<HTML> +<HEAD> +<TITLE>/secret/top_secret/index.html (04-Feb-1998)</TITLE> +<!-- Created by: Mattias Nilsson, 04-Feb-1998 --> +</HEAD> +<BODY> +<H1>/secret/top_secret/index.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/echo.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/echo.shtml new file mode 100644 index 0000000000..141db5be59 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/echo.shtml @@ -0,0 +1,35 @@ +<HTML> +<HEAD> +<TITLE>/echo.shtml</TITLE> +</HEAD> +<BODY> +<H1>/echo.shtml</H1> + +<P>DOCUMENT_NAME: <!--#echo var="DOCUMENT_NAME"--> + +<P>DOCUMENT_URI: <!--#echo var="DOCUMENT_URI"--> + +<P>QUERY_STRING_UNESCAPED: <!--#echo var="QUERY_STRING_UNESCAPED"--> + +<P>DATE_LOCAL: <!--#echo var="DATE_LOCAL"--> + +<P>DATE_GMT: <!--#echo var="DATE_GMT"--> + +<P>LAST_MODIFIED: <!--#echo var="LAST_MODIFIED"--> + +<P>NOT_DEFINED: <!--#echo var="NOT_DEFINED"--> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/exec.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/exec.shtml new file mode 100644 index 0000000000..97333da898 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/exec.shtml @@ -0,0 +1,30 @@ +<HTML> +<HEAD> +<TITLE>/exec.shtml</TITLE> +</HEAD> +<BODY> +<H1>/exec.shtml</H1> +<PRE> +<!--#exec cmd="ls"--> +<HR> +<!--#exec cmd="printenv"--> +<HR> +<!--#exec cmd="sunemaja"--> +<HR> +<!--#exec cgi="/cgi-bin/printenv.sh"--> +</PRE> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/flastmod.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/flastmod.shtml new file mode 100644 index 0000000000..d54c36fe50 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/flastmod.shtml @@ -0,0 +1,29 @@ +<HTML> +<HEAD> +<TITLE>/flastmod.shtml</TITLE> +</HEAD> +<BODY> +<H1>/flastmod.shtml</H1> + +<P>Last modification of index.html: <!--#flastmod file="index.html"--> + +<P>Last modification of not_defined.html: <!--#flastmod file="not_defined.html"--> + +<P>Last modification of /misc/friedrich.html: <!--#flastmod virtual="/misc/friedrich.html"--> + +<P>Last modification of /misc/not_defined.html: <!--#flastmod virtual="/misc/not_defined.html"--> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/fsize.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/fsize.shtml new file mode 100644 index 0000000000..570ee9cf6d --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/fsize.shtml @@ -0,0 +1,29 @@ +<HTML> +<HEAD> +<TITLE>/fsize.shtml</TITLE> +</HEAD> +<BODY> +<H1>/fsize.shtml</H1> + +<P>Size of index.html: <!--#fsize file="index.html"--> + +<P>Size of not_defined.html: <!--#fsize file="not_defined.html"--> + +<P>Size of /misc/friedrich.html: <!--#fsize virtual="/misc/friedrich.html"--> + +<P>Size of /misc/not_defined.html: <!--#fsize virtual="/misc/not_defined.html"--> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/include.shtml b/lib/inets/test/httpd_test_data/server_root/htdocs/include.shtml new file mode 100644 index 0000000000..529aad0437 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/include.shtml @@ -0,0 +1,33 @@ +<HTML> +<HEAD> +<TITLE>/include.shtml</TITLE> +</HEAD> +<BODY> +<H1>/include.shtml</H1> + +<P>Include /misc/friedrich.html: +<!--#include virtual="/misc/friedrich.html"--> + +<P>Include /misc/not_defined.html: +<!--#include virtual="/misc/not_defined.html"--> + +<P>Include misc/friedrich.html: +<!--#include file="misc/friedrich.html"--> + +<P>Include not_defined.html: +<!--#include file="not_defined.html"--> + +<P>[<A HREF="ssi.html">Back</A>] + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/index.html b/lib/inets/test/httpd_test_data/server_root/htdocs/index.html new file mode 100644 index 0000000000..cfdc9f9ab7 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/index.html @@ -0,0 +1,25 @@ +<HTML> +<HEAD> +<TITLE>/index.html</TITLE> +</HEAD> +<BODY> +<H1>/index.html</H1> + +<STRONG>Server-Side Include (SSI) commands:</STRONG><BR> +<A HREF="config.shtml">config</A><BR> +<A HREF="echo.shtml">echo</A><BR> +<A HREF="exec.shtml">exec</A><BR> +<A HREF="flastmod.shtml">flastmod</A><BR> +<A HREF="fsize.shtml">fsize</A><BR> +<A HREF="include.shtml">include</A><BR> + +<BR> +<BR> + +<STRONG>ESI callback:</STRING><BR> +<A HREF="cgi-bin/erl/httpd_example/get">cgi-bin/erl/httpd_example/get</A><BR> +<A HREF="cgi-bin/erl/httpd_example/yahoo">cgi-bin/erl/httpd_example/yahoo</A><BR> +<A HREF="cgi-bin/erl/httpd_example/test1">cgi-bin/erl/httpd_example/test1</A><BR> + +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/last_modified.html b/lib/inets/test/httpd_test_data/server_root/htdocs/last_modified.html new file mode 100644 index 0000000000..65c1790813 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/last_modified.html @@ -0,0 +1,22 @@ +<HTML> +<HEAD> +<TITLE>/last_modified.html</TITLE> +</HEAD> +<BODY> +<H1>/last_modified.html</H1> + +<P>This document is only used for test of illegal last-modified date.</P> + + +</BODY> +</HTML> + + + + + + + + + + diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/misc/friedrich.html b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/friedrich.html new file mode 100644 index 0000000000..d7953d5df4 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/friedrich.html @@ -0,0 +1,7 @@ +<P><CITE> +Talking much about oneself can also be a means to conceal oneself.<BR> +-- Friedrich Nietzsche +</CITE> + +<P>Nested Include: +<!--#include file="misc/oech.html"--> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/misc/oech.html b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/oech.html new file mode 100644 index 0000000000..506064bf04 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/oech.html @@ -0,0 +1,4 @@ +<P><CITE> +What excuses stand in your way? How can you eliminate them?<BR> +-- Roger von Oech +</CITE> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/misc/welcome.html b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/welcome.html new file mode 100644 index 0000000000..8c17451f91 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/misc/welcome.html @@ -0,0 +1 @@ +<HTML></HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_open/dummy.html b/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_open/dummy.html new file mode 100644 index 0000000000..a6e8a35a04 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_open/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/open/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/open/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_secret/dummy.html b/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_secret/dummy.html new file mode 100644 index 0000000000..016b04e540 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_secret/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/secret/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/secret/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_secret/top_secret/index.html b/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_secret/top_secret/index.html new file mode 100644 index 0000000000..2d17e8b596 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/mnesia_secret/top_secret/index.html @@ -0,0 +1,9 @@ +<HTML> +<HEAD> +<TITLE>/mnesia_secret/top_secret/index.html (04-Feb-1998)</TITLE> +<!-- Created by: Mattias Nilsson, 04-Feb-1998 --> +</HEAD> +<BODY> +<H1>/mnesia_secret/top_secret/index.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/open/dummy.html b/lib/inets/test/httpd_test_data/server_root/htdocs/open/dummy.html new file mode 100644 index 0000000000..a6e8a35a04 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/open/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/open/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/open/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/secret/dummy.html b/lib/inets/test/httpd_test_data/server_root/htdocs/secret/dummy.html new file mode 100644 index 0000000000..016b04e540 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/secret/dummy.html @@ -0,0 +1,10 @@ +<HTML> +<HEAD> +<TITLE>/secret/dummy.html (17-Apr-1997)</TITLE> +<!-- Created by: Joakim Greben�, 17-Apr-1997 --> +<!-- Changed by: Joakim Greben�, 17-Apr-1997 --> +</HEAD> +<BODY> +<H1>/secret/dummy.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/htdocs/secret/top_secret/index.html b/lib/inets/test/httpd_test_data/server_root/htdocs/secret/top_secret/index.html new file mode 100644 index 0000000000..34db3d5d1a --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/htdocs/secret/top_secret/index.html @@ -0,0 +1,9 @@ +<HTML> +<HEAD> +<TITLE>/secret/top_secret/index.html (04-Feb-1998)</TITLE> +<!-- Created by: Mattias Nilsson, 04-Feb-1998 --> +</HEAD> +<BODY> +<H1>/secret/top_secret/index.html</H1> +</BODY> +</HTML> diff --git a/lib/inets/test/httpd_test_data/server_root/icons/README b/lib/inets/test/httpd_test_data/server_root/icons/README new file mode 100644 index 0000000000..a1fc5a5a9c --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/README @@ -0,0 +1,161 @@ +Public Domain Icons + + These icons were originally made for Mosaic for X and have been + included in the NCSA httpd and Apache server distributions in the + past. They are in the public domain and may be freely included in any + application. The originals were done by Kevin Hughes ([email protected]). + + Many thanks to Andy Polyakov for tuning the icon colors and adding a + few new images. If you'd like to contribute additions or ideas to + this set, please let me know. + + The distribution site for these icons is at: + + http://www.eit.com/goodies/www.icons/ + + Kevin Hughes + September 11, 1995 + + +Suggested Uses + +The following are a few suggestions, to serve as a starting point for ideas. +Please feel free to tweak and rename the icons as you like. + + a.gif + This might be used to represent PostScript or text layout + languages. + + alert.black.gif, alert.red.gif + These can be used to highlight any important items, such as a + README file in a directory. + + back.gif, forward.gif + These can be used as links to go to previous and next areas. + + ball.gray.gif, ball.red.gif + These might be used as bullets. + + binary.gif + This can be used to represent binary files. + + binhex.gif + This can represent BinHex-encoded data. + + blank.gif + This can be used as a placeholder or a spacing element. + + bomb.gif + This can be used to repreesnt core files. + + box1.gif, box2.gif + These icons can be used to represent generic 3D applications and + related files. + + broken.gif + This can represent corrupted data. + + burst.gif + This can call attention to new and important items. + + c.gif + This might represent C source code. + + comp.blue.gif, comp.red.gif + These little computer icons can stand for telnet or FTP + sessions. + + compressed.gif + This may represent compressed data. + + continued.gif + This can be a link to a continued listing of a directory. + + down.gif, up.gif, left.gif, right.gif + These can be used to scroll up, down, left and right in a + listing or may be used to denote items in an outline. + + dvi.gif + This can represent DVI files. + + f.gif + This might represent FORTRAN or Forth source code. + + folder.gif, folder.open.gif, folder.sec.gif + The folder can represent directories. There is also a version + that can represent secure directories or directories that cannot + be viewed. + + generic.gif, generic.sec.gif, generic.red.gif + These can represent generic files, secure files, and important + files, respectively. + + hand.right.gif, hand.up.gif + These can point out important items (pun intended). + + image1.gif, image2.gif, image3.gif + These can represent image formats of various types. + + index.gif + This might represent a WAIS index or search facility. + + layout.gif + This might represent files and formats that contain graphics as + well as text layout, such as HTML and PDF files. + + link.gif + This might represent files that are symbolic links. + + movie.gif + This can represent various movie formats. + + p.gif + This may stand for Perl or Python source code. + + pie0.gif ... pie8.gif + These icons can be used in applications where a list of + documents is returned from a search. The little pie chart images + can denote how relevant the documents may be to your search + query. + + patch.gif + This may stand for patches and diff files. + + portal.gif + This might be a link to an online service or a 3D world. + + ps.gif, quill.gif + These may represent PostScript files. + + screw1.gif, screw2.gif + These may represent CAD or engineering data and formats. + + script.gif + This can represent any of various interpreted languages, such as + Perl, python, TCL, and shell scripts, as well as server + configuration files. + + sound1.gif, sound2.gif + These can represent sound files. + + sphere1.gif, sphere2.gif + These can represent 3D worlds or rendering applications and + formats. + + tex.gif + This can represent TeX files. + + text.gif + This can represent generic (plain) text files. + + transfer.gif + This can represent FTP transfers or uploads/downloads. + + unknown.gif + This may represent a file of an unknown type. + + uuencoded.gif + This can stand for uuencoded data. + + world1.gif, world2.gif + These can represent 3D worlds or other 3D formats. diff --git a/lib/inets/test/httpd_test_data/server_root/icons/a.gif b/lib/inets/test/httpd_test_data/server_root/icons/a.gif Binary files differnew file mode 100644 index 0000000000..bb23d971f4 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/a.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/alert.black.gif b/lib/inets/test/httpd_test_data/server_root/icons/alert.black.gif Binary files differnew file mode 100644 index 0000000000..eaecd2172a --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/alert.black.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/alert.red.gif b/lib/inets/test/httpd_test_data/server_root/icons/alert.red.gif Binary files differnew file mode 100644 index 0000000000..a423894043 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/alert.red.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/apache_pb.gif b/lib/inets/test/httpd_test_data/server_root/icons/apache_pb.gif Binary files differnew file mode 100644 index 0000000000..3a1c139fc4 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/apache_pb.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/back.gif b/lib/inets/test/httpd_test_data/server_root/icons/back.gif Binary files differnew file mode 100644 index 0000000000..a694ae1ec3 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/back.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/ball.gray.gif b/lib/inets/test/httpd_test_data/server_root/icons/ball.gray.gif Binary files differnew file mode 100644 index 0000000000..eb84268c4c --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/ball.gray.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/ball.red.gif b/lib/inets/test/httpd_test_data/server_root/icons/ball.red.gif Binary files differnew file mode 100644 index 0000000000..a8425cb574 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/ball.red.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/binary.gif b/lib/inets/test/httpd_test_data/server_root/icons/binary.gif Binary files differnew file mode 100644 index 0000000000..9a15cbae04 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/binary.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/binhex.gif b/lib/inets/test/httpd_test_data/server_root/icons/binhex.gif Binary files differnew file mode 100644 index 0000000000..62d0363108 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/binhex.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/blank.gif b/lib/inets/test/httpd_test_data/server_root/icons/blank.gif Binary files differnew file mode 100644 index 0000000000..0ccf01e198 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/blank.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/bomb.gif b/lib/inets/test/httpd_test_data/server_root/icons/bomb.gif Binary files differnew file mode 100644 index 0000000000..270fdb1c06 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/bomb.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/box1.gif b/lib/inets/test/httpd_test_data/server_root/icons/box1.gif Binary files differnew file mode 100644 index 0000000000..65dcd002ea --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/box1.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/box2.gif b/lib/inets/test/httpd_test_data/server_root/icons/box2.gif Binary files differnew file mode 100644 index 0000000000..c43bc4faec --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/box2.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/broken.gif b/lib/inets/test/httpd_test_data/server_root/icons/broken.gif Binary files differnew file mode 100644 index 0000000000..9f8cbe9f76 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/broken.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/burst.gif b/lib/inets/test/httpd_test_data/server_root/icons/burst.gif Binary files differnew file mode 100644 index 0000000000..fbdcf575f7 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/burst.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button1.gif b/lib/inets/test/httpd_test_data/server_root/icons/button1.gif Binary files differnew file mode 100644 index 0000000000..eb97cb7333 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button1.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button10.gif b/lib/inets/test/httpd_test_data/server_root/icons/button10.gif Binary files differnew file mode 100644 index 0000000000..fe0c97998c --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button10.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button2.gif b/lib/inets/test/httpd_test_data/server_root/icons/button2.gif Binary files differnew file mode 100644 index 0000000000..7698455bf9 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button2.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button3.gif b/lib/inets/test/httpd_test_data/server_root/icons/button3.gif Binary files differnew file mode 100644 index 0000000000..a8b8319232 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button3.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button4.gif b/lib/inets/test/httpd_test_data/server_root/icons/button4.gif Binary files differnew file mode 100644 index 0000000000..0fd15a0d7f --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button4.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button5.gif b/lib/inets/test/httpd_test_data/server_root/icons/button5.gif Binary files differnew file mode 100644 index 0000000000..64241e5c5d --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button5.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button6.gif b/lib/inets/test/httpd_test_data/server_root/icons/button6.gif Binary files differnew file mode 100644 index 0000000000..867cfd1212 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button6.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button7.gif b/lib/inets/test/httpd_test_data/server_root/icons/button7.gif Binary files differnew file mode 100644 index 0000000000..b3f5fb248f --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button7.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button8.gif b/lib/inets/test/httpd_test_data/server_root/icons/button8.gif Binary files differnew file mode 100644 index 0000000000..7a308be8f6 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button8.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/button9.gif b/lib/inets/test/httpd_test_data/server_root/icons/button9.gif Binary files differnew file mode 100644 index 0000000000..9acba576c0 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/button9.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/buttonl.gif b/lib/inets/test/httpd_test_data/server_root/icons/buttonl.gif Binary files differnew file mode 100644 index 0000000000..3883088e7a --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/buttonl.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/buttonr.gif b/lib/inets/test/httpd_test_data/server_root/icons/buttonr.gif Binary files differnew file mode 100644 index 0000000000..c4dc3887db --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/buttonr.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/c.gif b/lib/inets/test/httpd_test_data/server_root/icons/c.gif Binary files differnew file mode 100644 index 0000000000..7555b6c164 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/c.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/comp.blue.gif b/lib/inets/test/httpd_test_data/server_root/icons/comp.blue.gif Binary files differnew file mode 100644 index 0000000000..f8d76a8c23 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/comp.blue.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/comp.gray.gif b/lib/inets/test/httpd_test_data/server_root/icons/comp.gray.gif Binary files differnew file mode 100644 index 0000000000..7664cd0364 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/comp.gray.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/compressed.gif b/lib/inets/test/httpd_test_data/server_root/icons/compressed.gif Binary files differnew file mode 100644 index 0000000000..39e732739f --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/compressed.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/continued.gif b/lib/inets/test/httpd_test_data/server_root/icons/continued.gif Binary files differnew file mode 100644 index 0000000000..b0ffb7e0cc --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/continued.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/dir.gif b/lib/inets/test/httpd_test_data/server_root/icons/dir.gif Binary files differnew file mode 100644 index 0000000000..48264601ae --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/dir.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/down.gif b/lib/inets/test/httpd_test_data/server_root/icons/down.gif Binary files differnew file mode 100644 index 0000000000..a354c871cd --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/down.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/dvi.gif b/lib/inets/test/httpd_test_data/server_root/icons/dvi.gif Binary files differnew file mode 100644 index 0000000000..791be33105 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/dvi.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/f.gif b/lib/inets/test/httpd_test_data/server_root/icons/f.gif Binary files differnew file mode 100644 index 0000000000..fbe353c282 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/f.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/folder.gif b/lib/inets/test/httpd_test_data/server_root/icons/folder.gif Binary files differnew file mode 100644 index 0000000000..48264601ae --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/folder.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/folder.open.gif b/lib/inets/test/httpd_test_data/server_root/icons/folder.open.gif Binary files differnew file mode 100644 index 0000000000..30979cb528 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/folder.open.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/folder.sec.gif b/lib/inets/test/httpd_test_data/server_root/icons/folder.sec.gif Binary files differnew file mode 100644 index 0000000000..75332d9e59 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/folder.sec.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/forward.gif b/lib/inets/test/httpd_test_data/server_root/icons/forward.gif Binary files differnew file mode 100644 index 0000000000..b2959b4c85 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/forward.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/generic.gif b/lib/inets/test/httpd_test_data/server_root/icons/generic.gif Binary files differnew file mode 100644 index 0000000000..de60b2940f --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/generic.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/generic.red.gif b/lib/inets/test/httpd_test_data/server_root/icons/generic.red.gif Binary files differnew file mode 100644 index 0000000000..94743981d9 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/generic.red.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/generic.sec.gif b/lib/inets/test/httpd_test_data/server_root/icons/generic.sec.gif Binary files differnew file mode 100644 index 0000000000..88d5240c3c --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/generic.sec.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/hand.right.gif b/lib/inets/test/httpd_test_data/server_root/icons/hand.right.gif Binary files differnew file mode 100644 index 0000000000..5cdbc7206d --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/hand.right.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/hand.up.gif b/lib/inets/test/httpd_test_data/server_root/icons/hand.up.gif Binary files differnew file mode 100644 index 0000000000..85a5d68317 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/hand.up.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/htdig.gif b/lib/inets/test/httpd_test_data/server_root/icons/htdig.gif Binary files differnew file mode 100644 index 0000000000..35443fb63a --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/htdig.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/icon.sheet.gif b/lib/inets/test/httpd_test_data/server_root/icons/icon.sheet.gif Binary files differnew file mode 100644 index 0000000000..ad1686e448 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/icon.sheet.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/image1.gif b/lib/inets/test/httpd_test_data/server_root/icons/image1.gif Binary files differnew file mode 100644 index 0000000000..01e442bfa9 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/image1.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/image2.gif b/lib/inets/test/httpd_test_data/server_root/icons/image2.gif Binary files differnew file mode 100644 index 0000000000..751faeea36 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/image2.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/image3.gif b/lib/inets/test/httpd_test_data/server_root/icons/image3.gif Binary files differnew file mode 100644 index 0000000000..4f30484ff6 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/image3.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/index.gif b/lib/inets/test/httpd_test_data/server_root/icons/index.gif Binary files differnew file mode 100644 index 0000000000..162478fb3a --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/index.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/layout.gif b/lib/inets/test/httpd_test_data/server_root/icons/layout.gif Binary files differnew file mode 100644 index 0000000000..c96338a152 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/layout.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/left.gif b/lib/inets/test/httpd_test_data/server_root/icons/left.gif Binary files differnew file mode 100644 index 0000000000..279e6710d4 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/left.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/link.gif b/lib/inets/test/httpd_test_data/server_root/icons/link.gif Binary files differnew file mode 100644 index 0000000000..c5b6889a76 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/link.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/movie.gif b/lib/inets/test/httpd_test_data/server_root/icons/movie.gif Binary files differnew file mode 100644 index 0000000000..0035183774 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/movie.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/p.gif b/lib/inets/test/httpd_test_data/server_root/icons/p.gif Binary files differnew file mode 100644 index 0000000000..7b917b4e91 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/p.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/patch.gif b/lib/inets/test/httpd_test_data/server_root/icons/patch.gif Binary files differnew file mode 100644 index 0000000000..39bc90e795 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/patch.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pdf.gif b/lib/inets/test/httpd_test_data/server_root/icons/pdf.gif Binary files differnew file mode 100644 index 0000000000..c88fd777c4 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pdf.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie0.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie0.gif Binary files differnew file mode 100644 index 0000000000..6f7a0ae7a7 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie0.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie1.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie1.gif Binary files differnew file mode 100644 index 0000000000..03aa6be71e --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie1.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie2.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie2.gif Binary files differnew file mode 100644 index 0000000000..b04c5e0908 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie2.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie3.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie3.gif Binary files differnew file mode 100644 index 0000000000..4db9d023ed --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie3.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie4.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie4.gif Binary files differnew file mode 100644 index 0000000000..93471fdd88 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie4.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie5.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie5.gif Binary files differnew file mode 100644 index 0000000000..57aee93f07 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie5.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie6.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie6.gif Binary files differnew file mode 100644 index 0000000000..0dc327b569 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie6.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie7.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie7.gif Binary files differnew file mode 100644 index 0000000000..8661337f06 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie7.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/pie8.gif b/lib/inets/test/httpd_test_data/server_root/icons/pie8.gif Binary files differnew file mode 100644 index 0000000000..59ddb34ce0 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/pie8.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/portal.gif b/lib/inets/test/httpd_test_data/server_root/icons/portal.gif Binary files differnew file mode 100644 index 0000000000..0e6e506e00 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/portal.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/poweredby.gif b/lib/inets/test/httpd_test_data/server_root/icons/poweredby.gif Binary files differnew file mode 100644 index 0000000000..d324ab80ea --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/poweredby.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/ps.gif b/lib/inets/test/httpd_test_data/server_root/icons/ps.gif Binary files differnew file mode 100644 index 0000000000..0f565bc1db --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/ps.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/quill.gif b/lib/inets/test/httpd_test_data/server_root/icons/quill.gif Binary files differnew file mode 100644 index 0000000000..818a5cdc7e --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/quill.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/right.gif b/lib/inets/test/httpd_test_data/server_root/icons/right.gif Binary files differnew file mode 100644 index 0000000000..b256e5f75f --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/right.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/screw1.gif b/lib/inets/test/httpd_test_data/server_root/icons/screw1.gif Binary files differnew file mode 100644 index 0000000000..af6ba2b097 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/screw1.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/screw2.gif b/lib/inets/test/httpd_test_data/server_root/icons/screw2.gif Binary files differnew file mode 100644 index 0000000000..06dccb3e44 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/screw2.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/script.gif b/lib/inets/test/httpd_test_data/server_root/icons/script.gif Binary files differnew file mode 100644 index 0000000000..d8a853bc58 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/script.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/sound1.gif b/lib/inets/test/httpd_test_data/server_root/icons/sound1.gif Binary files differnew file mode 100644 index 0000000000..8efb49f55d --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/sound1.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/sound2.gif b/lib/inets/test/httpd_test_data/server_root/icons/sound2.gif Binary files differnew file mode 100644 index 0000000000..48e6a7fb2f --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/sound2.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/sphere1.gif b/lib/inets/test/httpd_test_data/server_root/icons/sphere1.gif Binary files differnew file mode 100644 index 0000000000..7067070da2 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/sphere1.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/sphere2.gif b/lib/inets/test/httpd_test_data/server_root/icons/sphere2.gif Binary files differnew file mode 100644 index 0000000000..a9e462a377 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/sphere2.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/star.gif b/lib/inets/test/httpd_test_data/server_root/icons/star.gif Binary files differnew file mode 100644 index 0000000000..4cfe0a5e0f --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/star.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/star_blank.gif b/lib/inets/test/httpd_test_data/server_root/icons/star_blank.gif Binary files differnew file mode 100644 index 0000000000..a0c83cb85b --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/star_blank.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/tar.gif b/lib/inets/test/httpd_test_data/server_root/icons/tar.gif Binary files differnew file mode 100644 index 0000000000..617e779efa --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/tar.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/tex.gif b/lib/inets/test/httpd_test_data/server_root/icons/tex.gif Binary files differnew file mode 100644 index 0000000000..45e43233b8 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/tex.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/text.gif b/lib/inets/test/httpd_test_data/server_root/icons/text.gif Binary files differnew file mode 100644 index 0000000000..4c623909fb --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/text.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/transfer.gif b/lib/inets/test/httpd_test_data/server_root/icons/transfer.gif Binary files differnew file mode 100644 index 0000000000..33697dbb66 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/transfer.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/unknown.gif b/lib/inets/test/httpd_test_data/server_root/icons/unknown.gif Binary files differnew file mode 100644 index 0000000000..32b1ea23fb --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/unknown.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/up.gif b/lib/inets/test/httpd_test_data/server_root/icons/up.gif Binary files differnew file mode 100644 index 0000000000..6d6d6d1ebf --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/up.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/uu.gif b/lib/inets/test/httpd_test_data/server_root/icons/uu.gif Binary files differnew file mode 100644 index 0000000000..4387d529f6 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/uu.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/uuencoded.gif b/lib/inets/test/httpd_test_data/server_root/icons/uuencoded.gif Binary files differnew file mode 100644 index 0000000000..4387d529f6 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/uuencoded.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/world1.gif b/lib/inets/test/httpd_test_data/server_root/icons/world1.gif Binary files differnew file mode 100644 index 0000000000..05b4ec2058 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/world1.gif diff --git a/lib/inets/test/httpd_test_data/server_root/icons/world2.gif b/lib/inets/test/httpd_test_data/server_root/icons/world2.gif Binary files differnew file mode 100644 index 0000000000..e3203f7a88 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/icons/world2.gif diff --git a/lib/inets/test/httpd_test_data/server_root/logs/Dummy_File_Needed_By_WinZip b/lib/inets/test/httpd_test_data/server_root/logs/Dummy_File_Needed_By_WinZip new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/logs/Dummy_File_Needed_By_WinZip @@ -0,0 +1 @@ + diff --git a/lib/inets/test/httpd_test_data/server_root/ssl/ssl_client.pem b/lib/inets/test/httpd_test_data/server_root/ssl/ssl_client.pem new file mode 100644 index 0000000000..8221139eb4 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/ssl/ssl_client.pem @@ -0,0 +1,22 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBPAIBAAJBAL6Ym/bgUvhhnPkw08sggGg8Tnp759ThGMEjkmDzhuJ3w3PfnF65 +mgHcgunku4G6LxAQfEUougJWf9Phmjj3oRUCAwEAAQJBAKMjvVvzZxFzfAlP4flc +OI0AEayFokp04dtvtzuFN09f+aBo2dP18xHmKLCZvxrBOaRAROoQYscALiIVpN07 +GAECIQDfi+sSfAFaDlT3vzpL3xE5UEH6IzY8jWpaZfM1QaToJQIhANpEF50H4wGO +8Sbh7dUutNd+s+NYUjsMySW2DjLKMsoxAiEAzzb2ftrdsempD0F+O0gZwiPIFKLB +Kp33YLYyHEKuJtUCIDGi+pvDh2R7VWw6RRQOIyI+tjolg83aAoSI+oGiahqBAiEA +xzmNNajwoaokvWvlaz0na8rhxu45grOvDrflBT9XvSQ= +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICDDCCAbYCAQAwDQYJKoZIhvcNAQEEBQAwgZAxCzAJBgNVBAYTAlNFMRIwEAYD +VQQIEwlTdG9ja2hvbG0xDzANBgNVBAcTBkFsdnNqbzEMMAoGA1UEChMDRVRYMQ4w +DAYDVQQLEwVETi9TUDEXMBUGA1UEAxMOSm9ha2ltIEdyZWJlbm8xJTAjBgkqhkiG +9w0BCQEWFmpvY2tlQGVyaXguZXJpY3Nzb24uc2UwHhcNOTcwNzE1MTUzNDM2WhcN +MDMwMjIyMTUzNDM2WjCBkDELMAkGA1UEBhMCU0UxEjAQBgNVBAgTCVN0b2NraG9s +bTEPMA0GA1UEBxMGQWx2c2pvMQwwCgYDVQQKEwNFVFgxDjAMBgNVBAsTBUROL1NQ +MRcwFQYDVQQDEw5Kb2FraW0gR3JlYmVubzElMCMGCSqGSIb3DQEJARYWam9ja2VA +ZXJpeC5lcmljc3Nvbi5zZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC+mJv24FL4 +YZz5MNPLIIBoPE56e+fU4RjBI5Jg84bid8Nz35xeuZoB3ILp5LuBui8QEHxFKLoC +Vn/T4Zo496EVAgMBAAEwDQYJKoZIhvcNAQEEBQADQQBYxQVfTydyZCE0UXvZd7Ei +josNsAaWJk9fFIJaG9uyXCEfg2dVgoT2eBk3D9DI+7OB+78isM5CVlFbL7hilvP8 +-----END CERTIFICATE----- diff --git a/lib/inets/test/httpd_test_data/server_root/ssl/ssl_server.pem b/lib/inets/test/httpd_test_data/server_root/ssl/ssl_server.pem new file mode 100644 index 0000000000..fe739c15f7 --- /dev/null +++ b/lib/inets/test/httpd_test_data/server_root/ssl/ssl_server.pem @@ -0,0 +1,22 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBOwIBAAJBAL9Bozj3BIjL5Cy8b3rjMT2kPZRychX4wz9bHoIIiKnKo1xXHYjw +g3N9zWM1f1ZzMADwVry1uAInA8q09+7hL20CAwEAAQJACwu2ao7RozjrV64WXimK +6X131P/7GMvCMwGHNIlbozqoOqmZcYrbKaF61l+XuwA2QvTo3ywW1Ivxcyr6TeAr +PQIhAOX+WXT6yiqqwjt08kjBCJyMgfZtdAO6pc/6pKjNWiZfAiEA1OH1iPW/OQe5 +tlQXpiRVdLyneNsPygPRJc4Bdwu3hbMCIQDbI5pA56QxOzqOREOGJsb5wrciAfAE +jZbnr72sSN2YqQIgAWFpvzagw9Tp/mWzNY+cwkIK7/yzsIKv04fveH8p9IMCIQCr +td4IiukeUwXmPSvYM4uCE/+J89wEL9qU8Mlc3gDLXA== +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICDDCCAbYCAQAwDQYJKoZIhvcNAQEEBQAwgZAxCzAJBgNVBAYTAlNFMRIwEAYD +VQQIEwlTdG9ja2hvbG0xDzANBgNVBAcTBkFsdnNqbzEMMAoGA1UEChMDRVRYMQ4w +DAYDVQQLEwVETi9TUDEXMBUGA1UEAxMOSm9ha2ltIEdyZWJlbm8xJTAjBgkqhkiG +9w0BCQEWFmpvY2tlQGVyaXguZXJpY3Nzb24uc2UwHhcNOTcwNzE1MTUzMzQxWhcN +MDMwMjIyMTUzMzQxWjCBkDELMAkGA1UEBhMCU0UxEjAQBgNVBAgTCVN0b2NraG9s +bTEPMA0GA1UEBxMGQWx2c2pvMQwwCgYDVQQKEwNFVFgxDjAMBgNVBAsTBUROL1NQ +MRcwFQYDVQQDEw5Kb2FraW0gR3JlYmVubzElMCMGCSqGSIb3DQEJARYWam9ja2VA +ZXJpeC5lcmljc3Nvbi5zZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC/QaM49wSI +y+QsvG964zE9pD2UcnIV+MM/Wx6CCIipyqNcVx2I8INzfc1jNX9WczAA8Fa8tbgC +JwPKtPfu4S9tAgMBAAEwDQYJKoZIhvcNAQEEBQADQQAmXDY1CyJjzvQZX442kkHG +ic9QFY1UuVfzokzNMwlHYl1Qx9zaodx0cJCrcH5GF9O9LJbhhV77LzoxT1Q5wZp5 +-----END CERTIFICATE----- diff --git a/lib/inets/test/httpd_test_lib.erl b/lib/inets/test/httpd_test_lib.erl new file mode 100644 index 0000000000..6abee5be2c --- /dev/null +++ b/lib/inets/test/httpd_test_lib.erl @@ -0,0 +1,332 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(httpd_test_lib). + +-include("inets_test_lib.hrl"). + +%% Poll functions +-export([verify_request/6, verify_request/7, is_expect/1]). + +-record(state, {request, % string() + socket, % socket() + status_line, % {Version, StatusCode, ReasonPharse} + headers, % #http_response_h{} + body, % binary() + mfa = {httpc_response, parse, [nolimit, false]}, + canceled = [], % [RequestId] + max_header_size = nolimit, % nolimit | integer() + max_body_size = nolimit, % nolimit | integer() + print = false + }). + +%%% Part of http.hrl - Temporary solution %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Response headers +-record(http_response_h,{ +%%% --- Standard "General" headers + 'cache-control', + connection, + date, + pragma, + trailer, + 'transfer-encoding', + upgrade, + via, + warning, +%%% --- Standard "Response" headers + 'accept-ranges', + age, + etag, + location, + 'proxy-authenticate', + 'retry-after', + server, + vary, + 'www-authenticate', +%%% --- Standard "Entity" headers + allow, + 'content-encoding', + 'content-language', + 'content-length' = "0", + 'content-location', + 'content-md5', + 'content-range', + 'content-type', + expires, + 'last-modified', + other=[] % list() - Key/Value list with other headers + }). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%-------------------------------------------------------------------- +%% API +%%------------------------------------------------------------------ +verify_request(SocketType, Host, Port, Node, RequestStr, Options) -> + verify_request(SocketType, Host, Port, Node, RequestStr, Options, 30000). +verify_request(SocketType, Host, Port, Node, RequestStr, Options, TimeOut) -> + {ok, Socket} = inets_test_lib:connect_bin(SocketType, Host, Port), + inets_test_lib:send(SocketType, Socket, RequestStr), + + State = case inets_regexp:match(RequestStr, "printenv") of + nomatch -> + #state{}; + _ -> + #state{print = true} + end, + + case request(State#state{request = RequestStr, socket = Socket}, TimeOut) of + {error, Reson} -> + {error, Reson}; + NewState -> + ValidateResult = validate(RequestStr, NewState, Options, + Node, Port), + inets_test_lib:close(SocketType, Socket), + ValidateResult + end. + +request(#state{mfa = {Module, Function, Args}, + request = RequestStr, socket = Socket} = State, TimeOut) -> + HeadRequest = lists:sublist(RequestStr, 1, 4), + receive + {tcp, Socket, Data} -> + print(tcp, Data, State), + case Module:Function([Data | Args]) of + {ok, Parsed} -> + handle_http_msg(Parsed, State); + {_, whole_body, _} when HeadRequest == "HEAD" -> + State#state{body = <<>>}; + NewMFA -> + request(State#state{mfa = NewMFA}, TimeOut) + end; + {tcp_closed, Socket} when Function == whole_body -> + print(tcp, "closed", State), + State#state{body = hd(Args)}; + {tcp_closed, Socket} -> + test_server:fail(connection_closed); + {tcp_error, Socket, Reason} -> + test_server:fail({tcp_error, Reason}); + {ssl, Socket, Data} -> + print(ssl, Data, State), + case Module:Function([Data | Args]) of + {ok, Parsed} -> + handle_http_msg(Parsed, State); + {_, whole_body, _} when HeadRequest == "HEAD" -> + State#state{body = <<>>}; + NewMFA -> + request(State#state{mfa = NewMFA}, TimeOut) + end; + {ssl_closed, Socket} when Function == whole_body -> + print(ssl, "closed", State), + State#state{body = hd(Args)}; + {ssl_closed, Socket} -> + test_server:fail(connection_closed); + {ssl_error, Socket, Reason} -> + test_server:fail({ssl_error, Reason}) + after TimeOut -> + test_server:fail(connection_timed_out) + end. + +handle_http_msg({Version, StatusCode, ReasonPharse, Headers, Body}, + State = #state{request = RequestStr}) -> + case is_expect(RequestStr) of + true -> + State#state{status_line = {Version, + StatusCode, + ReasonPharse}, + headers = Headers}; + false -> + handle_http_body(Body, + State#state{status_line = {Version, + StatusCode, + ReasonPharse}, + headers = Headers}) + end; + +handle_http_msg({ChunkedHeaders, Body}, + State = #state{headers = Headers}) -> + NewHeaders = http_chunk:handle_headers(Headers, ChunkedHeaders), + State#state{headers = NewHeaders, body = Body}; + +handle_http_msg(Body, State) -> + State#state{body = Body}. + +handle_http_body(<<>>, State = #state{request = "HEAD" ++ _}) -> + State#state{body = <<>>}; + +handle_http_body(Body, State = #state{headers = Headers, + max_body_size = MaxBodySize}) -> + case Headers#http_response_h.'transfer-encoding' of + "chunked" -> + case http_chunk:decode(Body, State#state.max_body_size, + State#state.max_header_size) of + {Module, Function, Args} -> + request(State#state{mfa = {Module, Function, Args}}, + 30000); + {ok, {ChunkedHeaders, NewBody}} -> + NewHeaders = http_chunk:handle_headers(Headers, + ChunkedHeaders), + State#state{headers = NewHeaders, body = NewBody} + end; + _ -> + Length = + list_to_integer(Headers#http_response_h.'content-length'), + case ((Length =< MaxBodySize) or (MaxBodySize == nolimit)) of + true -> + case httpc_response:whole_body(Body, Length) of + {ok, NewBody} -> + State#state{body = NewBody}; + MFA -> + request(State#state{mfa = MFA}, 5000) + end; + false -> + test_server:fail(body_too_big) + end + end. + +validate(RequestStr, #state{status_line = {Version, StatusCode, _}, + headers = Headers, + body = Body}, Options, N, P) -> + + %io:format("Status~p: H:~p B:~p~n", [StatusCode, Headers, Body]), + check_version(Version, Options), + case lists:keysearch(statuscode, 1, Options) of + {value, _} -> + check_status_code(StatusCode, Options, Options); + _ -> + ok + end, + do_validate(http_response:header_list(Headers), Options, N, P), + check_body(RequestStr, StatusCode, + Headers#http_response_h.'content-type', + list_to_integer(Headers#http_response_h.'content-length'), + Body). + +%%-------------------------------------------------------------------- +%% Internal functions +%%------------------------------------------------------------------ +check_version(Version, Options) -> + case lists:keysearch(version, 1, Options) of + {value, {version, Version}} -> + ok; + {value, {version, Ver}} -> + test_server:fail({wrong_version, [{got, Version}, + {expected, Ver}]}); + _ -> + case Version of + "HTTP/1.1" -> + ok; + _ -> + test_server:fail({wrong_version, [{got, Version}, + {expected, "HTTP/1.1"}]}) + end + end. + +check_status_code(StatusCode, [], Options) -> + test_server:fail({wrong_status_code, [{got, StatusCode}, + {expected, Options}]}); +check_status_code(StatusCode, Current = [_ | Rest], Options) -> + case lists:keysearch(statuscode, 1, Current) of + {value, {statuscode, StatusCode}} -> + ok; + {value, {statuscode, _OtherStatus}} -> + check_status_code(StatusCode, Rest, Options); + false -> + test_server:fail({wrong_status_code, [{got, StatusCode}, + {expected, Options}]}) + end. + +do_validate(_, [], _, _) -> + ok; +do_validate(Header, [{statuscode, _Code} | Rest], N, P) -> + do_validate(Header, Rest, N, P); +do_validate(Header, [{header, HeaderField}|Rest], N, P) -> + LowerHeaderField = http_util:to_lower(HeaderField), + case lists:keysearch(LowerHeaderField, 1, Header) of + {value, {LowerHeaderField, _Value}} -> + ok; + false -> + test_server:fail({missing_header_field, LowerHeaderField, Header}); + _ -> + test_server:fail({missing_header_field, LowerHeaderField, Header}) + end, + do_validate(Header, Rest, N, P); +do_validate(Header, [{header, HeaderField, Value}|Rest],N,P) -> + LowerHeaderField = http_util:to_lower(HeaderField), + case lists:keysearch(LowerHeaderField, 1, Header) of + {value, {LowerHeaderField, Value}} -> + ok; + false -> + test_server:fail({wrong_header_field_value, LowerHeaderField, + Header}); + _ -> + test_server:fail({wrong_header_field_value, LowerHeaderField, + Header}) + end, + do_validate(Header, Rest, N, P); +do_validate(Header,[{no_last_modified,HeaderField}|Rest],N,P) -> +% io:format("Header: ~p~nHeaderField: ~p~n",[Header,HeaderField]), + case lists:keysearch(HeaderField,1,Header) of + {value,_} -> + test_server:fail({wrong_header_field_value, HeaderField, + Header}); + _ -> + ok + end, + do_validate(Header, Rest, N, P); +do_validate(Header, [_Unknown | Rest], N, P) -> + do_validate(Header, Rest, N, P). + +is_expect(RequestStr) -> + + case inets_regexp:match(RequestStr, "xpect:100-continue") of + {match, _, _}-> + true; + _ -> + false + end. + +%% OTP-5775, content-length +check_body("GET /cgi-bin/erl/httpd_example:get_bin HTTP/1.0\r\n\r\n", 200, "text/html", Length, _Body) when Length /= 274-> + test_server:fail(content_length_error); +check_body("GET /cgi-bin/cgi_echo HTTP/1.0\r\n\r\n", 200, "text/plain", + _, Body) -> + case size(Body) of + 100 -> + ok; + _ -> + test_server:fail(content_length_error) + end; + +check_body(RequestStr, 200, "text/html", _, Body) -> + HeadRequest = lists:sublist(RequestStr, 1, 3), + case HeadRequest of + "GET" -> + inets_test_lib:check_body(binary_to_list(Body)); + _ -> + ok + end; + +check_body(_, _, _, _,_) -> + ok. + +print(Proto, Data, #state{print = true}) -> + test_server:format("Received ~p: ~p~n", [Proto, Data]); +print(_, _, #state{print = false}) -> + ok. + diff --git a/lib/inets/test/httpd_time_test.erl b/lib/inets/test/httpd_time_test.erl new file mode 100644 index 0000000000..7d6aa08542 --- /dev/null +++ b/lib/inets/test/httpd_time_test.erl @@ -0,0 +1,500 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(httpd_time_test). + +-export([t/3, t1/2, t2/2]). + +-export([do/1, do/2, do/3, do/4, do/5]). + +-export([main/5, poller_main/4, poller_loop/4]). + +-include("inets_test_lib.hrl"). + +-record(stat, {pid, time = undefined, count = undefined, res}). + + +%%% ----------------------------------------------------------------- +%%% Test suite interface +%%% + +t1(Host, Port) -> + t(ip_comm, Host, Port). + + +t2(Host, Port) -> + t(ssl, Host, Port). + + +t(SocketType, Host, Port) -> + %% put(dbg,true), + main(1, SocketType, Host, Port, 60000). + + + +%%% ----------------------------------------------------------------- +%%% Public interface when running the time test manually... +%%% + +do(Port) -> + do(ip_comm, hostname(), Port). + +do(Port, Time) when is_integer(Port) andalso is_integer(Time) -> + do(ip_comm, hostname(), Port, Time); + +do(Host, Port) -> + do(ip_comm, Host, Port). + +do(Host, Port, Time) when is_integer(Port) andalso is_integer(Time) -> + do(1, ip_comm, Host, Port, Time); + +do(SocketType, Host, Port) when is_integer(Port) -> + do(1, SocketType, Host, Port, 60000). + +do(N, SocketType, Host, Port) when is_integer(N) andalso is_integer(Port) -> + do(N, SocketType, Host, Port, 60000); + +do(SocketType, Host, Port, Time) + when is_integer(Port) andalso is_integer(Time) -> + do(1, SocketType, Host, Port, Time). + +do(N, SocketType, Host, Port, Time) + when is_integer(N) andalso is_integer(Port) andalso is_integer(Time) -> + do_it(N, SocketType, Host, Port, Time). + +do_it(N, SocketType, Host, Port, Time) -> + d("do_it -> entry with" + "~n N: ~p" + "~n SocketType: ~p" + "~n Host: ~p" + "~n Port: ~p" + "~n Time: ~p", [N, SocketType, Host, Port, Time]), + proc_lib:spawn(?MODULE, main, [N, SocketType, Host, Port, Time]). + + + +%%% ----------------------------------------------------------------- +%%% Controller (main) process +%%% + +main(N, SocketType, Host, Port, Time) + when is_integer(N) andalso + is_atom(SocketType) andalso + is_integer(Port) andalso + is_integer(Time) -> + process_flag(trap_exit,true), + put(sname,ctrl), + %% put(dbg,true), + d("main -> entry"), + Pollers = start_pollers(N, [self(), SocketType, Host, Port]), + d("main -> Pollers: ~p", [Pollers]), + loop(Pollers, Time). + +loop(Pollers, Timeout) -> + d("loop -> entry when" + "~n Timeout: ~p", [Timeout]), + Start = t(), + receive + {'EXIT', Pid, {poller_stat_failure, Time, Reason}} -> + case is_poller(Pid, Pollers) of + true -> + error_msg("received unexpected exit from poller ~p~n" + "befor completion of test " + "(after ~p micro sec):~n" + "~p~n", [Pid,Time,Reason]), + exit({fail, {poller_exit, Pid, Reason}}); + false -> + error_msg("received unexpected ~p from ~p" + "befor completion of test", [Reason, Pid]), + loop(Pollers, to(Timeout, Start)) + end; + + {poller_stat_failure, Pid, {Time, Reason}} -> + error_msg("received stat failure ~p from poller ~p after ~p " + "befor completion of test", [Reason, Pid, Time]), + exit({fail, {poller_failure, Pid, Reason}}); + + {poller_stat_failure, Pid, Reason} -> + error_msg("received stat failure ~p from poller ~p " + "befor completion of test", [Reason, Pid]), + exit({fail, {poller_failure, Pid, Reason}}); + + Any -> + error_msg("received unexpected message befor completion of test: " + "~n ~p", [Any]), + exit({fail, Any}) + + after Timeout -> + d("loop -> timeout: stop pollers"), + stop_pollers(Pollers), + d("loop -> collect poller statistics"), + Stats = collect_poller_stat(Pollers, []), + d("loop -> Stats: ~p", [Stats]), + display_poller_stat(Stats, Timeout), + ok + end. + +collect_poller_stat([], PollersStat) -> + PollersStat; +collect_poller_stat(Pollers, PollersStat) -> + d("collect_poller_stat -> entry with" + "~n Pollers: ~p" + "~n PollersStat: ~p", [Pollers, PollersStat]), + receive + {poller_statistics, Poller, {Time, Count}} -> + d("collect_poller_stat -> got statistics from ~p", [Poller]), + case lists:keysearch(Poller, 2, Pollers) of + {value, PollerStat} -> + d("collect_poller_stat -> current statistic record: ~p", + [PollerStat]), + P = lists:keydelete(Poller, 2, Pollers), + d("collect_poller_stat -> P: ~p", [P]), + S = PollerStat#stat{time = Time, count = Count, res = ok}, + d("collect_poller_stat -> S: ~p", [S]), + collect_poller_stat(P, [S | PollersStat]); + false -> + error_msg("statistics already received for ~p", [Poller]), + collect_poller_stat(Pollers, PollersStat) + end; + {poller_stat_failure, Poller, Else} -> + error_msg("poller statistics failure for ~p with ~p", + [Poller, Else]), + case lists:keysearch(Poller, 2, Pollers) of + {value, PollerStat} -> + P = lists:keydelete(Poller, 2, Pollers), + S = PollerStat#stat{res = {error, Else}}, + collect_poller_stat(P, [S | PollerStat]); + false -> + error_msg("statistics already received for ~p", [Poller]), + collect_poller_stat(Pollers, PollersStat) + end + end. + + +display_poller_stat(Stats, T) -> + display_poller_stat(Stats, 1, T, 0). + +display_poller_stat([], _, TestTime, AccCount) -> + io:format("Total statistics:~n" + " Accumulated count: ~w~n" + " Average access time: ~w milli sec~n", + [AccCount, (TestTime/AccCount)]); +display_poller_stat([#stat{res = ok} = Stat | Stats], N, TestTime, AccCount) -> + #stat{pid = Pid, time = Time, count = Count} = Stat, + io:format("Statistics for poller ~p (~p):~n" + " time: ~w seconds~n" + " count: ~w~n" + " Average access time: ~w milli sec~n", + [Pid, N, Time/(1000*1000), Count, (TestTime/Count)]), + display_poller_stat(Stats, N + 1, TestTime, AccCount+Count); +display_poller_stat([Stat | Stats], N, TestTime, AccCount) -> + #stat{pid = Pid, res = Error} = Stat, + io:format("Statistics failed for poller ~p (~p):~n" + " ~p~n", [Pid, N, Error]), + display_poller_stat(Stats, N + 1, TestTime, AccCount). + + + +%%% ----------------------------------------------------------------- +%%% Poller process +%%% + +start_pollers(N, Args) -> + start_pollers(N, Args, []). + +start_pollers(0, _Args, Pollers) -> + Pollers; +start_pollers(N, Args, Pollers) -> + Pid = proc_lib:spawn_link(?MODULE, poller_main, Args), + start_pollers(N-1, Args, [#stat{pid = Pid} | Pollers]). + +stop_pollers(Pollers) -> + [Pid ! stop || #stat{pid = Pid} <- Pollers], + await_stop_pollers(Pollers). + +await_stop_pollers([]) -> + ok; +await_stop_pollers(Pollers0) -> + receive + {'EXIT', Pid, _Reason} -> + Pollers = lists:keydelete(Pid, 2, Pollers0), + await_stop_pollers(Pollers) + after 5000 -> + [Pid ! shutdown || #stat{pid = Pid} <- Pollers0] + end. + + +is_poller(_, []) -> + false; +is_poller(Pid, [#stat{pid = Pid}|_]) -> + true; +is_poller(Pid, [_|Rest]) -> + is_poller(Pid, Rest). + + +poller_main(Parent, SocketType, Host, Port) -> + process_flag(trap_exit,true), + put(sname,poller), + case timer:tc(?MODULE, poller_loop, [SocketType, Host, Port, uris()]) of + {Time, Count} when is_integer(Time) andalso is_integer(Count) -> + Parent ! {poller_statistics, self(), {Time, Count}}; + {Time, {'EXIT', Reason}} when is_integer(Time) -> + exit({poller_stat_failure, Time, Reason}); + {Time, Other} when is_integer(Time) -> + Parent ! {poller_stat_failure, self(), {Time, Other}}; + Else -> + Parent ! {poller_stat_failure, self(), Else} + end. + + +uris() -> + uris(get(uris)). + +uris(L) when is_list(L) -> + L; +uris(_) -> + ["/", + "/index.html"]. + + +poller_loop(SocketType, Host, Port, URIs) -> + poller_loop(SocketType, Host, Port, URIs, 0). + +poller_loop(SocketType, Host, Port, URIs, Count) -> + receive + stop -> + Count + after 0 -> + case poller_loop1(SocketType, Host, Port, URIs) of + done -> + poller_loop(SocketType, Host, Port, URIs, + Count + length(URIs)); + {error, Reason, FailURI, FailURIs} -> + SuccessCount = + Count + (length(URIs) - (length(FailURIs) + 1)), + exit({Reason, FailURI, SuccessCount}) + end + end. + + +poller_loop1(_SocketType, _Host, _Port, []) -> + done; +poller_loop1(SocketType, Host, Port, [URI | URIs]) -> + Res = inets_test_lib:connect_byte(SocketType, Host, Port), + case (catch poll(Res, SocketType, URI, "200")) of + ok -> + poller_loop1(SocketType, Host, Port, URIs); + {'EXIT', Reason} -> + {error, Reason, URI, URIs} + end. + +poll({ok, Socket}, SocketType, URI, ExpRes) -> + Req = "GET " ++ URI ++ " HTTP/1.0\r\n\r\n", + Res = inets_test_lib:send(SocketType, Socket, Req), + await_poll_response(Res, SocketType, Socket, ExpRes); +poll({error, Reason}, _SocketType, _URI, _ExpRes) -> + exit({failed_creating_socket, Reason}); +poll(Error, _SocketType, _URI, _ExpRes) -> + exit({failed_creating_socket, Error}). + +await_poll_response(ok, SocketType, Socket, ExpStatusCode) -> + receive + %% SSL receives + {ssl, Socket, Data} -> + validate(ExpStatusCode, SocketType, Socket, Data); + {ssl_closed, Socket} -> + exit(connection_closed); + {ssl_error, Socket, Error} -> + exit({connection_error, Error}); + + %% TCP receives + {tcp, Socket, Response} -> + validate(ExpStatusCode, SocketType, Socket, Response); + {tcp_closed, Socket} -> + exit(connection_closed); + {tcp_error, Socket, Error} -> + exit({connection_error, Error}) + + after 10000 -> + exit(response_timed_out) + end; +await_poll_response(Error, _SocketType, _Socket, _ExpStatusCode) -> + exit(Error). + + +validate(ExpStatusCode, SocketType, Socket, Response) -> + Sz = sz(Response), + trash_the_rest(Socket, Sz), + inets_test_lib:close(SocketType, Socket), + case inets_regexp:split(Response," ") of + {ok,["HTTP/1.0", ExpStatusCode|_]} -> + ok; + {ok,["HTTP/1.0", StatusCode|_]} -> + error_msg("Unexpected status code: ~p (~s). " + "Expected status code: ~p (~s)", + [StatusCode, status_to_message(StatusCode), + ExpStatusCode, status_to_message(ExpStatusCode)]), + exit({unexpected_response_code, StatusCode, ExpStatusCode}); + {ok,["HTTP/1.1", ExpStatusCode|_]} -> + ok; + {ok,["HTTP/1.1", StatusCode|_]} -> + error_msg("Unexpected status code: ~p (~s). " + "Expected status code: ~p (~s)", + [StatusCode, status_to_message(StatusCode), + ExpStatusCode, status_to_message(ExpStatusCode)]), + exit({unexpected_response_code, StatusCode, ExpStatusCode}) + end. + + +trash_the_rest(Socket, N) -> + receive + {ssl, Socket, Trash} -> + trash_the_rest(Socket, add(N,sz(Trash))); + {ssl_closed, Socket} -> + N; + {ssl_error, Socket, Error} -> + exit({connection_error, Error}); + + {tcp, Socket, Trash} -> + trash_the_rest(Socket, add(N,sz(Trash))); + {tcp_closed, Socket} -> + N; + {tcp_error, Socket, Error} -> + exit({connection_error, Error}) + + after 10000 -> + exit({connection_timed_out, N}) + end. + + +add(N1,N2) when is_integer(N1) andalso is_integer(N2) -> + N1 + N2; +add(N1,_) when is_integer(N1) -> + N1; +add(_,N2) when is_integer(N2) -> + N2. + + +sz(L) when is_list(L) -> + length(lists:flatten(L)); +sz(B) when is_binary(B) -> + size(B); +sz(O) -> + {unknown_size,O}. + + +%% -------------------------------------------------------------- +%% +%% Status code to printable string +%% + +status_to_message(L) when is_list(L) -> + case (catch list_to_integer(L)) of + I when is_integer(I) -> + status_to_message(I); + _ -> + io_lib:format("UNKNOWN STATUS CODE: '~p'",[L]) + end; +status_to_message(100) -> "Section 10.1.1: Continue"; +status_to_message(101) -> "Section 10.1.2: Switching Protocols"; +status_to_message(200) -> "Section 10.2.1: OK"; +status_to_message(201) -> "Section 10.2.2: Created"; +status_to_message(202) -> "Section 10.2.3: Accepted"; +status_to_message(203) -> "Section 10.2.4: Non-Authoritative Information"; +status_to_message(204) -> "Section 10.2.5: No Content"; +status_to_message(205) -> "Section 10.2.6: Reset Content"; +status_to_message(206) -> "Section 10.2.7: Partial Content"; +status_to_message(300) -> "Section 10.3.1: Multiple Choices"; +status_to_message(301) -> "Section 10.3.2: Moved Permanently"; +status_to_message(302) -> "Section 10.3.3: Found"; +status_to_message(303) -> "Section 10.3.4: See Other"; +status_to_message(304) -> "Section 10.3.5: Not Modified"; +status_to_message(305) -> "Section 10.3.6: Use Proxy"; +status_to_message(307) -> "Section 10.3.8: Temporary Redirect"; +status_to_message(400) -> "Section 10.4.1: Bad Request"; +status_to_message(401) -> "Section 10.4.2: Unauthorized"; +status_to_message(402) -> "Section 10.4.3: Peyment Required"; +status_to_message(403) -> "Section 10.4.4: Forbidden"; +status_to_message(404) -> "Section 10.4.5: Not Found"; +status_to_message(405) -> "Section 10.4.6: Method Not Allowed"; +status_to_message(406) -> "Section 10.4.7: Not Acceptable"; +status_to_message(407) -> "Section 10.4.8: Proxy Authentication Required"; +status_to_message(408) -> "Section 10.4.9: Request Time-Out"; +status_to_message(409) -> "Section 10.4.10: Conflict"; +status_to_message(410) -> "Section 10.4.11: Gone"; +status_to_message(411) -> "Section 10.4.12: Length Required"; +status_to_message(412) -> "Section 10.4.13: Precondition Failed"; +status_to_message(413) -> "Section 10.4.14: Request Entity Too Large"; +status_to_message(414) -> "Section 10.4.15: Request-URI Too Large"; +status_to_message(415) -> "Section 10.4.16: Unsupported Media Type"; +status_to_message(416) -> "Section 10.4.17: Requested range not satisfiable"; +status_to_message(417) -> "Section 10.4.18: Expectation Failed"; +status_to_message(500) -> "Section 10.5.1: Internal Server Error"; +status_to_message(501) -> "Section 10.5.2: Not Implemented"; +status_to_message(502) -> "Section 10.5.3: Bad Gatteway"; +status_to_message(503) -> "Section 10.5.4: Service Unavailable"; +status_to_message(504) -> "Section 10.5.5: Gateway Time-out"; +status_to_message(505) -> "Section 10.5.6: HTTP Version not supported"; +status_to_message(Code) -> io_lib:format("Unknown status code: ~p",[Code]). + +%% ---------------------------------------------------------------- + +to(To, Start) -> + To - (t() - Start). + +%% Time in milli seconds +t() -> + {A,B,C} = erlang:now(), + A*1000000000+B*1000+(C div 1000). + + +%% ---------------------------------------------------------------- + + + +% close(Socket) -> +% gen_tcp:close(Socket). + +% send(Socket, Data) -> +% gen_tcp:send(Socket, Data). + + +hostname() -> + {ok, Hostname} = inet:gethostname(), + hostname(Hostname). + +hostname(Hostname) when is_list(Hostname) -> + list_to_atom(Hostname); +hostname(Hostname) -> + Hostname. + +%% ---------------------------------------------------------------- + +error_msg(F,A) -> error_logger:error_msg(F ++ "~n",A). + +d(F) -> + d(get(dbg),F,[]). + +d(F,A) -> + d(get(dbg),F,A). + +d(true, F, A) -> + io:format("DBG ~p ~p " ++ F ++ "~n", [self(),get(sname)]++A); +d(_,_,_) -> + ok. diff --git a/lib/inets/test/inets.config b/lib/inets/test/inets.config new file mode 100644 index 0000000000..6c9077594d --- /dev/null +++ b/lib/inets/test/inets.config @@ -0,0 +1 @@ +[{inets,[{services,[{httpd,"/ldisk/tests/bmk/inets/priv_dir/8099.conf"}]}]}]. diff --git a/lib/inets/test/inets.spec b/lib/inets/test/inets.spec new file mode 100644 index 0000000000..a9b4524295 --- /dev/null +++ b/lib/inets/test/inets.spec @@ -0,0 +1,2 @@ +{topcase, {dir, "../inets_test"}}. +{hosts, ["tuor"]}. diff --git a/lib/inets/test/inets.spec.vxworks b/lib/inets/test/inets.spec.vxworks new file mode 100644 index 0000000000..6886299226 --- /dev/null +++ b/lib/inets/test/inets.spec.vxworks @@ -0,0 +1,5 @@ +{topcase, {dir, "../inets_test"}}. +{skip, {inets_SUITE, ip_mod_cgi, "Requires processes"}}. +{skip, {inets_SUITE, ip_mod_all_modules, "Requires processes"}}. +{skip, {inets_SUITE, ssl, "Requires SSL"}}. + diff --git a/lib/inets/test/inets_SUITE.erl b/lib/inets/test/inets_SUITE.erl new file mode 100644 index 0000000000..56983caace --- /dev/null +++ b/lib/inets/test/inets_SUITE.erl @@ -0,0 +1,583 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(inets_SUITE). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include("inets_test_lib.hrl"). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-define(NUM_DEFAULT_SERVICES, 1). + +all(doc) -> + ["Test suites for the inets application."]; + +all(suite) -> + [ + app_test, + appup_test, + services_test, + httpd_reload + ]. + +services_test(suite) -> + [ + start_inets, + start_httpc, + start_httpd, + start_ftpc, + start_tftpd + ]. + + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(Case, Config) -> Config +% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + inets:stop(), + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(Case, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(_, Config) -> + Config. + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- +app_test(suite) -> + [{inets_app_test, all}]. + +appup_test(suite) -> + [{inets_appup_test, all}]. + + +%%------------------------------------------------------------------------- + +start_inets(doc) -> + ["Test inets API functions"]; +start_inets(suite) -> + []; +start_inets(Config) when is_list(Config) -> + [_|_] = inets:service_names(), + + {error,inets_not_started} = inets:services(), + {error,inets_not_started} = inets:services_info(), + + ok = inets:start(), + + %% httpc default profile always started + [_|_] = inets:services(), + [_|_] = inets:services_info(), + + {error,{already_started,inets}} = inets:start(), + + ok = inets:stop(), + {error,{not_started,inets}} = inets:stop(), + + ok = inets:start(transient), + ok = inets:stop(), + + ok = inets:start(permanent), + ok = inets:stop(). + + +%%------------------------------------------------------------------------- + +start_httpc(doc) -> + ["Start/stop of httpc service"]; +start_httpc(suite) -> + []; +start_httpc(Config) when is_list(Config) -> + process_flag(trap_exit, true), + tsp("start_httpc -> entry with" + "~n Config: ~p", [Config]), + + PrivDir = ?config(priv_dir, Config), + + tsp("start_httpc -> start (empty) inets"), + ok = inets:start(), + + tsp("start_httpc -> start httpc (as inets service) with profile foo"), + {ok, Pid0} = inets:start(httpc, [{profile, foo}]), + + tsp("start_httpc -> check running services"), + Pids0 = [ServicePid || {_, ServicePid} <- inets:services()], + true = lists:member(Pid0, Pids0), + [_|_] = inets:services_info(), + + tsp("start_httpc -> stop httpc"), + inets:stop(httpc, Pid0), + + tsp("start_httpc -> sleep some"), + test_server:sleep(100), + + tsp("start_httpc -> check running services"), + Pids1 = [ServicePid || {_, ServicePid} <- inets:services()], + false = lists:member(Pid0, Pids1), + + tsp("start_httpc -> start httpc (stand-alone) with profile bar"), + {ok, Pid1} = inets:start(httpc, [{profile, bar}], stand_alone), + + tsp("start_httpc -> check running services"), + Pids2 = [ServicePid || {_, ServicePid} <- inets:services()], + false = lists:member(Pid1, Pids2), + + tsp("start_httpc -> stop httpc"), + ok = inets:stop(stand_alone, Pid1), + receive + {'EXIT', Pid1, shutdown} -> + ok + after 100 -> + tsf(stand_alone_not_shutdown) + end, + + tsp("start_httpc -> stop inets"), + ok = inets:stop(), + + tsp("start_httpc -> unload inets"), + application:load(inets), + + tsp("start_httpc -> set inets environment (httpc profile foo)"), + application:set_env(inets, services, [{httpc,[{profile, foo}, + {data_dir, PrivDir}]}]), + + tsp("start_httpc -> start inets"), + ok = inets:start(), + + tsp("start_httpc -> check running services"), + (?NUM_DEFAULT_SERVICES + 1) = length(inets:services()), + + tsp("start_httpc -> unset inets env"), + application:unset_env(inets, services), + + tsp("start_httpc -> stop inets"), + ok = inets:stop(), + + tsp("start_httpc -> start (empty) inets"), + ok = inets:start(), + + tsp("start_httpc -> start inets httpc service with profile foo"), + {ok, Pid3} = inets:start(httpc, [{profile, foo}]), + + tsp("start_httpc -> stop inets service httpc with profile foo"), + ok = inets:stop(httpc, foo), + + tsp("start_httpc -> check running services"), + Pids3 = [ServicePid || {_, ServicePid} <- inets:services()], + false = lists:member(Pid3, Pids3), + + tsp("start_httpc -> stop inets"), + ok = inets:stop(), + + tsp("start_httpc -> done"), + ok. + + +%%------------------------------------------------------------------------- + +start_httpd(doc) -> + ["Start/stop of httpd service"]; +start_httpd(suite) -> + []; +start_httpd(Config) when is_list(Config) -> + process_flag(trap_exit, true), + i("start_httpd -> entry with" + "~n Config: ~p", [Config]), + PrivDir = ?config(priv_dir, Config), + HttpdConf = [{server_name, "httpd_test"}, {server_root, PrivDir}, + {document_root, PrivDir}, {bind_address, "localhost"}], + + i("start_httpd -> start inets"), + ok = inets:start(), + + i("start_httpd -> start httpd service"), + {ok, Pid0} = inets:start(httpd, [{port, 0}, {ipfamily, inet} | HttpdConf]), + Pids0 = [ServicePid || {_, ServicePid} <- inets:services()], + true = lists:member(Pid0, Pids0), + [_|_] = inets:services_info(), + + i("start_httpd -> stop httpd service"), + inets:stop(httpd, Pid0), + test_server:sleep(500), + Pids1 = [ServicePid || {_, ServicePid} <- inets:services()], + false = lists:member(Pid0, Pids1), + i("start_httpd -> start (stand-alone) httpd service"), + {ok, Pid1} = + inets:start(httpd, [{port, 0}, {ipfamily, inet} | HttpdConf], + stand_alone), + Pids2 = [ServicePid || {_, ServicePid} <- inets:services()], + false = lists:member(Pid1, Pids2), + i("start_httpd -> stop (stand-alone) httpd service"), + ok = inets:stop(stand_alone, Pid1), + receive + {'EXIT', Pid1, shutdown} -> + ok + after 100 -> + test_server:fail(stand_alone_not_shutdown) + end, + i("start_httpd -> stop inets"), + ok = inets:stop(), + File0 = filename:join(PrivDir, "httpd.conf"), + {ok, Fd0} = file:open(File0, [write]), + Str = io_lib:format("~p.~n", [[{port, 0}, {ipfamily, inet} | HttpdConf]]), + ok = file:write(Fd0, Str), + file:close(Fd0), + + i("start_httpd -> [application] load inets"), + application:load(inets), + i("start_httpd -> [application] set httpd services env with proplist-file"), + application:set_env(inets, + services, [{httpd, [{proplist_file, File0}]}]), + i("start_httpd -> start inets"), + ok = inets:start(), + (?NUM_DEFAULT_SERVICES + 1) = length(inets:services()), + i("start_httpd -> [application] unset services env"), + application:unset_env(inets, services), + i("start_httpd -> stop inets"), + ok = inets:stop(), + + File1 = filename:join(PrivDir, "httpd_apache.conf"), + + {ok, Fd1} = file:open(File1, [write]), + file:write(Fd1, "ServerName httpd_test\r\n"), + file:write(Fd1, "ServerRoot " ++ PrivDir ++ "\r\n"), + file:write(Fd1, "DocumentRoot " ++ PrivDir ++" \r\n"), + file:write(Fd1, "BindAddress *|inet\r\n"), + file:write(Fd1, "Port 0\r\n"), + file:close(Fd1), + + i("start_httpd -> [application] load inets"), + application:load(inets), + i("start_httpd -> [application] set httpd services env with file"), + application:set_env(inets, + services, [{httpd, [{file, File1}]}]), + i("start_httpd -> start inets"), + ok = inets:start(), + (?NUM_DEFAULT_SERVICES + 1) = length(inets:services()), + i("start_httpd -> [application] unset services env"), + application:unset_env(inets, services), + i("start_httpd -> stop inets"), + ok = inets:stop(), + + %% OLD format + i("start_httpd -> [application] load inets"), + application:load(inets), + i("start_httpd -> [application] set httpd services OLD env"), + application:set_env(inets, + services, [{httpd, File1}]), + i("start_httpd -> start inets"), + ok = inets:start(), + (?NUM_DEFAULT_SERVICES + 1) = length(inets:services()), + i("start_httpd -> [application] unset services enc"), + application:unset_env(inets, services), + i("start_httpd -> stop inets"), + ok = inets:stop(), + + i("start_httpd -> start inets"), + ok = inets:start(), + i("start_httpd -> try (and fail) start httpd service - server_name"), + {error, {missing_property, server_name}} = + inets:start(httpd, [{port, 0}, + {server_root, PrivDir}, + {document_root, PrivDir}, + {bind_address, "localhost"}]), + i("start_httpd -> try (and fail) start httpd service - missing document_root"), + {error, {missing_property, document_root}} = + inets:start(httpd, [{port, 0}, + {server_name, "httpd_test"}, + {server_root, PrivDir}, + {bind_address, "localhost"}]), + i("start_httpd -> try (and fail) start httpd service - missing server_root"), + {error, {missing_property, server_root}} = + inets:start(httpd, [{port, 0}, + {server_name, "httpd_test"}, + {document_root, PrivDir}, + {bind_address, "localhost"}]), + i("start_httpd -> try (and fail) start httpd service - missing port"), + {error, {missing_property, port}} = + inets:start(httpd, HttpdConf), + i("start_httpd -> stop inets"), + ok = inets:stop(), + i("start_httpd -> done"), + ok. + + +%%------------------------------------------------------------------------- + +start_ftpc(doc) -> + ["Start/stop of ftpc service"]; +start_ftpc(suite) -> + []; +start_ftpc(Config) when is_list(Config) -> + process_flag(trap_exit, true), + inets:disable_trace(), + inets:enable_trace(max, io, ftpc), + ok = inets:start(), + try + begin + {_Tag, FtpdHost} = ftp_suite_lib:dirty_select_ftpd_host(Config), + case inets:start(ftpc, [{host, FtpdHost}]) of + {ok, Pid0} -> + Pids0 = [ServicePid || {_, ServicePid} <- + inets:services()], + true = lists:member(Pid0, Pids0), + [_|_] = inets:services_info(), + inets:stop(ftpc, Pid0), + test_server:sleep(100), + Pids1 = [ServicePid || {_, ServicePid} <- + inets:services()], + false = lists:member(Pid0, Pids1), + {ok, Pid1} = + inets:start(ftpc, [{host, FtpdHost}], stand_alone), + Pids2 = [ServicePid || {_, ServicePid} <- + inets:services()], + false = lists:member(Pid1, Pids2), + ok = inets:stop(stand_alone, Pid1), + receive + {'EXIT', Pid1, shutdown} -> + ok + after 100 -> + tsf(stand_alone_not_shutdown) + end, + ok = inets:stop(), + inets:disable_trace(), + ok; + _ -> + inets:disable_trace(), + {skip, "Unable to reach selected FTP server " ++ FtpdHost} + end + end + catch + throw:{error, not_found} -> + inets:disable_trace(), + {skip, "No available FTP servers"} + end. + + + +%%------------------------------------------------------------------------- + +start_tftpd(doc) -> + ["Start/stop of tfpd service"]; +start_tftpd(suite) -> + []; +start_tftpd(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ok = inets:start(), + {ok, Pid0} = inets:start(tftpd, [{host, "localhost"}, {port, 0}]), + Pids0 = [ServicePid || {_, ServicePid} <- inets:services()], + true = lists:member(Pid0, Pids0), + [_|_] = inets:services_info(), + inets:stop(tftpd, Pid0), + test_server:sleep(100), + Pids1 = [ServicePid || {_, ServicePid} <- inets:services()], + false = lists:member(Pid0, Pids1), + {ok, Pid1} = + inets:start(tftpd, [{host, "localhost"}, {port, 0}], stand_alone), + Pids2 = [ServicePid || {_, ServicePid} <- inets:services()], + false = lists:member(Pid1, Pids2), + ok = inets:stop(stand_alone, Pid1), + receive + {'EXIT', Pid1, shutdown} -> + ok + after 100 -> + test_server:fail(stand_alone_not_shutdown) + end, + ok = inets:stop(), + application:load(inets), + application:set_env(inets, services, [{tftpd,[{host, "localhost"}, + {port, 0}]}]), + ok = inets:start(), + (?NUM_DEFAULT_SERVICES + 1) = length(inets:services()), + application:unset_env(inets, services), + ok = inets:stop(). + + +%%------------------------------------------------------------------------- + +httpd_reload(doc) -> + ["Reload httpd configuration without restarting service"]; +httpd_reload(suite) -> + []; +httpd_reload(Config) when is_list(Config) -> + process_flag(trap_exit, true), + i("httpd_reload -> starting"), + PrivDir = ?config(priv_dir, Config), + DataDir = ?config(data_dir, Config), + HttpdConf = [{server_name, "httpd_test"}, + {server_root, PrivDir}, + {document_root, PrivDir}, + {bind_address, "localhost"}], + + inets:enable_trace(max, io), + + i("httpd_reload -> start inets"), + + ok = inets:start(), + test_server:sleep(5000), + i("httpd_reload -> inets started - start httpd service"), + + {ok, Pid0} = inets:start(httpd, [{port, 0}, {ipfamily, inet} | HttpdConf]), + test_server:sleep(5000), + i("httpd_reload -> httpd service started (~p) - get port", [Pid0]), + + [{port, Port0}] = httpd:info(Pid0, [port]), + test_server:sleep(5000), + i("httpd_reload -> Port: ~p - get document root", [Port0]), + + [{document_root, PrivDir}] = httpd:info(Pid0, [document_root]), + test_server:sleep(5000), + i("httpd_reload -> document root: ~p - reload config", [PrivDir]), + + ok = httpd:reload_config([{port, Port0}, {ipfamily, inet}, + {server_name, "httpd_test"}, + {server_root, PrivDir}, + {document_root, DataDir}, + {bind_address, "localhost"}], non_disturbing), + test_server:sleep(5000), + io:format("~w:~w:httpd_reload - reloaded - get document root~n", [?MODULE, ?LINE]), + + [{document_root, DataDir}] = httpd:info(Pid0, [document_root]), + test_server:sleep(5000), + i("httpd_reload -> document root: ~p - reload config", [DataDir]), + + ok = httpd:reload_config([{port, Port0}, {ipfamily, inet}, + {server_name, "httpd_test"}, + {server_root, PrivDir}, + {document_root, PrivDir}, + {bind_address, "localhost"}], disturbing), + + [{document_root, PrivDir}] = httpd:info(Pid0, [document_root]), + ok = inets:stop(httpd, Pid0), + ok = inets:stop(), + + File = filename:join(PrivDir, "httpd_apache.conf"), + + {ok, Fd0} = file:open(File, [write]), + file:write(Fd0, "ServerName httpd_test\r\n"), + file:write(Fd0, "ServerRoot " ++ PrivDir ++ "\r\n"), + file:write(Fd0, "DocumentRoot " ++ PrivDir ++" \r\n"), + file:write(Fd0, "BindAddress *\r\n"), + file:write(Fd0, "Port 0\r\n"), + file:close(Fd0), + + application:load(inets), + application:set_env(inets, + services, [{httpd, [{file, File}]}]), + + ok = inets:start(), + [Pid1] = [HttpdPid || {httpd, HttpdPid} <- inets:services()], + [{server_name, "httpd_test"}] = httpd:info(Pid1, [server_name]), + [{port, Port1}] = httpd:info(Pid1, [port]), + {ok, Fd1} = file:open(File, [write]), + file:write(Fd1, "ServerName httpd_test2\r\n"), + file:write(Fd1, "ServerRoot " ++ PrivDir ++ "\r\n"), + file:write(Fd1, "DocumentRoot " ++ PrivDir ++" \r\n"), + file:write(Fd1, "BindAddress *\r\n"), + file:write(Fd1, "Port " ++ integer_to_list(Port1) ++ "\r\n"), + file:close(Fd1), + + ok = httpd:reload_config(File, non_disturbing), + [{server_name, "httpd_test2"}] = httpd:info(Pid1, [server_name]), + + {ok, Fd2} = file:open(File, [write]), + file:write(Fd2, "ServerName httpd_test\r\n"), + file:write(Fd2, "ServerRoot " ++ PrivDir ++ "\r\n"), + file:write(Fd2, "DocumentRoot " ++ PrivDir ++" \r\n"), + file:write(Fd2, "BindAddress *\r\n"), + file:write(Fd2, "Port " ++ integer_to_list(Port1) ++ "\r\n"), + file:close(Fd2), + ok = httpd:reload_config(File, disturbing), + [{server_name, "httpd_test"}] = httpd:info(Pid1, [server_name]), + + ok = inets:stop(httpd, Pid1), + application:unset_env(inets, services), + ok = inets:stop(), + i("httpd_reload -> starting"), + ok. + + +tsf(Reason) -> + test_server:fail(Reason). + +tsp(F) -> + tsp(F, []). +tsp(F, A) -> + Timestamp = formated_timestamp(), + test_server:format("** ~s ** ~p ~p:" ++ F ++ "~n", [Timestamp, self(), ?MODULE | A]). + +i(F) -> + i(F, []). + +i(F, A) -> + Timestamp = formated_timestamp(), + io:format("*** ~s ~w:" ++ F ++ "~n", [Timestamp, ?MODULE | A]). + +formated_timestamp() -> + format_timestamp( os:timestamp() ). + +format_timestamp({_N1, _N2, N3} = Now) -> + {Date, Time} = calendar:now_to_datetime(Now), + {YYYY,MM,DD} = Date, + {Hour,Min,Sec} = Time, + FormatDate = + io_lib:format("~.4w:~.2.0w:~.2.0w ~.2.0w:~.2.0w:~.2.0w 4~w", + [YYYY,MM,DD,Hour,Min,Sec,round(N3/1000)]), + lists:flatten(FormatDate). + diff --git a/lib/inets/test/inets_SUITE_data/.gitignore b/lib/inets/test/inets_SUITE_data/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/lib/inets/test/inets_SUITE_data/.gitignore diff --git a/lib/inets/test/inets_app_test.erl b/lib/inets/test/inets_app_test.erl new file mode 100644 index 0000000000..6bdb9bb308 --- /dev/null +++ b/lib/inets/test/inets_app_test.erl @@ -0,0 +1,296 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2002-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%---------------------------------------------------------------------- +%% Purpose: Verify the application specifics of the inets application +%%---------------------------------------------------------------------- +-module(inets_app_test). + +-compile(export_all). + +-include("inets_test_lib.hrl"). + + +% t() -> megaco_test_lib:t(?MODULE). +% t(Case) -> megaco_test_lib:t({?MODULE, Case}). + + +%% Test server callbacks +init_per_testcase(undef_funcs, Config) -> + NewConfig = lists:keydelete(watchdog, 1, Config), + Dog = test_server:timetrap(inets_test_lib:minutes(10)), + [{watchdog, Dog}| NewConfig]; +init_per_testcase(_, Config) -> + Config. + +fin_per_testcase(_Case, Config) -> + Config. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +all(suite) -> + Cases = + [ + fields, + modules, + exportall, + app_depend, + undef_funcs + ], + {req, [], {conf, app_init, Cases, app_fin}}. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +app_init(suite) -> []; +app_init(doc) -> []; +app_init(Config) when is_list(Config) -> + case is_app(inets) of + {ok, AppFile} -> + io:format("AppFile: ~n~p~n", [AppFile]), + inets:print_version_info(), + [{app_file, AppFile}|Config]; + {error, Reason} -> + fail(Reason) + end. + +is_app(App) -> + LibDir = code:lib_dir(App), + File = filename:join([LibDir, "ebin", atom_to_list(App) ++ ".app"]), + case file:consult(File) of + {ok, [{application, App, AppFile}]} -> + {ok, AppFile}; + Error -> + {error, {invalid_format, Error}} + end. + + +app_fin(suite) -> []; +app_fin(doc) -> []; +app_fin(Config) when is_list(Config) -> + Config. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +fields(suite) -> + []; +fields(doc) -> + []; +fields(Config) when is_list(Config) -> + AppFile = key1search(app_file, Config), + Fields = [vsn, description, modules, registered, applications], + case check_fields(Fields, AppFile, []) of + [] -> + ok; + Missing -> + fail({missing_fields, Missing}) + end. + +check_fields([], _AppFile, Missing) -> + Missing; +check_fields([Field|Fields], AppFile, Missing) -> + check_fields(Fields, AppFile, check_field(Field, AppFile, Missing)). + +check_field(Name, AppFile, Missing) -> + io:format("checking field: ~p~n", [Name]), + case lists:keymember(Name, 1, AppFile) of + true -> + Missing; + false -> + [Name|Missing] + end. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +modules(suite) -> + []; +modules(doc) -> + []; +modules(Config) when is_list(Config) -> + AppFile = key1search(app_file, Config), + Mods = key1search(modules, AppFile), + EbinList = get_ebin_mods(inets), + case missing_modules(Mods, EbinList, []) of + [] -> + ok; + Missing -> + throw({error, {missing_modules, Missing}}) + end, + case extra_modules(Mods, EbinList, []) of + [] -> + ok; + Extra -> + throw({error, {extra_modules, Extra}}) + end, + {ok, Mods}. + +get_ebin_mods(App) -> + LibDir = code:lib_dir(App), + EbinDir = filename:join([LibDir,"ebin"]), + {ok, Files0} = file:list_dir(EbinDir), + Files1 = [lists:reverse(File) || File <- Files0], + [list_to_atom(lists:reverse(Name)) || [$m,$a,$e,$b,$.|Name] <- Files1]. + + +missing_modules([], _Ebins, Missing) -> + Missing; +missing_modules([Mod|Mods], Ebins, Missing) -> + case lists:member(Mod, Ebins) of + true -> + missing_modules(Mods, Ebins, Missing); + false -> + io:format("missing module: ~p~n", [Mod]), + missing_modules(Mods, Ebins, [Mod|Missing]) + end. + + +extra_modules(_Mods, [], Extra) -> + Extra; +extra_modules(Mods, [Mod|Ebins], Extra) -> + case lists:member(Mod, Mods) of + true -> + extra_modules(Mods, Ebins, Extra); + false -> + io:format("supefluous module: ~p~n", [Mod]), + extra_modules(Mods, Ebins, [Mod|Extra]) + end. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +exportall(suite) -> + []; +exportall(doc) -> + []; +exportall(Config) when is_list(Config) -> + AppFile = key1search(app_file, Config), + Mods = key1search(modules, AppFile), + check_export_all(Mods). + + +check_export_all([]) -> + ok; +check_export_all([Mod|Mods]) -> + case (catch apply(Mod, module_info, [compile])) of + {'EXIT', {undef, _}} -> + check_export_all(Mods); + O -> + case lists:keysearch(options, 1, O) of + false -> + check_export_all(Mods); + {value, {options, List}} -> + case lists:member(export_all, List) of + true -> + throw({error, {export_all, Mod}}); + false -> + check_export_all(Mods) + end + end + end. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +app_depend(suite) -> + []; +app_depend(doc) -> + []; +app_depend(Config) when is_list(Config) -> + AppFile = key1search(app_file, Config), + Apps = key1search(applications, AppFile), + check_apps(Apps). + + +check_apps([]) -> + ok; +check_apps([App|Apps]) -> + case is_app(App) of + {ok, _} -> + check_apps(Apps); + Error -> + throw({error, {missing_app, {App, Error}}}) + end. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +undef_funcs(suite) -> + []; +undef_funcs(doc) -> + []; +undef_funcs(Config) when is_list(Config) -> + App = inets, + AppFile = key1search(app_file, Config), + Mods = key1search(modules, AppFile), + Root = code:root_dir(), + LibDir = code:lib_dir(App), + EbinDir = filename:join([LibDir,"ebin"]), + XRefTestName = undef_funcs_make_name(App, xref_test_name), + {ok, XRef} = xref:start(XRefTestName), + ok = xref:set_default(XRef, + [{verbose,false},{warnings,false}]), + XRefName = undef_funcs_make_name(App, xref_name), + {ok, XRefName} = xref:add_release(XRef, Root, {name,XRefName}), + {ok, App} = xref:replace_application(XRef, App, EbinDir), + {ok, Undefs} = xref:analyze(XRef, undefined_function_calls), + xref:stop(XRef), + analyze_undefined_function_calls(Undefs, Mods, []). + +analyze_undefined_function_calls([], _, []) -> + ok; +analyze_undefined_function_calls([], _, AppUndefs) -> + exit({suite_failed, {undefined_function_calls, AppUndefs}}); +analyze_undefined_function_calls([{{Mod, _F, _A}, _C} = AppUndef|Undefs], + AppModules, AppUndefs) -> + %% Check that this module is our's + case lists:member(Mod,AppModules) of + true -> + {Calling,Called} = AppUndef, + {Mod1,Func1,Ar1} = Calling, + {Mod2,Func2,Ar2} = Called, + io:format("undefined function call: " + "~n ~w:~w/~w calls ~w:~w/~w~n", + [Mod1,Func1,Ar1,Mod2,Func2,Ar2]), + analyze_undefined_function_calls(Undefs, AppModules, + [AppUndef|AppUndefs]); + false -> + io:format("dropping ~p~n", [Mod]), + analyze_undefined_function_calls(Undefs, AppModules, AppUndefs) + end. + +%% This function is used simply to avoid cut-and-paste errors later... +undef_funcs_make_name(App, PostFix) -> + list_to_atom(atom_to_list(App) ++ "_" ++ atom_to_list(PostFix)). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +fail(Reason) -> + exit({suite_failed, Reason}). + +key1search(Key, L) -> + case lists:keysearch(Key, 1, L) of + undefined -> + fail({not_found, Key, L}); + {value, {Key, Value}} -> + Value + end. diff --git a/lib/inets/test/inets_appup_test.erl b/lib/inets/test/inets_appup_test.erl new file mode 100644 index 0000000000..d580c6c4c5 --- /dev/null +++ b/lib/inets/test/inets_appup_test.erl @@ -0,0 +1,336 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2002-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%---------------------------------------------------------------------- +%% Purpose: Verify the application specifics of the Megaco application +%%---------------------------------------------------------------------- +-module(inets_appup_test). + +-compile(export_all). + +-include("inets_test_lib.hrl"). + + +% t() -> megaco_test_lib:t(?MODULE). +% t(Case) -> megaco_test_lib:t({?MODULE, Case}). + + +%% Test server callbacks +init_per_testcase(_Case, Config) -> + Config. + +fin_per_testcase(_Case, Config) -> + Config. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +all(suite) -> + Cases = + [ + appup + ], + {req, [], {conf, appup_init, Cases, appup_fin}}. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +appup_init(suite) -> []; +appup_init(doc) -> []; +appup_init(Config) when is_list(Config) -> + AppFile = file_name(inets, ".app"), + AppupFile = file_name(inets, ".appup"), + [{app_file, AppFile}, {appup_file, AppupFile}|Config]. + + +file_name(App, Ext) -> + LibDir = code:lib_dir(App), + filename:join([LibDir, "ebin", atom_to_list(App) ++ Ext]). + + +appup_fin(suite) -> []; +appup_fin(doc) -> []; +appup_fin(Config) when is_list(Config) -> + Config. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +appup(suite) -> + []; +appup(doc) -> + "perform a simple check of the appup file"; +appup(Config) when is_list(Config) -> + AppupFile = key1search(appup_file, Config), + AppFile = key1search(app_file, Config), + Modules = modules(AppFile), + check_appup(AppupFile, Modules). + +modules(File) -> + case file:consult(File) of + {ok, [{application,inets,Info}]} -> + case lists:keysearch(modules,1,Info) of + {value, {modules, Modules}} -> + Modules; + false -> + fail({bad_appinfo, Info}) + end; + Error -> + fail({bad_appfile, Error}) + end. + + +check_appup(AppupFile, Modules) -> + case file:consult(AppupFile) of + {ok, [{V, UpFrom, DownTo}]} -> +% io:format("~p => " +% "~n ~p" +% "~n ~p" +% "~n", [V, UpFrom, DownTo]), + check_appup(V, UpFrom, DownTo, Modules); + Else -> + fail({bad_appupfile, Else}) + end. + + +check_appup(V, UpFrom, DownTo, Modules) -> + check_version(V), + check_depends(up, UpFrom, Modules), + check_depends(down, DownTo, Modules), + ok. + + +check_depends(_, [], _) -> + ok; +check_depends(UpDown, [Dep|Deps], Modules) -> + check_depend(UpDown, Dep, Modules), + check_depends(UpDown, Deps, Modules). + + +check_depend(UpDown, {V, Instructions}, Modules) -> + check_version(V), + case check_instructions(UpDown, + Instructions, Instructions, [], [], Modules) of + {_Good, []} -> + ok; + {_, Bad} -> + fail({bad_instructions, Bad, UpDown}) + end. + + +check_instructions(_, [], _, Good, Bad, _) -> + {lists:reverse(Good), lists:reverse(Bad)}; +check_instructions(UpDown, [Instr|Instrs], AllInstr, Good, Bad, Modules) -> + case (catch check_instruction(UpDown, Instr, AllInstr, Modules)) of + ok -> + check_instructions(UpDown, Instrs, AllInstr, + [Instr|Good], Bad, Modules); + {error, Reason} -> + check_instructions(UpDown, Instrs, AllInstr, Good, + [{Instr, Reason}|Bad], Modules) + end; +check_instructions(UpDown, Instructions, _, _, _, _) -> + fail({bad_instructions, {UpDown, Instructions}}). + +%% A new module is added +check_instruction(up, {add_module, Module}, _, Modules) + when is_atom(Module) -> + check_module(Module, Modules); + +%% An old module is re-added +check_instruction(down, {add_module, Module}, _, Modules) + when is_atom(Module) -> + case (catch check_module(Module, Modules)) of + {error, {unknown_module, Module, Modules}} -> + ok; + ok -> + error({existing_readded_module, Module}) + end; + +%% Removing a module on upgrade: +%% - the module has been removed from the app-file. +%% - check that no module depends on this (removed) module +check_instruction(up, {remove, {Module, Pre, Post}}, _, Modules) + when is_atom(Module), is_atom(Pre), is_atom(Post) -> + case (catch check_module(Module, Modules)) of + {error, {unknown_module, Module, Modules}} -> + check_purge(Pre), + check_purge(Post); + ok -> + error({existing_removed_module, Module}) + end; + +%% Removing a module on downgrade: the module exist +%% in the app-file. +check_instruction(down, {remove, {Module, Pre, Post}}, AllInstr, Modules) + when is_atom(Module), is_atom(Pre), is_atom(Post) -> + case (catch check_module(Module, Modules)) of + ok -> + check_purge(Pre), + check_purge(Post), + check_no_remove_depends(Module, AllInstr); + {error, {unknown_module, Module, Modules}} -> + error({nonexisting_removed_module, Module}) + end; + +check_instruction(up, {load_module, Module, Pre, Post, Depend}, _, Modules) + when is_atom(Module), is_atom(Pre), is_atom(Post), is_list(Depend) -> + check_module(Module, Modules), + check_module_depend(Module, Depend, Modules), + check_purge(Pre), + check_purge(Post); + +check_instruction(down, {load_module, Module, Pre, Post, Depend}, _, Modules) + when is_atom(Module), is_atom(Pre), is_atom(Post), is_list(Depend) -> + check_module(Module, Modules), + % Can not be sure that the the dependent module exists in the new appfile + %%check_module_depend(Module, Depend, Modules), + check_purge(Pre), + check_purge(Post); + + + +check_instruction(up, {delete_module, Module}, _, Modules) + when is_atom(Module) -> + case (catch check_module(Module, Modules)) of + {error, {unknown_module, Module, Modules}} -> + ok; + ok -> + error({existing_module_deleted, Module}) + end; + +check_instruction(down, {delete_module, Module}, _, Modules) + when is_atom(Module) -> + check_module(Module, Modules); + + +check_instruction(_, {apply, {Module, Function, Args}}, _, _) when is_atom(Module), is_atom(Function), is_list(Args) -> + ok; + +check_instruction(_, {update, Module, supervisor}, _, Modules) when is_atom(Module) -> + check_module(Module, Modules); + +check_instruction(_, {update, Module, {advanced, _}, DepMods}, _, Modules) when is_atom(Module), is_list(DepMods) -> + check_module(Module, Modules), + check_module_depend(Module, DepMods, Modules); + +check_instruction(_, {update, Module, Change, Pre, Post, Depend}, _, Modules) + when is_atom(Module), is_atom(Pre), is_atom(Post), is_list(Depend) -> + check_module(Module, Modules), + check_module_depend(Module, Depend, Modules), + check_change(Change), + check_purge(Pre), + check_purge(Post); + +check_instruction(_, {restart_application, inets}, _AllInstr, _Modules) -> + ok; + +check_instruction(_, {update, Module, {advanced, _}}, _, Modules) -> + check_module(Module, Modules); + +check_instruction(_, Instr, _AllInstr, _Modules) -> + error({error, {unknown_instruction, Instr}}). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +check_version(V) when is_list(V) -> + ok; +check_version(V) -> + error({bad_version, V}). + + +check_module(M, Modules) when is_atom(M) -> + case lists:member(M,Modules) of + true -> + ok; + false -> + error({unknown_module, M, Modules}) + end; +check_module(M, _) -> + error({bad_module, M}). + + +check_module_depend(M, [], _) when is_atom(M) -> + ok; +check_module_depend(M, Deps, Modules) when is_atom(M), is_list(Deps) -> + case [Dep || Dep <- Deps, lists:member(Dep, Modules) == false] of + [] -> + ok; + Unknown -> + error({unknown_depend_modules, Unknown}) + end; +check_module_depend(_M, D, _Modules) -> + error({bad_depend, D}). + + +check_no_remove_depends(_Module, []) -> + ok; +check_no_remove_depends(Module, [Instr|Instrs]) -> + check_no_remove_depend(Module, Instr), + check_no_remove_depends(Module, Instrs). + +check_no_remove_depend(Module, {load_module, Mod, _Pre, _Post, Depend}) -> + case lists:member(Module, Depend) of + true -> + error({removed_module_in_depend, load_module, Mod, Module}); + false -> + ok + end; +check_no_remove_depend(Module, {update, Mod, _Change, _Pre, _Post, Depend}) -> + case lists:member(Module, Depend) of + true -> + error({removed_module_in_depend, update, Mod, Module}); + false -> + ok + end; +check_no_remove_depend(_, _) -> + ok. + + +check_change(soft) -> + ok; +check_change({advanced, _Something}) -> + ok; +check_change(Change) -> + error({bad_change, Change}). + + +check_purge(soft_purge) -> + ok; +check_purge(brutal_purge) -> + ok; +check_purge(Purge) -> + error({bad_purge, Purge}). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +error(Reason) -> + throw({error, Reason}). + +fail(Reason) -> + exit({suite_failed, Reason}). + +key1search(Key, L) -> + case lists:keysearch(Key, 1, L) of + undefined -> + fail({not_found, Key, L}); + {value, {Key, Value}} -> + Value + end. diff --git a/lib/inets/test/inets_internal.hrl b/lib/inets/test/inets_internal.hrl new file mode 120000 index 0000000000..3228d7ef6a --- /dev/null +++ b/lib/inets/test/inets_internal.hrl @@ -0,0 +1 @@ +../src/inets_app/inets_internal.hrl
\ No newline at end of file diff --git a/lib/inets/test/inets_sup_SUITE.erl b/lib/inets/test/inets_sup_SUITE.erl new file mode 100644 index 0000000000..ba41e0960c --- /dev/null +++ b/lib/inets/test/inets_sup_SUITE.erl @@ -0,0 +1,414 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(inets_sup_SUITE). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +all(doc) -> + ["Test that the inets supervisorstructur is the expected one."]; +all(suite) -> + [ + default_tree, + ftpc_worker, + tftpd_worker, + httpd_subtree, + httpc_subtree + ]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initiation before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(_) -> + inets:stop(), + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(Case, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initiation before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_testcase(httpd_subtree, Config) -> + io:format("init_per_testcase(httpd_subtree) -> entry with" + "~n Config: ~p" + "~n", [Config]), + Dog = test_server:timetrap(?t:minutes(1)), + NewConfig = lists:keydelete(watchdog, 1, Config), + + DataDir = ?config(data_dir, Config), + PrivDir = ?config(priv_dir, Config), + ServerROOT = filename:join(PrivDir, "server_root"), + DocROOT = filename:join(PrivDir, "htdocs"), + ConfDir = filename:join(ServerROOT, "conf"), + + io:format("init_per_testcase(httpd_subtree) -> create dir(s)" + "~n", []), + file:make_dir(ServerROOT), %% until http_test is cleaned up! + ok = file:make_dir(DocROOT), + ok = file:make_dir(ConfDir), + + io:format("init_per_testcase(httpd_subtree) -> copy file(s)" + "~n", []), + {ok, _} = inets_test_lib:copy_file("simple.conf", DataDir, PrivDir), + {ok, _} = inets_test_lib:copy_file("mime.types", DataDir, ConfDir), + + io:format("init_per_testcase(httpd_subtree) -> write file(s)" + "~n", []), + ConfFile = filename:join(PrivDir, "simple.conf"), + {ok, Fd} = file:open(ConfFile, [append]), + ok = file:write(Fd, "ServerRoot " ++ ServerROOT ++ "\n"), + ok = file:write(Fd, "DocumentRoot " ++ DocROOT ++ "\n"), + ok = file:close(Fd), + + %% To make sure application:set_env is not overwritten by any + %% app-file settings. + io:format("init_per_testcase(httpd_subtree) -> load inets app" + "~n", []), + application:load(inets), + io:format("init_per_testcase(httpd_subtree) -> update inets env" + "~n", []), + ok = application:set_env(inets, services, [{httpd, ConfFile}]), + + try + io:format("init_per_testcase(httpd_subtree) -> start inets app" + "~n", []), + ok = inets:start(), + io:format("init_per_testcase(httpd_subtree) -> done" + "~n", []), + [{watchdog, Dog}, {server_root, ServerROOT}, {doc_root, DocROOT}, + {conf_dir, ConfDir}| NewConfig] + catch + _:Reason -> + io:format("init_per_testcase(httpd_subtree) -> " + "failed starting inets - cleanup" + "~n Reason: ~p" + "~n", [Reason]), + application:unset_env(inets, services), + application:unload(inets), + exit({failed_starting_inets, Reason}) + end; + + +init_per_testcase(Case, Config) -> + io:format("init_per_testcase(~p) -> entry with" + "~n Config: ~p" + "~n", [Case, Config]), + Dog = test_server:timetrap(?t:minutes(5)), + NewConfig = lists:keydelete(watchdog, 1, Config), + Stop = inets:stop(), + io:format("init_per_testcase(~p) -> Stop: ~p" + "~n", [Case, Stop]), + ok = inets:start(), + [{watchdog, Dog} | NewConfig]. + + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(Case, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(httpd_subtree, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + PrivDir = ?config(priv_dir, Config), + inets_test_lib:del_dirs(PrivDir), + ok; + +end_per_testcase(_, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + inets:stop(), + ok. + +%%------------------------------------------------------------------------- +%% Test cases starts here. +%%------------------------------------------------------------------------- + + +%%------------------------------------------------------------------------- +%% default_tree +%%------------------------------------------------------------------------- +default_tree(doc) -> + ["Makes sure the correct processes are started and linked," + "in the default case."]; +default_tree(suite) -> + []; +default_tree(Config) when is_list(Config) -> + TopSupChildren = supervisor:which_children(inets_sup), + 4 = length(TopSupChildren), + {value, {httpd_sup, _, supervisor,[httpd_sup]}} = + lists:keysearch(httpd_sup, 1, TopSupChildren), + {value, {httpc_sup, _,supervisor,[httpc_sup]}} = + lists:keysearch(httpc_sup, 1, TopSupChildren), + {value, {ftp_sup,_,supervisor,[ftp_sup]}} = + lists:keysearch(ftp_sup, 1, TopSupChildren), + {value, {tftp_sup,_,supervisor,[tftp_sup]}} = + lists:keysearch(tftp_sup, 1, TopSupChildren), + + HttpcSupChildren = supervisor:which_children(httpc_sup), + {value, {httpc_profile_sup,_, supervisor, [httpc_profile_sup]}} = + lists:keysearch(httpc_profile_sup, 1, HttpcSupChildren), + {value, {httpc_handler_sup,_, supervisor, [httpc_handler_sup]}} = + lists:keysearch(httpc_handler_sup, 1, HttpcSupChildren), + + [] = supervisor:which_children(ftp_sup), + + [] = supervisor:which_children(httpd_sup), + + %% Default profile + [{httpc_manager, _, worker,[httpc_manager]}] + = supervisor:which_children(httpc_profile_sup), + + [] = supervisor:which_children(httpc_handler_sup), + + [] = supervisor:which_children(tftp_sup), + + ok. + + +%%------------------------------------------------------------------------- +%% ftpc_worker +%%------------------------------------------------------------------------- +ftpc_worker(doc) -> + ["Makes sure the ftp worker processes are added and removed " + "appropriatly to/from the supervison tree."]; +ftpc_worker(suite) -> + []; +ftpc_worker(Config) when is_list(Config) -> + inets:disable_trace(), + inets:enable_trace(max, io, ftpc), + [] = supervisor:which_children(ftp_sup), + try + begin + {_Tag, FtpdHost} = ftp_suite_lib:dirty_select_ftpd_host(Config), + case inets:start(ftpc, [{host, FtpdHost}]) of + {ok, Pid} -> + case supervisor:which_children(ftp_sup) of + [{_,_, worker, [ftp]}] -> + inets:stop(ftpc, Pid), + test_server:sleep(5000), + [] = supervisor:which_children(ftp_sup), + inets:disable_trace(), + ok; + Children -> + inets:disable_trace(), + exit({unexpected_children, Children}) + end; + _ -> + inets:disable_trace(), + {skip, "Unable to reach test FTP server"} + end + end + catch + throw:{error, not_found} -> + inets:disable_trace(), + {skip, "No available FTP servers"} + end. + + +%%------------------------------------------------------------------------- +%% tftpd_worker +%%------------------------------------------------------------------------- +tftpd_worker(doc) -> + ["Makes sure the tftp sub tree is correct."]; +tftpd_worker(suite) -> + []; +tftpd_worker(Config) when is_list(Config) -> + [] = supervisor:which_children(tftp_sup), + {ok, Pid0} = inets:start(tftpd, [{host, "localhost"}, + {port, inet_port()}]), + {ok, _Pid1} = inets:start(tftpd, [{host, "localhost"}, + {port, inet_port()}], stand_alone), + + [{_,Pid0, worker, _}] = supervisor:which_children(tftp_sup), + inets:stop(tftpd, Pid0), + test_server:sleep(5000), + [] = supervisor:which_children(tftp_sup), + ok. + + +%%------------------------------------------------------------------------- +%% httpd_subtree +%%------------------------------------------------------------------------- +httpd_subtree(doc) -> + ["Makes sure the httpd sub tree is correct."]; +httpd_subtree(suite) -> + []; +httpd_subtree(Config) when is_list(Config) -> + io:format("httpd_subtree -> entry with" + "~n Config: ~p" + "~n", [Config]), + + %% Check that we have the httpd top supervisor + io:format("httpd_subtree -> verify inets~n", []), + {ok, _} = verify_child(inets_sup, httpd_sup, supervisor), + + %% Check that we have the httpd instance supervisor + io:format("httpd_subtree -> verify httpd~n", []), + {ok, Id} = verify_child(httpd_sup, httpd_instance_sup, supervisor), + {httpd_instance_sup, Addr, Port} = Id, + Instance = httpd_util:make_name("httpd_instance_sup", Addr, Port), + + %% Check that we have the expected httpd instance children + io:format("httpd_subtree -> verify httpd instance children " + "(acceptor, misc and manager)~n", []), + {ok, _} = verify_child(Instance, httpd_acceptor_sup, supervisor), + {ok, _} = verify_child(Instance, httpd_misc_sup, supervisor), + {ok, _} = verify_child(Instance, httpd_manager, worker), + + %% Check that the httpd instance acc supervisor has children + io:format("httpd_subtree -> verify acc~n", []), + InstanceAcc = httpd_util:make_name("httpd_acc_sup", Addr, Port), + case supervisor:which_children(InstanceAcc) of + [_ | _] -> + ok; + InstanceAccUnexpectedChildren -> + exit({unexpected_children, + InstanceAcc, InstanceAccUnexpectedChildren}) + end, + + %% Check that the httpd instance misc supervisor has no children + io:format("httpd_subtree -> verify misc~n", []), + InstanceMisc = httpd_util:make_name("httpd_misc_sup", Addr, Port), + case supervisor:which_children(InstanceMisc) of + [] -> + ok; + InstanceMiscUnexpectedChildren -> + exit({unexpected_children, + InstanceMisc, InstanceMiscUnexpectedChildren}) + end, + io:format("httpd_subtree -> done~n", []), + ok. + + +verify_child(Parent, Child, Type) -> +%% io:format("verify_child -> entry with" +%% "~n Parent: ~p" +%% "~n Child: ~p" +%% "~n Type: ~p" +%% "~n", [Parent, Child, Type]), + Children = supervisor:which_children(Parent), +%% io:format("verify_child -> which children" +%% "~n Children: ~p" +%% "~n", [Children]), + verify_child(Children, Parent, Child, Type). + +verify_child([], Parent, Child, _Type) -> + {error, {child_not_found, Child, Parent}}; +verify_child([{Id, _Pid, Type2, Mods}|Children], Parent, Child, Type) -> + case lists:member(Child, Mods) of + true when (Type2 =:= Type) -> +%% io:format("verify_child -> found with expected type" +%% "~n Id: ~p" +%% "~n", [Id]), + {ok, Id}; + true when (Type2 =/= Type) -> +%% io:format("verify_child -> found with unexpected type" +%% "~n Type2: ~p" +%% "~n Id: ~p" +%% "~n", [Type2, Id]), + {error, {wrong_type, Type2, Child, Parent}}; + false -> + verify_child(Children, Parent, Child, Type) + end. + + + +%%------------------------------------------------------------------------- +%% httpc_subtree +%%------------------------------------------------------------------------- +httpc_subtree(doc) -> + ["Makes sure the httpc sub tree is correct."]; +httpc_subtree(suite) -> + []; +httpc_subtree(Config) when is_list(Config) -> + tsp("httpc_subtree -> entry with" + "~n Config: ~p", [Config]), + + tsp("httpc_subtree -> start inets service httpc with profile foo"), + {ok, Foo} = inets:start(httpc, [{profile, foo}]), + + tsp("httpc_subtree -> " + "start stand-alone inets service httpc with profile bar"), + {ok, Bar} = inets:start(httpc, [{profile, bar}], stand_alone), + + tsp("httpc_subtree -> retreive list of httpc instances"), + HttpcChildren = supervisor:which_children(httpc_profile_sup), + tsp("httpc_subtree -> HttpcChildren: ~n~p", [HttpcChildren]), + + tsp("httpc_subtree -> verify httpc stand-alone instances"), + {value, {httpc_manager, _, worker, [httpc_manager]}} = + lists:keysearch(httpc_manager, 1, HttpcChildren), + + tsp("httpc_subtree -> verify httpc (named) instances"), + {value,{{httpc,foo}, Pid, worker, [httpc_manager]}} = + lists:keysearch({httpc, foo}, 1, HttpcChildren), + false = lists:keysearch({httpc, bar}, 1, HttpcChildren), + + tsp("httpc_subtree -> stop inets"), + inets:stop(httpc, Pid), + + tsp("httpc_subtree -> done"), + ok. + +inet_port() -> + {ok, Socket} = gen_tcp:listen(0, [{reuseaddr, true}]), + {ok, Port} = inet:port(Socket), + gen_tcp:close(Socket), + Port. + + +tsp(F) -> + tsp(F, []). +tsp(F, A) -> + test_server:format("~p ~p:" ++ F ++ "~n", [self(), ?MODULE | A]). + +tsf(Reason) -> + test_server:fail(Reason). + diff --git a/lib/inets/test/inets_sup_SUITE_data/mime.types b/lib/inets/test/inets_sup_SUITE_data/mime.types new file mode 100644 index 0000000000..e52d345ff7 --- /dev/null +++ b/lib/inets/test/inets_sup_SUITE_data/mime.types @@ -0,0 +1,3 @@ +# MIME type Extension +text/html html htm +text/plain asc txt diff --git a/lib/inets/test/inets_sup_SUITE_data/simple.conf b/lib/inets/test/inets_sup_SUITE_data/simple.conf new file mode 100644 index 0000000000..e1429b4a28 --- /dev/null +++ b/lib/inets/test/inets_sup_SUITE_data/simple.conf @@ -0,0 +1,6 @@ +Port 8888 +ServerName www.test +SocketType ip_comm +Modules mod_get +ServerAdmin [email protected] + diff --git a/lib/inets/test/inets_test_lib.erl b/lib/inets/test/inets_test_lib.erl new file mode 100644 index 0000000000..6af2ad32f7 --- /dev/null +++ b/lib/inets/test/inets_test_lib.erl @@ -0,0 +1,302 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(inets_test_lib). + +-include("inets_test_lib.hrl"). + +%% Various small utility functions +-export([start_http_server/1, start_http_server_ssl/1]). +-export([hostname/0]). +-export([connect_bin/3, connect_byte/3, send/3, close/2]). +-export([copy_file/3, copy_files/2, copy_dirs/2, del_dirs/1]). +-export([info/4, log/4, debug/4, print/4]). +-export([check_body/1]). +-export([millis/0, millis_diff/2, hours/1, minutes/1, seconds/1, sleep/1]). +-export([non_pc_tc_maybe_skip/4, os_based_skip/1]). + +start_http_server(Conf) -> + application:load(inets), + ok = application:set_env(inets, services, [{httpd, Conf}]), + ok = application:start(inets). + +start_http_server_ssl(FileName) -> + application:start(ssl), + catch start_http_server(FileName). + +%% ---------------------------------------------------------------------- +%% print functions +%% + +info(F, A, Mod, Line) -> + print("INF ", F, A, Mod, Line). + +log(F, A, Mod, Line) -> + print("LOG ", F, A, Mod, Line). + +debug(F, A, Mod, Line) -> + print("DBG ", F, A, Mod, Line). + +print(P, F, A, Mod, Line) -> + io:format("~s[~p:~p:~p] : " ++ F ++ "~n", [P, self(), Mod, Line| A]). + +print(F, A, Mod, Line) -> + print("", F, A, Mod, Line). + +hostname() -> + from($@, atom_to_list(node())). +from(H, [H | T]) -> T; +from(H, [_ | T]) -> from(H, T); +from(_, []) -> []. + + +copy_file(File, From, To) -> + file:copy(filename:join(From, File), filename:join(To, File)). + +copy_files(FromDir, ToDir) -> + {ok, Files} = file:list_dir(FromDir), + lists:foreach(fun(File) -> + FullPath = filename:join(FromDir, File), + case filelib:is_file(FullPath) of + true -> + file:copy(FullPath, + filename:join(ToDir, File)); + false -> + ok + end + end, Files). + + +copy_dirs(FromDirRoot, ToDirRoot) -> +%% io:format("~w:copy_dirs -> entry with" +%% "~n FromDirRoot: ~p" +%% "~n ToDirRoot: ~p" +%% "~n", [?MODULE, FromDirRoot, ToDirRoot]), + {ok, Files} = file:list_dir(FromDirRoot), + lists:foreach( + fun(FileOrDir) -> + %% Check if it's a directory or a file +%% io:format("~w:copy_dirs -> check ~p" +%% "~n", [?MODULE, FileOrDir]), + case filelib:is_dir(filename:join(FromDirRoot, FileOrDir)) of + true -> +%% io:format("~w:copy_dirs -> ~p is a directory" +%% "~n", [?MODULE, FileOrDir]), + FromDir = filename:join([FromDirRoot, FileOrDir]), + ToDir = filename:join([ToDirRoot, FileOrDir]), + ok = file:make_dir(ToDir), + copy_dirs(FromDir, ToDir); + false -> +%% io:format("~w:copy_dirs -> ~p is a file" +%% "~n", [?MODULE, FileOrDir]), + copy_file(FileOrDir, FromDirRoot, ToDirRoot) + end + end, Files). + +del_dirs(Dir) -> + case file:list_dir(Dir) of + {ok, []} -> + file:del_dir(Dir); + {ok, Files} -> + lists:foreach(fun(File) -> + FullPath = filename:join(Dir,File), + case filelib:is_dir(FullPath) of + true -> + del_dirs(FullPath), + file:del_dir(FullPath); + false -> + file:delete(FullPath) + end + end, Files); + _ -> + ok + end. + +check_body(Body) -> + case string:rstr(Body, "</html>") of + 0 -> + case string:rstr(Body, "</HTML>") of + 0 -> + test_server:format("Body ~p~n", [Body]), + test_server:fail(did_not_receive_whole_body); + _ -> + ok + end; + _ -> + ok + end. + +%% ---------------------------------------------------------------- +%% Conditional skip of testcases +%% + +non_pc_tc_maybe_skip(Config, Condition, File, Line) + when is_list(Config) andalso is_function(Condition) -> + %% Check if we shall skip the skip + case os:getenv("TS_OS_BASED_SKIP") of + "false" -> + ok; + _ -> + case lists:keysearch(ts, 1, Config) of + {value, {ts, inets}} -> + %% Always run the testcase if we are using our own + %% test-server... + ok; + _ -> + case (catch Condition()) of + true -> + skip(non_pc_testcase, File, Line); + _ -> + ok + end + end + end. + + +os_based_skip(any) -> + true; +os_based_skip(Skippable) when is_list(Skippable) -> + {OsFam, OsName} = + case os:type() of + {_Fam, _Name} = FamAndName -> + FamAndName; + Fam -> + {Fam, undefined} + end, + case lists:member(OsFam, Skippable) of + true -> + true; + false -> + case lists:keysearch(OsFam, 1, Skippable) of + {value, {OsFam, OsName}} -> + true; + {value, {OsFam, OsNames}} when is_list(OsNames) -> + lists:member(OsName, OsNames); + _ -> + false + end + end; +os_based_skip(_) -> + false. + + +%% ---------------------------------------------------------------------- +%% Socket functions: +%% open(SocketType, Host, Port) -> {ok, Socket} | {error, Reason} +%% SocketType -> ssl | ip_comm +%% Host -> atom() | string() | {A, B, C, D} +%% Port -> integer() + +connect_bin(ssl, Host, Port) -> + ssl:start(), + %% Does not support ipv6 in old ssl + case ssl:connect(Host, Port, [binary, {packet,0}]) of + {ok, Socket} -> + {ok, Socket}; + {error, Reason} -> + {error, Reason}; + Error -> + Error + end; +connect_bin(ip_comm, Host, Port) -> + Opts = [inet6, binary, {packet,0}], + connect(ip_comm, Host, Port, Opts). + + +connect(ip_comm, Host, Port, Opts) -> + test_server:format("gen_tcp:connect(~p, ~p, ~p) ~n", [Host, Port, Opts]), + case gen_tcp:connect(Host,Port, Opts) of + {ok, Socket} -> + test_server:format("connect success~n", []), + {ok, Socket}; + {error, nxdomain} -> + test_server:format("nxdomain opts: ~p~n", [Opts]), + connect(ip_comm, Host, Port, lists:delete(inet6, Opts)); + {error, eafnosupport} -> + test_server:format("eafnosupport opts: ~p~n", [Opts]), + connect(ip_comm, Host, Port, lists:delete(inet6, Opts)); + {error, {enfile,_}} -> + test_server:format("Error enfile~n", []), + {error, enfile}; + Error -> + test_server:format("Unexpected error: " + "~n Error: ~p" + "~nwhen" + "~n Host: ~p" + "~n Port: ~p" + "~n Opts: ~p" + "~n", [Error, Host, Port, Opts]), + Error + end. + +connect_byte(ip_comm, Host, Port) -> + Opts = [inet6, {packet,0}], + connect(ip_comm, Host, Port, Opts); + +connect_byte(ssl, Host, Port) -> + ssl:start(), + %% Does not support ipv6 in old ssl + case ssl:connect(Host,Port,[{packet,0}]) of + {ok,Socket} -> + {ok,Socket}; + {error,{enfile,_}} -> + {error, enfile}; + Error -> + Error + end. + +send(ssl, Socket, Data) -> + ssl:send(Socket, Data); +send(ip_comm,Socket,Data) -> + gen_tcp:send(Socket,Data). + + +close(ssl,Socket) -> + catch ssl:close(Socket); +close(ip_comm,Socket) -> + catch gen_tcp:close(Socket). + +millis() -> + erlang:now(). + +millis_diff(A,B) -> + T1 = (element(1,A)*1000000) + element(2,A) + (element(3,A)/1000000), + T2 = (element(1,B)*1000000) + element(2,B) + (element(3,B)/1000000), + T1 - T2. + +hours(N) -> trunc(N * 1000 * 60 * 60). +minutes(N) -> trunc(N * 1000 * 60). +seconds(N) -> trunc(N * 1000). + + +sleep(infinity) -> + receive + after infinity -> + ok + end; +sleep(MSecs) -> + receive + after trunc(MSecs) -> + ok + end, + ok. + + +skip(Reason, File, Line) -> + exit({skipped, {Reason, File, Line}}). diff --git a/lib/inets/test/inets_test_lib.hrl b/lib/inets/test/inets_test_lib.hrl new file mode 100644 index 0000000000..12a43fa136 --- /dev/null +++ b/lib/inets/test/inets_test_lib.hrl @@ -0,0 +1,104 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%---------------------------------------------------------------------- +%% Purpose: Define common macros for testing +%%---------------------------------------------------------------------- + +%% - Print macros - + +-ifdef(inets_debug). +-define(DEBUG(F,A), inets_test_lib:debug(F, A, ?MODULE, ?LINE)). +-else. +-define(DEBUG(F,A),ok). +-endif. + +-ifdef(inets_log). +-define(LOG(F,A), inets_test_lib:log(F, A, ?MODULE, ?LINE)). +-else. +-define(LOG(F,A),ok). +-endif. + +-define(INFO(F,A), inets_test_lib:info(F, A, ?MODULE, ?LINE)). +-define(PRINT(F,A), inets_test_lib:print(F, A, ?MODULE, ?LINE)). + + +%% - Macros stolen from the test server - + +-ifndef(line). +-define(line,put(test_server_loc,{?MODULE,?LINE}),). +-endif. + + +%% - Test case macros - + +-define(EXPANDABLE(I, C, F), inets_test_lib:expandable(I, C, F)). +-define(OS_BASED_SKIP(Skippable), + inets_test_lib:os_based_skip(Skippable)). + +-define(NON_PC_TC_MAYBE_SKIP(Config, Condition), + inets_test_lib:non_pc_tc_maybe_skip(Config, Condition, ?MODULE, ?LINE)). + + + +%% - Misc macros - + +-define(UPDATE(K,V,C), inets_test_lib:update_config(K,V,C)). +-define(CONFIG(K,C), inets_test_lib:get_config(K,C)). +-define(HOSTNAME(), inets_test_lib:hostname()). +-define(SZ(X), inets_test_lib:sz(X)). + + +%% - Test case macros - + +-define(SKIP(Reason), inets_test_lib:skip(Reason)). +-define(FAIL(Reason), inets_test_lib:fail(Reason, ?MODULE, ?LINE)). + + +%% - Socket macros - + +-define(CONNECT(M,H,P), inets_test_lib:connect(M,H,P)). +-define(SEND(M,S,D), inets_test_lib:send(M,S,D)). +-define(CSEND(M,S,D,C,T), inets_test_lib:csend(M,S,D,C,T)). +-define(CLOSE(M,S), inets_test_lib:close(M,S)). + + +%% - Time macros - + +-define(HOURS(N), inets_test_lib:hours(N)). +-define(MINS(N), inets_test_lib:minutes(N)). +-define(SECS(N), inets_test_lib:seconds(N)). + +-define(WD_START(T), inets_test_lib:watchdog_start(T)). +-define(WD_STOP(P), inets_test_lib:watchdog_stop(P)). + +-define(SLEEP(MSEC), inets_test_lib:sleep(MSEC)). +-define(M(), inets_test_lib:millis()). +-define(MDIFF(A,B), inets_test_lib:millis_diff(A,B)). + + +%% - Process utility macros - + +-define(FLUSH(), inets_test_lib:flush_mqueue()). +-define(ETRAP_GET(), inets_test_lib:trap_exit()). +-define(ETRAP_SET(O), inets_test_lib:trap_exit(O)). + + + + diff --git a/lib/inets/test/rules.mk b/lib/inets/test/rules.mk new file mode 100644 index 0000000000..047c03b267 --- /dev/null +++ b/lib/inets/test/rules.mk @@ -0,0 +1,59 @@ +#-*-makefile-*- ; force emacs to enter makefile-mode +# ---------------------------------------------------- +# Make include file for otp +# +# Copyright (C) 1996, Ericsson Telecommunications +# Author: Lars Thorsen +# ---------------------------------------------------- +.SUFFIXES: .hrl .erl .jam .beam + + +# ---------------------------------------------------- +# Common macros +# ---------------------------------------------------- +DEFAULT_TARGETS = opt debug instr release release_docs clean docs + +# ---------------------------------------------------- +# Erlang language section +# ---------------------------------------------------- +EMULATOR = beam +ifeq ($(findstring vxworks,$(TARGET)),vxworks) +# VxWorks object files should be compressed. +# Other object files should have debug_info. +ERL_COMPILE_FLAGS += +compressed +else +ifdef BOOTSTRAP +ERL_COMPILE_FLAGS += +slim +else +ERL_COMPILE_FLAGS += +debug_info +endif +endif +ERLC_WFLAGS = -W +ERLC = erlc $(ERLC_WFLAGS) $(ERLC_FLAGS) +ERL.beam = erl.beam -boot start_clean +ERL.jam = erl -boot start_clean +ERL = $(ERL.$(EMULATOR)) + +ifeq ($(EBIN),) +EBIN = . +endif + +ESRC = . + + +$(EBIN)/%.jam: $(ESRC)/%.erl + $(ERLC) -bjam $(ERL_COMPILE_FLAGS) -o$(EBIN) $< + +$(EBIN)/%.beam: $(ESRC)/%.erl + $(ERLC) -bbeam $(ERL_COMPILE_FLAGS) -o$(EBIN) $< + +.erl.jam: + $(ERLC) -bjam $(ERL_COMPILE_FLAGS) -o$(dir $@) $< + +.erl.beam: + $(ERLC) -bbeam $(ERL_COMPILE_FLAGS) -o$(dir $@) $< + + + + + diff --git a/lib/inets/test/tftp_SUITE.erl b/lib/inets/test/tftp_SUITE.erl new file mode 100644 index 0000000000..5768fff88b --- /dev/null +++ b/lib/inets/test/tftp_SUITE.erl @@ -0,0 +1,903 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2006-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +-module(tftp_SUITE). + +-compile(export_all). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Includes and defines +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +-include("tftp_test_lib.hrl"). + +-define(START_DAEMON(PortX, OptionsX), + fun(Port, Options) -> + {ok, Pid} = ?VERIFY({ok, _Pid}, tftp:start([{port, Port} | Options])), + if + Port == 0 -> + {ok, ActualOptions} = ?IGNORE(tftp:info(Pid)), + {value, {port, ActualPort}} = + lists:keysearch(port, 1, ActualOptions), + {ActualPort, Pid}; + true -> + {Port, Pid} + end + end(PortX, OptionsX)). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% API +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +t() -> + tftp_test_lib:t([{?MODULE, all}]). + +t(Cases) -> + tftp_test_lib:t(Cases, default_config()). + +t(Cases, Config) -> + tftp_test_lib:t(Cases, Config). + +default_config() -> + []. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Test server callbacks +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +init_per_testcase(Case, Config) -> + tftp_test_lib:init_per_testcase(Case, Config). + +fin_per_testcase(Case, Config) when is_list(Config) -> + tftp_test_lib:fin_per_testcase(Case, Config). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Top test case +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +all(doc) -> + ["Test suites for TFTP."]; + +all(suite) -> + [ + simple, + extra, + reuse_connection, + resend_client, + resend_server + ]. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Simple +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +simple(doc) -> + ["Start the daemon and perform simple a read and write."]; +simple(suite) -> + []; +simple(Config) when is_list(Config) -> + ?VERIFY(ok, application:start(inets)), + + {Port, DaemonPid} = ?IGNORE(?START_DAEMON(0, [{debug, brief}])), + + %% Read fail + RemoteFilename = "tftp_temporary_remote_test_file.txt", + LocalFilename = "tftp_temporary_local_test_file.txt", + Blob = list_to_binary(lists:duplicate(2000, $1)), + %% Blob = <<"Some file contents\n">>, + Size = size(Blob), + ?IGNORE(file:delete(RemoteFilename)), + ?VERIFY({error, {client_open, enoent, _}}, + tftp:read_file(RemoteFilename, binary, [{port, Port}])), + + %% Write and read + ?VERIFY({ok, Size}, tftp:write_file(RemoteFilename, Blob, [{port, Port}])), + ?VERIFY({ok, Blob}, tftp:read_file(RemoteFilename, binary, [{port, Port}])), + ?IGNORE(file:delete(LocalFilename)), + ?VERIFY({ok, Size}, tftp:read_file(RemoteFilename, LocalFilename, [{port, Port}])), + + %% Cleanup + unlink(DaemonPid), + exit(DaemonPid, kill), + ?VERIFY(ok, file:delete(LocalFilename)), + ?VERIFY(ok, file:delete(RemoteFilename)), + ?VERIFY(ok, application:stop(inets)), + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Extra +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +extra(doc) -> + ["Verify new stuff for IS 1.2."]; +extra(suite) -> + []; +extra(Config) when is_list(Config) -> + ?VERIFY({'EXIT', {badarg,{fake_key, fake_flag}}}, + tftp:start([{port, 0}, {fake_key, fake_flag}])), + + {Port, DaemonPid} = ?IGNORE(?START_DAEMON(0, [{debug, brief}])), + + RemoteFilename = "tftp_extra_temporary_remote_test_file.txt", + LocalFilename = "tftp_extra_temporary_local_test_file.txt", + Blob = <<"Some file contents\n">>, + Size = size(Blob), + Host = "127.0.0.1", + Peer = {inet, Host, Port}, + Generic = + [ + {state, []}, + {prepare, fun extra_prepare/6}, + {open, fun extra_open/6}, + {read, fun extra_read/1}, + {write, fun extra_write/2}, + {abort, fun extra_abort/3 } + ], + Options = [{host, Host}, + {port, Port}, + %%{ debug,all}, + {callback, {".*", tftp_test_lib, Generic}}], + ?VERIFY(ok, file:write_file(LocalFilename, Blob)), + ?VERIFY({ok, [{count, Size}, Peer]}, + tftp:write_file(RemoteFilename, LocalFilename, Options)), + ?VERIFY(ok, file:delete(LocalFilename)), + + ?VERIFY({ok,[{bin, Blob}, Peer]}, + tftp:read_file(RemoteFilename, LocalFilename, Options)), + + %% Cleanup + unlink(DaemonPid), + exit(DaemonPid, kill), + ?VERIFY(ok, file:delete(LocalFilename)), + ?VERIFY(ok, file:delete(RemoteFilename)), + ok. + +-record(extra_state, {file, blksize, count, acc, peer}). + +%%------------------------------------------------------------------- +%% Prepare +%%------------------------------------------------------------------- + +extra_prepare(Peer, Access, LocalFilename, Mode, SuggestedOptions, []) -> + %% Client side + BlkSize = list_to_integer(tftp_test_lib:lookup_option("blksize", "512", SuggestedOptions)), + State = #extra_state{blksize = BlkSize, peer = Peer}, + extra_open(Peer, Access, LocalFilename, Mode, SuggestedOptions, State), + {ok, SuggestedOptions, State}; +extra_prepare(_Peer, _Access, _Bin, _Mode, _SuggestedOptions, _Initial) -> + {error, {undef, "Illegal callback options."}}. + +%%------------------------------------------------------------------- +%% Open +%%------------------------------------------------------------------- + +extra_open(Peer, Access, LocalFilename, Mode, SuggestedOptions, []) -> + %% Server side + case extra_prepare(Peer, Access, LocalFilename, Mode, SuggestedOptions, []) of + {ok, AcceptedOptions, []} -> + BlkSize = list_to_integer(tftp_test_lib:lookup_option("blksize", "512", AcceptedOptions)), + State = #extra_state{blksize = BlkSize, peer = Peer}, + extra_open(Peer, Access, LocalFilename, Mode, AcceptedOptions, State); + {error, {Code, Text}} -> + {error, {Code, Text}} + end; +extra_open(_Peer, Access, LocalFilename, _Mode, NegotiatedOptions, #extra_state{} = State) -> + {File, Acc} = + case Access of + read -> + if + is_binary(LocalFilename) -> + {undefined, LocalFilename}; + is_list(LocalFilename) -> + {ok, Bin} = file:read_file(LocalFilename), + {LocalFilename, Bin} + end; + write -> + {LocalFilename, []} + end, + %% Both sides + State2 = State#extra_state{file = File, acc = Acc, count = 0}, + {ok, NegotiatedOptions, State2}. + +%%------------------------------------------------------------------- +%% Read +%%------------------------------------------------------------------- + +extra_read(#extra_state{acc = Bin} = State) when is_binary(Bin) -> + BlkSize = State#extra_state.blksize, + Count = State#extra_state.count + size(Bin), + if + size(Bin) >= BlkSize -> + <<Block:BlkSize/binary, Bin2/binary>> = Bin, + State2 = State#extra_state{acc = Bin2, count = Count}, + {more, Block, State2}; + size(Bin) < BlkSize -> + Res = [{count, Count}, State#extra_state.peer], + {last, Bin, Res} + end. + +%%------------------------------------------------------------------- +%% Write +%%------------------------------------------------------------------- + +extra_write(Bin, #extra_state{acc = List} = State) when is_binary(Bin), is_list(List) -> + Size = size(Bin), + BlkSize = State#extra_state.blksize, + if + Size == BlkSize -> + {more, State#extra_state{acc = [Bin | List]}}; + Size < BlkSize -> + Bin2 = list_to_binary(lists:reverse([Bin | List])), + Res = [{bin, Bin2}, State#extra_state.peer], + file:write_file(State#extra_state.file, Bin2), + {last, Res} + end. + +%%------------------------------------------------------------------- +%% Abort +%%------------------------------------------------------------------- + +extra_abort(_Code, _Text, #extra_state{}) -> + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Re-send client +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +resend_client(doc) -> + ["Verify that the server behaves correctly when the client re-sends packets."]; +resend_client(suite) -> + []; +resend_client(Config) when is_list(Config) -> + Host = {127, 0, 0, 1}, + {Port, DaemonPid} = ?IGNORE(?START_DAEMON(0, [{debug, all}])), + + ?VERIFY(ok, resend_read_client(Host, Port, 10)), + ?VERIFY(ok, resend_read_client(Host, Port, 512)), + ?VERIFY(ok, resend_read_client(Host, Port, 1025)), + + ?VERIFY(ok, resend_write_client(Host, Port, 10)), + ?VERIFY(ok, resend_write_client(Host, Port, 512)), + ?VERIFY(ok, resend_write_client(Host, Port, 1025)), + + %% Cleanup + unlink(DaemonPid), + exit(DaemonPid, kill), + ok. + +resend_read_client(Host, Port, BlkSize) -> + RemoteFilename = "tftp_resend_read_client.tmp", + Block1 = lists:duplicate(BlkSize, $1), + Block2 = lists:duplicate(BlkSize, $2), + Block3 = lists:duplicate(BlkSize, $3), + Block4 = lists:duplicate(BlkSize, $4), + Block5 = lists:duplicate(BlkSize, $5), + Blocks = [Block1, Block2, Block3, Block4, Block5], + Blob = list_to_binary(Blocks), + ?VERIFY(ok, file:write_file(RemoteFilename, Blob)), + + Timeout = timer:seconds(3), + ?VERIFY(timeout, recv(0)), + + %% Open socket + {ok, Socket} = ?VERIFY({ok, _}, gen_udp:open(0, [binary, {reuseaddr, true}, {active, true}])), + + ReadList = [0, 1, RemoteFilename, 0, "octet", 0], + Data1Bin = list_to_binary([0, 3, 0, 1 | Block1]), + NewPort = + if + BlkSize =:= 512 -> + %% Send READ + ReadBin = list_to_binary(ReadList), + ?VERIFY(ok, gen_udp:send(Socket, Host, Port, ReadBin)), + + %% Sleep a while in order to provoke the server to re-send the packet + timer:sleep(Timeout + timer:seconds(1)), + + %% Recv DATA #1 (the packet that the server think that we have lost) + {udp, _, _, NewPort0, _} = ?VERIFY({udp, Socket, Host, _, Data1Bin}, recv(Timeout)), + NewPort0; + true -> + %% Send READ + BlkSizeList = integer_to_list(BlkSize), + Options = ["blksize", 0, BlkSizeList, 0], + ReadBin = list_to_binary([ReadList | Options]), + ?VERIFY(ok, gen_udp:send(Socket, Host, Port, ReadBin)), + + %% Recv OACK + OptionAckBin = list_to_binary([0, 6 | Options]), + {udp, _, _, NewPort0, _} = ?VERIFY({udp, Socket, Host, _, OptionAckBin}, recv(Timeout)), + + %% Send ACK #0 + Ack0Bin = <<0, 4, 0, 0>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort0, Ack0Bin)), + + %% Send ACK #0 AGAIN (pretend that we timed out) + timer:sleep(timer:seconds(1)), + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort0, Ack0Bin)), + + %% Recv DATA #1 (the packet that the server think that we have lost) + ?VERIFY({udp, Socket, Host, NewPort0, Data1Bin}, recv(Timeout)), + NewPort0 + end, + + %% Recv DATA #1 AGAIN (the re-sent package) + ?VERIFY({udp, Socket, Host, NewPort, Data1Bin}, recv(Timeout)), + + %% Send ACK #1 + Ack1Bin = <<0, 4, 0, 1>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack1Bin)), + + %% Recv DATA #2 + Data2Bin = list_to_binary([0, 3, 0, 2 | Block2]), + ?VERIFY({udp, Socket, Host, NewPort, Data2Bin}, recv(Timeout)), + + %% Send ACK #2 + Ack2Bin = <<0, 4, 0, 2>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack2Bin)), + + %% Recv DATA #3 + Data3Bin = list_to_binary([0, 3, 0, 3 | Block3]), + ?VERIFY({udp, Socket, Host, NewPort, Data3Bin}, recv(Timeout)), + + %% Send ACK #3 + Ack3Bin = <<0, 4, 0, 3>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack3Bin)), + + %% Send ACK #3 AGAIN (pretend that we timed out) + timer:sleep(timer:seconds(1)), + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack3Bin)), + + %% Recv DATA #4 (the packet that the server think that we have lost) + Data4Bin = list_to_binary([0, 3, 0, 4 | Block4]), + ?VERIFY({udp, Socket, Host, NewPort, Data4Bin}, recv(Timeout)), + + %% Recv DATA #4 AGAIN (the re-sent package) + ?VERIFY({udp, Socket, Host, NewPort, Data4Bin}, recv(Timeout)), + + %% Send ACK #2 which is out of range + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack2Bin)), + + %% Send ACK #4 + Ack4Bin = <<0, 4, 0, 4>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack4Bin)), + + %% Recv DATA #5 + Data5Bin = list_to_binary([0, 3, 0, 5 | Block5]), + ?VERIFY({udp, Socket, Host, NewPort, Data5Bin}, recv(Timeout)), + + %% Send ACK #5 + Ack5Bin = <<0, 4, 0, 5>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack5Bin)), + + %% Close socket + ?VERIFY(ok, gen_udp:close(Socket)), + + ?VERIFY(timeout, recv(Timeout)), + ?VERIFY(ok, file:delete(RemoteFilename)), + ok. + +resend_write_client(Host, Port, BlkSize) -> + RemoteFilename = "tftp_resend_write_client.tmp", + Block1 = lists:duplicate(BlkSize, $1), + Block2 = lists:duplicate(BlkSize, $2), + Block3 = lists:duplicate(BlkSize, $3), + Block4 = lists:duplicate(BlkSize, $4), + Block5 = lists:duplicate(BlkSize, $5), + Blocks = [Block1, Block2, Block3, Block4, Block5], + Blob = list_to_binary(Blocks), + ?IGNORE(file:delete(RemoteFilename)), + ?VERIFY({error, enoent}, file:read_file(RemoteFilename)), + + Timeout = timer:seconds(3), + ?VERIFY(timeout, recv(0)), + + %% Open socket + {ok, Socket} = ?VERIFY({ok, _}, gen_udp:open(0, [binary, {reuseaddr, true}, {active, true}])), + + WriteList = [0, 2, RemoteFilename, 0, "octet", 0], + NewPort = + if + BlkSize =:= 512 -> + %% Send WRITE + WriteBin = list_to_binary(WriteList), + ?VERIFY(ok, gen_udp:send(Socket, Host, Port, WriteBin)), + + %% Sleep a while in order to provoke the server to re-send the packet + timer:sleep(Timeout + timer:seconds(1)), + + %% Recv ACK #0 (the packet that the server think that we have lost) + Ack0Bin = <<0, 4, 0, 0>>, + ?VERIFY({udp, Socket, Host, _, Ack0Bin}, recv(Timeout)), + + %% Recv ACK #0 AGAIN (the re-sent package) + {udp, _, _, NewPort0, _} = ?VERIFY({udp, Socket, Host, _, Ack0Bin}, recv(Timeout)), + NewPort0; + true -> + %% Send WRITE + BlkSizeList = integer_to_list(BlkSize), + WriteBin = list_to_binary([WriteList, "blksize", 0, BlkSizeList, 0]), + ?VERIFY(ok, gen_udp:send(Socket, Host, Port, WriteBin)), + + %% Sleep a while in order to provoke the server to re-send the packet + timer:sleep(timer:seconds(1)), + + %% Recv OACK (the packet that the server think that we have lost) + OptionAckBin = list_to_binary([0, 6, "blksize",0, BlkSizeList, 0]), + ?VERIFY({udp, Socket, Host, _, OptionAckBin}, recv(Timeout)), + + %% Recv OACK AGAIN (the re-sent package) + {udp, _, _, NewPort0, _} = ?VERIFY({udp, Socket, Host, _, OptionAckBin}, recv(Timeout)), + NewPort0 + end, + + %% Send DATA #1 + Data1Bin = list_to_binary([0, 3, 0, 1 | Block1]), + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Data1Bin)), + + %% Recv ACK #1 + Ack1Bin = <<0, 4, 0, 1>>, + ?VERIFY({udp, Socket, Host, NewPort, Ack1Bin}, recv(Timeout)), + + %% Send DATA #2 + Data2Bin = list_to_binary([0, 3, 0, 2 | Block2]), + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Data2Bin)), + + %% Recv ACK #2 + Ack2Bin = <<0, 4, 0, 2>>, + ?VERIFY({udp, Socket, Host, NewPort, Ack2Bin}, recv(Timeout)), + + %% Send DATA #3 + Data3Bin = list_to_binary([0, 3, 0, 3 | Block3]), + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Data3Bin)), + + %% Recv ACK #3 + Ack3Bin = <<0, 4, 0, 3>>, + ?VERIFY({udp, Socket, Host, NewPort, Ack3Bin}, recv(Timeout)), + + %% Send DATA #3 AGAIN (pretend that we timed out) + timer:sleep(timer:seconds(1)), + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Data3Bin)), + + %% Recv ACK #3 AGAIN (the packet that the server think that we have lost) + ?VERIFY({udp, Socket, Host, NewPort, Ack3Bin}, recv(Timeout)), + + %% Send DATA #2 which is out of range + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Data2Bin)), + + %% Send DATA #4 + Data4Bin = list_to_binary([0, 3, 0, 4 | Block4]), + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Data4Bin)), + + %% Recv ACK #4 + Ack4Bin = <<0, 4, 0, 4>>, + ?VERIFY({udp, Socket, Host, NewPort, Ack4Bin}, recv(Timeout)), + + %% Send DATA #5 + Data5Bin = list_to_binary([0, 3, 0, 5 | Block5]), + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Data5Bin)), + + %% Recv ACK #5 + Ack5Bin = <<0, 4, 0, 5>>, + ?VERIFY({udp, Socket, Host, NewPort, Ack5Bin}, recv(Timeout)), + + %% Close socket + ?VERIFY(ok, gen_udp:close(Socket)), + + ?VERIFY(timeout, recv(Timeout)), + ?VERIFY({ok, Blob}, file:read_file(RemoteFilename)), + ?VERIFY(ok, file:delete(RemoteFilename)), + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Re-send server +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +resend_server(doc) -> + ["Verify that the server behaves correctly when the server re-sends packets."]; +resend_server(suite) -> + []; +resend_server(Config) when is_list(Config) -> + Host = {127, 0, 0, 1}, + + ?VERIFY(ok, resend_read_server(Host, 10)), + ?VERIFY(ok, resend_read_server(Host, 512)), + ?VERIFY(ok, resend_read_server(Host, 1025)), + + ?VERIFY(ok, resend_write_server(Host, 10)), + ?VERIFY(ok, resend_write_server(Host, 512)), + ?VERIFY(ok, resend_write_server(Host, 1025)), + ok. + +resend_read_server(Host, BlkSize) -> + RemoteFilename = "tftp_resend_read_server.tmp", + Block1 = lists:duplicate(BlkSize, $1), + Block2 = lists:duplicate(BlkSize, $2), + Block3 = lists:duplicate(BlkSize, $3), + Block4 = lists:duplicate(BlkSize, $4), + Block5 = lists:duplicate(BlkSize, $5), + Block6 = [], + Blocks = [Block1, Block2, Block3, Block4, Block5, Block6], + Blob = list_to_binary(Blocks), + + Timeout = timer:seconds(3), + ?VERIFY(timeout, recv(0)), + + %% Open daemon socket + {ok, DaemonSocket} = ?VERIFY({ok, _}, gen_udp:open(0, [binary, {reuseaddr, true}, {active, true}])), + {ok, DaemonPort} = ?IGNORE(inet:port(DaemonSocket)), + + %% Open server socket + {ok, ServerSocket} = ?VERIFY({ok, _}, gen_udp:open(0, [binary, {reuseaddr, true}, {active, true}])), + ?IGNORE(inet:port(ServerSocket)), + + %% Prepare client process + ReplyTo = self(), + ClientFun = + fun(Extra) -> + Options = [{port, DaemonPort}, {debug, brief}] ++ Extra, + Res = ?VERIFY({ok, Blob}, tftp:read_file(RemoteFilename, binary, Options)), + ReplyTo ! {self(), {tftp_client_reply, Res}}, + exit(normal) + end, + + ReadList = [0, 1, RemoteFilename, 0, "octet", 0], + Data1Bin = list_to_binary([0, 3, 0, 1 | Block1]), + Ack1Bin = <<0, 4, 0, 1>>, + {ClientPort, ClientPid} = + if + BlkSize =:= 512 -> + %% Start client process + ClientPid0 = spawn_link(fun() -> ClientFun([]) end), + + %% Recv READ + ReadBin = list_to_binary(ReadList), + {udp, _, _, ClientPort0, _} = ?VERIFY({udp, DaemonSocket, Host, _, ReadBin}, recv(Timeout)), + + %% Send DATA #1 + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort0, Data1Bin)), + + %% Sleep a while in order to provoke the client to re-send the packet + timer:sleep(Timeout + timer:seconds(1)), + + %% Recv ACK #1 (the packet that the server think that we have lost) + ?VERIFY({udp, ServerSocket, Host, ClientPort0, Ack1Bin}, recv(Timeout)), + + %% Recv ACK #1 AGAIN (the re-sent package) + ?VERIFY({udp, ServerSocket, Host, _, Ack1Bin}, recv(Timeout)), + {ClientPort0, ClientPid0}; + true -> + %% Start client process + BlkSizeList = integer_to_list(BlkSize), + ClientPid0 = spawn_link(fun() -> ClientFun([{"blksize", BlkSizeList}]) end), + + %% Recv READ + Options = ["blksize", 0, BlkSizeList, 0], + ReadBin = list_to_binary([ReadList | Options]), + {udp, _, _, ClientPort0, _} = ?VERIFY({udp, DaemonSocket, Host, _, ReadBin}, recv(Timeout)), + + %% Send OACK + BlkSizeList = integer_to_list(BlkSize), + OptionAckBin = list_to_binary([0, 6, "blksize",0, BlkSizeList, 0]), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort0, OptionAckBin)), + + %% Sleep a while in order to provoke the client to re-send the packet + timer:sleep(Timeout + timer:seconds(1)), + + %% Recv ACK #0 (the packet that the server think that we have lost) + Ack0Bin = <<0, 4, 0, 0>>, + ?VERIFY({udp, ServerSocket, Host, ClientPort0, Ack0Bin}, recv(Timeout)), + + %% Recv ACK #0 AGAIN (the re-sent package) + ?VERIFY({udp, ServerSocket, Host, ClientPort0, Ack0Bin}, recv(Timeout)), + + %% Send DATA #1 + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort0, Data1Bin)), + + %% Recv ACK #1 + ?VERIFY({udp, ServerSocket, Host, _, Ack1Bin}, recv(Timeout)), + {ClientPort0, ClientPid0} + end, + + %% Send DATA #2 + Data2Bin = list_to_binary([0, 3, 0, 2 | Block2]), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Data2Bin)), + + %% Recv ACK #2 + Ack2Bin = <<0, 4, 0, 2>>, + ?VERIFY({udp, ServerSocket, Host, ClientPort, Ack2Bin}, recv(Timeout)), + + %% Send DATA #3 + Data3Bin = list_to_binary([0, 3, 0, 3 | Block3]), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Data3Bin)), + + %% Recv ACK #3 + Ack3Bin = <<0, 4, 0, 3>>, + ?VERIFY({udp, ServerSocket, Host, ClientPort, Ack3Bin}, recv(Timeout)), + + %% Send DATA #3 AGAIN (pretend that we timed out) + timer:sleep(timer:seconds(1)), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Data3Bin)), + + %% Recv ACK #3 AGAIN (the packet that the server think that we have lost) + ?VERIFY({udp, ServerSocket, Host, ClientPort, Ack3Bin}, recv(Timeout)), + + %% Send DATA #4 + Data4Bin = list_to_binary([0, 3, 0, 4 | Block4]), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Data4Bin)), + + %% Recv ACK #4 + Ack4Bin = <<0, 4, 0, 4>>, + ?VERIFY({udp, ServerSocket, Host, ClientPort, Ack4Bin}, recv(Timeout)), + + %% Send DATA #3 which is out of range + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Data3Bin)), + + %% Send DATA #5 + Data5Bin = list_to_binary([0, 3, 0, 5 | Block5]), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Data5Bin)), + + %% Recv ACK #5 + Ack5Bin = <<0, 4, 0, 5>>, + ?VERIFY({udp, ServerSocket, Host, ClientPort, Ack5Bin}, recv(Timeout)), + + %% Send DATA #6 + Data6Bin = list_to_binary([0, 3, 0, 6 | Block6]), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Data6Bin)), + + %% Close daemon and server sockets + ?VERIFY(ok, gen_udp:close(ServerSocket)), + ?VERIFY(ok, gen_udp:close(DaemonSocket)), + + ?VERIFY({ClientPid, {tftp_client_reply, {ok, Blob}}}, recv(Timeout)), + + ?VERIFY(timeout, recv(Timeout)), + ok. + +resend_write_server(Host, BlkSize) -> + RemoteFilename = "tftp_resend_write_server.tmp", + Block1 = lists:duplicate(BlkSize, $1), + Block2 = lists:duplicate(BlkSize, $2), + Block3 = lists:duplicate(BlkSize, $3), + Block4 = lists:duplicate(BlkSize, $4), + Block5 = lists:duplicate(BlkSize, $5), + Block6 = [], + Blocks = [Block1, Block2, Block3, Block4, Block5, Block6], + Blob = list_to_binary(Blocks), + Size = size(Blob), + + Timeout = timer:seconds(3), + ?VERIFY(timeout, recv(0)), + + %% Open daemon socket + {ok, DaemonSocket} = ?VERIFY({ok, _}, gen_udp:open(0, [binary, {reuseaddr, true}, {active, true}])), + {ok, DaemonPort} = ?IGNORE(inet:port(DaemonSocket)), + + %% Open server socket + {ok, ServerSocket} = ?VERIFY({ok, _}, gen_udp:open(0, [binary, {reuseaddr, true}, {active, true}])), + ?IGNORE(inet:port(ServerSocket)), + + %% Prepare client process + ReplyTo = self(), + ClientFun = + fun(Extra) -> + Options = [{port, DaemonPort}, {debug, brief}] ++ Extra, + Res = ?VERIFY({ok, Size}, tftp:write_file(RemoteFilename, Blob, Options)), + ReplyTo ! {self(), {tftp_client_reply, Res}}, + exit(normal) + end, + + WriteList = [0, 2, RemoteFilename, 0, "octet", 0], + Data1Bin = list_to_binary([0, 3, 0, 1 | Block1]), + {ClientPort, ClientPid} = + if + BlkSize =:= 512 -> + %% Start client process + ClientPid0 = spawn_link(fun() -> ClientFun([]) end), + + %% Recv WRITE + WriteBin = list_to_binary(WriteList), + io:format("WriteBin ~p\n", [WriteBin]), + {udp, _, _, ClientPort0, _} = ?VERIFY({udp, DaemonSocket, Host, _, WriteBin}, recv(Timeout)), + + %% Send ACK #1 + Ack0Bin = <<0, 4, 0, 0>>, + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort0, Ack0Bin)), + + %% Sleep a while in order to provoke the client to re-send the packet + timer:sleep(Timeout + timer:seconds(1)), + + %% Recv DATA #1 (the packet that the server think that we have lost) + ?VERIFY({udp, ServerSocket, Host, ClientPort0, Data1Bin}, recv(Timeout)), + + %% Recv DATA #1 AGAIN (the re-sent package) + ?VERIFY({udp, ServerSocket, Host, _, Data1Bin}, recv(Timeout)), + {ClientPort0, ClientPid0}; + true -> + %% Start client process + BlkSizeList = integer_to_list(BlkSize), + ClientPid0 = spawn_link(fun() -> ClientFun([{"blksize", BlkSizeList}]) end), + + %% Recv WRITE + Options = ["blksize", 0, BlkSizeList, 0], + WriteBin = list_to_binary([WriteList | Options]), + {udp, _, _, ClientPort0, _} = ?VERIFY({udp, DaemonSocket, Host, _, WriteBin}, recv(Timeout)), + + %% Send OACK + BlkSizeList = integer_to_list(BlkSize), + OptionAckBin = list_to_binary([0, 6, "blksize",0, BlkSizeList, 0]), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort0, OptionAckBin)), + + %% Sleep a while in order to provoke the client to re-send the packet + timer:sleep(Timeout + timer:seconds(1)), + + %% Recv DATA #1 (the packet that the server think that we have lost) + ?VERIFY({udp, ServerSocket, Host, ClientPort0, Data1Bin}, recv(Timeout)), + + %% Recv DATA #1 AGAIN (the re-sent package) + ?VERIFY({udp, ServerSocket, Host, ClientPort0, Data1Bin}, recv(Timeout)), + {ClientPort0, ClientPid0} + end, + + %% Send ACK #1 + Ack1Bin = <<0, 4, 0, 1>>, + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Ack1Bin)), + + %% Recv DATA #2 + Data2Bin = list_to_binary([0, 3, 0, 2 | Block2]), + ?VERIFY({udp, ServerSocket, Host, ClientPort, Data2Bin}, recv(Timeout)), + + %% Send ACK #2 + Ack2Bin = <<0, 4, 0, 2>>, + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Ack2Bin)), + + %% Recv DATA #3 + Data3Bin = list_to_binary([0, 3, 0, 3 | Block3]), + ?VERIFY({udp, ServerSocket, Host, ClientPort, Data3Bin}, recv(Timeout)), + + %% Send ACK #3 + Ack3Bin = <<0, 4, 0, 3>>, + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Ack3Bin)), + + %% Send ACK #3 AGAIN (pretend that we timed out) + timer:sleep(timer:seconds(1)), + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Ack3Bin)), + + %% Recv DATA #4 (the packet that the server think that we have lost) + Data4Bin = list_to_binary([0, 3, 0, 4 | Block4]), + ?VERIFY({udp, ServerSocket, Host, ClientPort, Data4Bin}, recv(Timeout)), + + %% Recv DATA #4 AGAIN (the re-sent package) + ?VERIFY({udp, ServerSocket, Host, ClientPort, Data4Bin}, recv(Timeout)), + + %% Send ACK #4 + Ack4Bin = <<0, 4, 0, 4>>, + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Ack4Bin)), + + %% Recv DATA #5 + Data5Bin = list_to_binary([0, 3, 0, 5 | Block5]), + ?VERIFY({udp, ServerSocket, Host, ClientPort, Data5Bin}, recv(Timeout)), + + %% Send ACK #3 which is out of range + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Ack3Bin)), + + %% Send ACK #5 + Ack5Bin = <<0, 4, 0, 5>>, + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Ack5Bin)), + + %% Recv DATA #6 + Data6Bin = list_to_binary([0, 3, 0, 6 | Block6]), + ?VERIFY({udp, ServerSocket, Host, ClientPort, Data6Bin}, recv(Timeout)), + + %% Send ACK #6 + Ack6Bin = <<0, 4, 0, 6>>, + ?VERIFY(ok, gen_udp:send(ServerSocket, Host, ClientPort, Ack6Bin)), + + %% Close daemon and server sockets + ?VERIFY(ok, gen_udp:close(ServerSocket)), + ?VERIFY(ok, gen_udp:close(DaemonSocket)), + + ?VERIFY({ClientPid, {tftp_client_reply, {ok, Size}}}, recv(Timeout)), + + ?VERIFY(timeout, recv(Timeout)), + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +reuse_connection(doc) -> + ["Verify that the server can reuse an ongiong connection when same client resends request."]; +reuse_connection(suite) -> + []; +reuse_connection(Config) when is_list(Config) -> + Host = {127, 0, 0, 1}, + {Port, DaemonPid} = ?IGNORE(?START_DAEMON(0, [{debug, all}])), + + RemoteFilename = "reuse_connection.tmp", + BlkSize = 512, + Block1 = lists:duplicate(BlkSize, $1), + Block2 = lists:duplicate(BlkSize div 2, $2), + Blocks = [Block1, Block2], + Blob = list_to_binary(Blocks), + ?VERIFY(ok, file:write_file(RemoteFilename, Blob)), + + Seconds = 3, + Timeout = timer:seconds(Seconds), + ?VERIFY(timeout, recv(0)), + + %% Open socket + {ok, Socket} = ?VERIFY({ok, _}, gen_udp:open(0, [binary, {reuseaddr, true}, {active, true}])), + + ReadList = [0, 1, RemoteFilename, 0, "octet", 0], + Data1Bin = list_to_binary([0, 3, 0, 1 | Block1]), + + %% Send READ + TimeoutList = integer_to_list(Seconds), + Options = ["timeout", 0, TimeoutList, 0], + ReadBin = list_to_binary([ReadList | Options]), + ?VERIFY(ok, gen_udp:send(Socket, Host, Port, ReadBin)), + + %% Send yet another READ for same file + ?VERIFY(ok, gen_udp:send(Socket, Host, Port, ReadBin)), + + %% Recv OACK + OptionAckBin = list_to_binary([0, 6 | Options]), + {udp, _, _, NewPort, _} = ?VERIFY({udp, Socket, Host, _, OptionAckBin}, recv(Timeout)), + + %% Send ACK #0 + Ack0Bin = <<0, 4, 0, 0>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack0Bin)), + + %% Recv DATA #1 + ?VERIFY({udp, Socket, Host, NewPort, Data1Bin}, recv(Timeout)), + + %% Send ACK #1 + Ack1Bin = <<0, 4, 0, 1>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack1Bin)), + + %% Recv DATA #2 + Data2Bin = list_to_binary([0, 3, 0, 2 | Block2]), + ?VERIFY({udp, Socket, Host, NewPort, Data2Bin}, recv(Timeout)), + + %% Send ACK #2 + Ack2Bin = <<0, 4, 0, 2>>, + ?VERIFY(ok, gen_udp:send(Socket, Host, NewPort, Ack2Bin)), + + %% Close socket + ?VERIFY(ok, gen_udp:close(Socket)), + + ?VERIFY(timeout, recv(Timeout)), + ?VERIFY(ok, file:delete(RemoteFilename)), + + %% Cleanup + unlink(DaemonPid), + exit(DaemonPid, kill), + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Goodies +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +recv(Timeout) -> + receive + Msg -> + Msg + after Timeout -> + timeout + end. diff --git a/lib/inets/test/tftp_test_lib.erl b/lib/inets/test/tftp_test_lib.erl new file mode 100644 index 0000000000..3729309b0e --- /dev/null +++ b/lib/inets/test/tftp_test_lib.erl @@ -0,0 +1,307 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2007-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +-module(tftp_test_lib). + +-compile(export_all). + +-include("tftp_test_lib.hrl"). + +%% +%% ----- +%% + +init_per_testcase(_Case, Config) when is_list(Config) -> + io:format("\n ", []), + ?IGNORE(application:stop(inets)), + Config. + +fin_per_testcase(_Case, Config) when is_list(Config) -> + ?IGNORE(application:stop(inets)), + Config. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Infrastructure for test suite +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +error(Actual, Mod, Line) -> + (catch global:send(tftp_global_logger, {failed, Mod, Line})), + log("<ERROR> Bad result: ~p\n", [Actual], Mod, Line), + Label = lists:concat([Mod, "(", Line, ") unexpected result"]), + et:report_event(60, Mod, Mod, Label, + [{line, Mod, Line}, {error, Actual}]), + case global:whereis_name(tftp_test_case_sup) of + undefined -> + ignore; + Pid -> + Fail = #'REASON'{mod = Mod, line = Line, desc = Actual}, + Pid ! {fail, self(), Fail} + end, + Actual. + +log(Format, Args, Mod, Line) -> + case global:whereis_name(tftp_global_logger) of + undefined -> + io:format(user, "~p(~p): " ++ Format, + [Mod, Line] ++ Args); + Pid -> + io:format(Pid, "~p(~p): " ++ Format, + [Mod, Line] ++ Args) + end. + +default_config() -> + []. + +t() -> + t([{?MODULE, all}]). + +t(Cases) -> + t(Cases, default_config()). + +t(Cases, Config) -> + process_flag(trap_exit, true), + Res = lists:flatten(do_test(Cases, Config)), + io:format("Res: ~p\n", [Res]), + display_result(Res), + Res. + +do_test({Mod, Fun}, Config) when is_atom(Mod), is_atom(Fun) -> + case catch apply(Mod, Fun, [suite]) of + [] -> + io:format("Eval: ~p:", [{Mod, Fun}]), + Res = eval(Mod, Fun, Config), + {R, _, _} = Res, + io:format(" ~p\n", [R]), + Res; + + Cases when is_list(Cases) -> + io:format("Expand: ~p ...\n", [{Mod, Fun}]), + Map = fun(Case) when is_atom(Case)-> {Mod, Case}; + (Case) -> Case + end, + do_test(lists:map(Map, Cases), Config); + + {req, _, {conf, Init, Cases, Finish}} -> + case (catch apply(Mod, Init, [Config])) of + Conf when is_list(Conf) -> + io:format("Expand: ~p ...\n", [{Mod, Fun}]), + Map = fun(Case) when is_atom(Case)-> {Mod, Case}; + (Case) -> Case + end, + Res = do_test(lists:map(Map, Cases), Conf), + (catch apply(Mod, Finish, [Conf])), + Res; + + {'EXIT', {skipped, Reason}} -> + io:format(" => skipping: ~p\n", [Reason]), + [{skipped, {Mod, Fun}, Reason}]; + + Error -> + io:format(" => failed: ~p\n", [Error]), + [{failed, {Mod, Fun}, Error}] + end; + + {'EXIT', {undef, _}} -> + io:format("Undefined: ~p\n", [{Mod, Fun}]), + [{nyi, {Mod, Fun}, ok}]; + + Error -> + io:format("Ignoring: ~p: ~p\n", [{Mod, Fun}, Error]), + [{failed, {Mod, Fun}, Error}] + end; +do_test(Mod, Config) when is_atom(Mod) -> + Res = do_test({Mod, all}, Config), + Res; +do_test(Cases, Config) when is_list(Cases) -> + [do_test(Case, Config) || Case <- Cases]; +do_test(Bad, _Config) -> + [{badarg, Bad, ok}]. + +eval(Mod, Fun, Config) -> + TestCase = {?MODULE, Mod, Fun}, + Label = lists:concat(["TEST CASE: ", Fun]), + et:report_event(40, ?MODULE, Mod, Label ++ " started", + [TestCase, Config]), + global:register_name(tftp_test_case_sup, self()), + Flag = process_flag(trap_exit, true), + Config2 = Mod:init_per_testcase(Fun, Config), + Pid = spawn_link(?MODULE, do_eval, [self(), Mod, Fun, Config2]), + R = wait_for_evaluator(Pid, Mod, Fun, Config2, []), + Mod:fin_per_testcase(Fun, Config2), + global:unregister_name(tftp_test_case_sup), + process_flag(trap_exit, Flag), + R. + +wait_for_evaluator(Pid, Mod, Fun, Config, Errors) -> + TestCase = {?MODULE, Mod, Fun}, + Label = lists:concat(["TEST CASE: ", Fun]), + receive + {done, Pid, ok} when Errors == [] -> + et:report_event(40, Mod, ?MODULE, Label ++ " ok", + [TestCase, Config]), + {ok, {Mod, Fun}, Errors}; + {done, Pid, {ok, _}} when Errors == [] -> + et:report_event(40, Mod, ?MODULE, Label ++ " ok", + [TestCase, Config]), + {ok, {Mod, Fun}, Errors}; + {done, Pid, Fail} -> + et:report_event(20, Mod, ?MODULE, Label ++ " failed", + [TestCase, Config, {return, Fail}, Errors]), + {failed, {Mod,Fun}, Fail}; + {'EXIT', Pid, {skipped, Reason}} -> + et:report_event(20, Mod, ?MODULE, Label ++ " skipped", + [TestCase, Config, {skipped, Reason}]), + {skipped, {Mod, Fun}, Errors}; + {'EXIT', Pid, Reason} -> + et:report_event(20, Mod, ?MODULE, Label ++ " crashed", + [TestCase, Config, {'EXIT', Reason}]), + {crashed, {Mod, Fun}, [{'EXIT', Reason} | Errors]}; + {fail, Pid, Reason} -> + wait_for_evaluator(Pid, Mod, Fun, Config, Errors ++ [Reason]) + end. + +do_eval(ReplyTo, Mod, Fun, Config) -> + case (catch apply(Mod, Fun, [Config])) of + {'EXIT', {skipped, Reason}} -> + ReplyTo ! {'EXIT', self(), {skipped, Reason}}; + Other -> + ReplyTo ! {done, self(), Other} + end, + unlink(ReplyTo), + exit(shutdown). + +display_result([]) -> + io:format("OK\n", []); +display_result(Res) when is_list(Res) -> + Ok = [MF || {ok, MF, _} <- Res], + Nyi = [MF || {nyi, MF, _} <- Res], + Skipped = [{MF, Reason} || {skipped, MF, Reason} <- Res], + Failed = [{MF, Reason} || {failed, MF, Reason} <- Res], + Crashed = [{MF, Reason} || {crashed, MF, Reason} <- Res], + display_summary(Ok, Nyi, Skipped, Failed, Crashed), + display_skipped(Skipped), + display_failed(Failed), + display_crashed(Crashed). + +display_summary(Ok, Nyi, Skipped, Failed, Crashed) -> + io:format("\nTest case summary:\n", []), + display_summary(Ok, "successful"), + display_summary(Nyi, "not yet implemented"), + display_summary(Skipped, "skipped"), + display_summary(Failed, "failed"), + display_summary(Crashed, "crashed"), + io:format("\n", []). + +display_summary(Res, Info) -> + io:format(" ~w test cases ~s\n", [length(Res), Info]). + +display_skipped([]) -> + ok; +display_skipped(Skipped) -> + io:format("Skipped test cases:\n", []), + F = fun({MF, Reason}) -> io:format(" ~p => ~p\n", [MF, Reason]) end, + lists:foreach(F, Skipped), + io:format("\n", []). + + +display_failed([]) -> + ok; +display_failed(Failed) -> + io:format("Failed test cases:\n", []), + F = fun({MF, Reason}) -> io:format(" ~p => ~p\n", [MF, Reason]) end, + lists:foreach(F, Failed), + io:format("\n", []). + +display_crashed([]) -> + ok; +display_crashed(Crashed) -> + io:format("Crashed test cases:\n", []), + F = fun({MF, Reason}) -> io:format(" ~p => ~p\n", [MF, Reason]) end, + lists:foreach(F, Crashed), + io:format("\n", []). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% generic callback +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +-record(generic_state, {state, prepare, open, read, write, abort}). + +prepare(Peer, Access, LocalFilename, Mode, SuggestedOptions, Initial) when is_list(Initial) -> + State = lookup_option(state, mandatory, Initial), + Prepare = lookup_option(prepare, mandatory, Initial), + Open = lookup_option(open, mandatory, Initial), + Read = lookup_option(read, mandatory, Initial), + Write = lookup_option(write, mandatory, Initial), + Abort = lookup_option(abort, mandatory, Initial), + case Prepare(Peer, Access, LocalFilename, Mode, SuggestedOptions, State) of + {ok, AcceptedOptions, NewState} -> + {ok, + AcceptedOptions, + #generic_state{state = NewState, + prepare = Prepare, + open = Open, + read = Read, + write = Write, + abort = Abort}}; + Other -> + Other + end. + +open(Peer, Access, LocalFilename, Mode, SuggestedOptions, Initial) when is_list(Initial) -> + case prepare(Peer, Access, LocalFilename, Mode, SuggestedOptions, Initial) of + {ok, SuggestedOptions2, GenericState} -> + open(Peer, Access, LocalFilename, Mode, SuggestedOptions2, GenericState); + Other -> + Other + end; +open(Peer, Access, LocalFilename, Mode, SuggestedOptions, #generic_state{state = State, open = Open} = GenericState) -> + case Open(Peer, Access, LocalFilename, Mode, SuggestedOptions, State) of + {ok, SuggestedOptions2, NewState} -> + {ok, SuggestedOptions2, GenericState#generic_state{state = NewState}}; + Other -> + Other + end. + +read(#generic_state{state = State, read = Read} = GenericState) -> + case Read(State) of + {more, DataBlock, NewState} -> + {more, DataBlock, GenericState#generic_state{state = NewState}}; + Other -> + Other + end. + +write(DataBlock, #generic_state{state = State, write = Write} = GenericState) -> + case Write(DataBlock, State) of + {more, NewState} -> + {more, GenericState#generic_state{state = NewState}}; + Other -> + Other + end. + +abort(Code, Text, #generic_state{state = State, abort = Abort}) -> + Abort(Code, Text, State). + +lookup_option(Key, Default, Options) -> + case lists:keysearch(Key, 1, Options) of + {value, {_, Val}} -> + Val; + false -> + Default + end. + diff --git a/lib/inets/test/tftp_test_lib.hrl b/lib/inets/test/tftp_test_lib.hrl new file mode 100644 index 0000000000..da4b065976 --- /dev/null +++ b/lib/inets/test/tftp_test_lib.hrl @@ -0,0 +1,43 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2007-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +-record('REASON', {mod, line, desc}). + +-define(LOG(Format, Args), + tftp_test_lib:log(Format, Args, ?MODULE, ?LINE)). + +-define(ERROR(Reason), + tftp_test_lib:error(Reason, ?MODULE, ?LINE)). + +-define(VERIFY(Expected, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Expected -> ?LOG("Ok, ~p\n", [AcTuAlReS]); + _ -> ?ERROR(AcTuAlReS) + end, + AcTuAlReS + end()). + +-define(IGNORE(Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + ?LOG("Ok, ~p\n", [AcTuAlReS]), + AcTuAlReS + end()). diff --git a/lib/inets/vsn.mk b/lib/inets/vsn.mk index 8ed4f0c192..746517eed5 100644 --- a/lib/inets/vsn.mk +++ b/lib/inets/vsn.mk @@ -1,27 +1,42 @@ #-*-makefile-*- ; force emacs to enter makefile-mode # %CopyrightBegin% -# -# Copyright Ericsson AB 1997-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1997-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% -INETS_VSN = 5.2.0.1 -PRE_VSN = -APP_VSN = "inets-$(INETS_VSN)$(PRE_VSN)" +APPLICATION = inets +INETS_VSN = 5.3 +PRE_VSN =-p13 +APP_VSN = "$(APPLICATION)-$(INETS_VSN)$(PRE_VSN)" + +TICKETS = \ + OTP-8016 \ + OTP-8056 \ + OTP-8103 \ + OTP-8106 \ + OTP-8312 \ + OTP-8315 \ + OTP-8327 \ + OTP-8349 \ + OTP-8351 \ + OTP-8352 \ + OTP-8359 \ + OTP-8371 -TICKETS = OTP-8204 OTP-8206 OTP-8247 OTP-8248 OTP-8249 OTP-8258 OTP-8280 +TICKETS_5_2 = OTP-8204 OTP-8206 OTP-8247 OTP-8248 OTP-8249 OTP-8258 OTP-8280 TICKETS_5_1_3 = OTP-8154 diff --git a/lib/kernel/src/pg2.erl b/lib/kernel/src/pg2.erl index fc9508a194..cb9fec2ffe 100644 --- a/lib/kernel/src/pg2.erl +++ b/lib/kernel/src/pg2.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(pg2). @@ -334,8 +334,11 @@ local_group_members(Name) -> P <- member_in_group(Pid, Name)]. member_in_group(Pid, Name) -> - [{{member, Name, Pid}, N}] = ets:lookup(pg2_table, {member, Name, Pid}), - lists:duplicate(N, Pid). + case ets:lookup(pg2_table, {member, Name, Pid}) of + [] -> []; + [{{member, Name, Pid}, N}] -> + lists:duplicate(N, Pid) + end. member_groups(Pid) -> [Name || [Name] <- ets:match(pg2_table, {{pid, Pid, '$1'}})]. diff --git a/lib/orber/doc/src/Makefile b/lib/orber/doc/src/Makefile index 40f5ef8708..c82db49c9b 100644 --- a/lib/orber/doc/src/Makefile +++ b/lib/orber/doc/src/Makefile @@ -64,7 +64,6 @@ XML_REF3_FILES = \ orber_acl.xml XML_PART_FILES = \ - part_notes_history.xml \ part.xml \ part_notes.xml @@ -85,10 +84,6 @@ XML_CHAPTER_FILES = \ ch_orberweb.xml \ ch_debugging.xml -XML_HTML_FILES = \ - notes_history.xml - - BOOK_FILES = book.xml XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ @@ -124,7 +119,6 @@ INTERNAL_HTML_FILES = $(TECHNICAL_DESCR_FILES:%.xml=$(HTMLDIR)/%.html) HTML_FILES = $(XML_APPLICATION_FILES:%.xml=$(HTMLDIR)/%.html) \ $(XML_CHAPTER_FILES:%.xml=$(HTMLDIR)/%.html) \ - $(XML_HTML_FILES:%.xml=$(HTMLDIR)/%.html) \ $(XML_PART_FILES:%.xml=$(HTMLDIR)/%.html) INFO_FILE = ../../info diff --git a/lib/orber/doc/src/ch_contents.xml b/lib/orber/doc/src/ch_contents.xml index 65383805b3..602955764d 100644 --- a/lib/orber/doc/src/ch_contents.xml +++ b/lib/orber/doc/src/ch_contents.xml @@ -112,8 +112,8 @@ A concise history of Orber.</p> <title>IDL to Erlang Mapping</title> <p>The OMG IDL mapping for Erlang, which is necessary to access the functionality of Orber, is described, The mapping structure is - included as the\011basic and the constructed OMG IDL types - references, invocations\011and Erlang characteristics. An example is + included as the basic and the constructed OMG IDL types + references, invocations and Erlang characteristics. An example is also provided.</p> </section> diff --git a/lib/orber/doc/src/ch_example.xml b/lib/orber/doc/src/ch_example.xml index d4cc5ceddc..f2ccfcc7e1 100644 --- a/lib/orber/doc/src/ch_example.xml +++ b/lib/orber/doc/src/ch_example.xml @@ -45,7 +45,7 @@ <title>Generating Erlang Code</title> <p>Run the IDL compiler on this file by calling the <c>ic:gen/1</c> function </p> <code type="erl"> -\0111> ic:gen("stack"). + 1> ic:gen("stack"). </code> <p>This will produce the client stub and server skeleton. Among other files a stack API module named <c>StackModule_Stack.erl</c> will be produced. diff --git a/lib/orber/doc/src/ch_idl_to_erlang_mapping.xml b/lib/orber/doc/src/ch_idl_to_erlang_mapping.xml index 0e2b049ab9..a97ad65f0e 100644 --- a/lib/orber/doc/src/ch_idl_to_erlang_mapping.xml +++ b/lib/orber/doc/src/ch_idl_to_erlang_mapping.xml @@ -286,15 +286,15 @@ typedef string<10> myString10; typedef wstring<10> myWString10; ]]></code> <p>If we want to define a char/string or wchar/wstring constant, we can - use octal (\\OOO - one, two or three octal digits), - hexadecimal (\\xHH - one or two hexadecimal digits) and unicode (\\uHHHH - + use octal (\OOO - one, two or three octal digits), + hexadecimal (\xHH - one or two hexadecimal digits) and unicode (\uHHHH - one, two, three or four hexadecimal digits.) representation as well. For example:</p> <code type="none"> -const string SwedensBestSoccerTeam = "\\101" "\\x49" "\\u004B"; -const wstring SwedensBestHockeyTeam = L"\\101\\x49\\u004B"; -const char aChar = '\\u004B'; -const wchar aWchar = L'\\u004C'; +const string SwedensBestSoccerTeam = "\101" "\x49" "\u004B"; +const wstring SwedensBestHockeyTeam = L"\101\x49\u004B"; +const char aChar = '\u004B'; +const wchar aWchar = L'\u004C'; </code> <p>Naturally, we can use <c>"Erlang"</c>, <c>L"Rocks"</c>, <c>'A'</c> and <c>L'A'</c> as well.</p> @@ -697,14 +697,14 @@ module DB { module x { struct y_z { -\011... + ... }; interface y { -\011struct z { -\011 ... -\011}; + struct z { + ... + }; }; }; </code> @@ -815,7 +815,7 @@ module m { const float pi = 3.14; interface i { -\011const float pi = 3.1415; + const float pi = 3.1415; }; }; </code> @@ -1036,19 +1036,19 @@ $> erlc +"{be,erl_template}" DB.idl %% Description: %%---------------------------------------------------------------------- logon(State, ID, PW) -> -\011%% Check if the ID/PW is valid and what -\011%% type of user it is (Common or Administrator). -\011OE_Reply + %% Check if the ID/PW is valid and what + %% type of user it is (Common or Administrator). + OE_Reply = case check_user(ID, PW) of -\011 {ok, administrator} -> -\011 'DB_Administrator':oe_create(); -\011 {ok, common} -> -\011 'DB_CommonUser':oe_create(); -\011 error -> -\011 %% Here we should throw an exception - \011 corba:raise(....) + {ok, administrator} -> + 'DB_Administrator':oe_create(); + {ok, common} -> + 'DB_CommonUser':oe_create(); + error -> + %% Here we should throw an exception + corba:raise(....) end, -\011{reply, OE_Reply, State}. + {reply, OE_Reply, State}. %%====================================================================== %% Internal Functions @@ -1064,7 +1064,7 @@ logon(State, ID, PW) -> %% Description: Initiates the server %%---------------------------------------------------------------------- init(_Env) -> -\011{ok, #state{}}. + {ok, #state{}}. %%---------------------------------------------------------------------- @@ -1076,7 +1076,7 @@ init(_Env) -> %% Description: Invoked when the object is terminating. %%---------------------------------------------------------------------- terminate(_Reason, _State) -> -\011ok. + ok. %%---------------------------------------------------------------------- @@ -1090,7 +1090,7 @@ terminate(_Reason, _State) -> %% due to code replacement. %%---------------------------------------------------------------------- code_change(_OldVsn, State, _Extra) -> -\011{ok, State}. + {ok, State}. %%---------------------------------------------------------------------- @@ -1104,7 +1104,7 @@ code_change(_OldVsn, State, _Extra) -> %% Description: Invoked when, for example, the server traps exits. %%---------------------------------------------------------------------- handle_info(_Info, State) -> -\011{noreply, State}. + {noreply, State}. ]]></code> <p>Since <c>DB_Administrator</c> inherits from <c>DB_CommonUser</c>, we must implement <c>delete</c> in the <c>DB_Administrator_impl.erl</c> @@ -1421,11 +1421,11 @@ interface i { </row> <row> <cell align="left" valign="middle">{tk_objref, IFRId, Name}</cell> - <cell align="left" valign="middle">{tk_objref, "IDL:M1\\I1:1.0", "I1"}</cell> + <cell align="left" valign="middle">{tk_objref, "IDL:M1\I1:1.0", "I1"}</cell> </row> <row> <cell align="left" valign="middle">{tk_struct, IFRId, Name, [{ElemName, ElemTC}]}</cell> - <cell align="left" valign="middle">{tk_struct, "IDL:M1\\S1:1.0", "S1", [{"a", tk_long}, {"b", tk_char}]}</cell> + <cell align="left" valign="middle">{tk_struct, "IDL:M1\S1:1.0", "S1", [{"a", tk_long}, {"b", tk_char}]}</cell> </row> <row> <cell align="left" valign="middle">{tk_union, IFRId, Name, DiscrTC, DefaultNr, [{Label, ElemName, ElemTC}]} <br></br> diff --git a/lib/orber/doc/src/ch_install.xml b/lib/orber/doc/src/ch_install.xml index eee2b99c92..ab5885954b 100644 --- a/lib/orber/doc/src/ch_install.xml +++ b/lib/orber/doc/src/ch_install.xml @@ -483,7 +483,7 @@ nodeB@hostB> orber:start(). <item>Since Orber domains, they are supposed to communicate via IIOP, <em>MUST</em> have unique names, communication will fail if two domains have the same name. The domain name <em>MAY NOT</em> - contain <c>^G</c> (i.e. <c>\\007</c>).</item> + contain <c>^G</c> (i.e. <c>\007</c>).</item> <tag><em>iiop_port</em></tag> <item>If set to 0 the OS will pick any vacant port. <br></br> @@ -595,7 +595,7 @@ nodeB@hostB> orber:start(). the <c>interceptors</c> parameter.</item> <tag><em>orbInitRef</em></tag> <item>Setting this option, e.g., - <c>erl -orber orbInitRef [\\"NameService=corbaloc::host.com/NameService\\"]</c>, + <c>erl -orber orbInitRef [\"NameService=corbaloc::host.com/NameService\"]</c>, will alter the location from where <c>corba:resolve_initial_references(Key)</c> tries to find an object matching the given Key. The keys will also appear when invoking <c>corba:list_initial_services()</c>. This variable overrides @@ -605,7 +605,7 @@ nodeB@hostB> orber:start(). found, and this variable is set, it determines the location from where <c>orber:resolve_initial_references(Key)</c> tries to find an object matching the given Key. Usage: - <c>erl -orber orbDefaultInitRef \\"corbaloc::host.com\\"</c>.</item> + <c>erl -orber orbDefaultInitRef \"corbaloc::host.com\"</c>.</item> <tag><em>orber_debug_level</em></tag> <item>The range is 0 to 10. Using level 10 is the most verbose configuration. diff --git a/lib/orber/doc/src/ch_interceptors.xml b/lib/orber/doc/src/ch_interceptors.xml index 27b254c4bf..af8c5a45f1 100644 --- a/lib/orber/doc/src/ch_interceptors.xml +++ b/lib/orber/doc/src/ch_interceptors.xml @@ -188,17 +188,17 @@ out_reply_encoded({ObjTable, ChecksumModule}, ObjKey, Ctx, Op, Bin, Extra) -> %% Interceptor functions. -export([new_out_connection/3, -\011 new_in_connection/3, -\011 closed_in_connection/1, -\011 closed_out_connection/1, -\011 in_request_encoded/6, -\011 in_reply_encoded/6, -\011 out_reply_encoded/6, -\011 out_request_encoded/6, -\011 in_request/6, -\011 in_reply/6, -\011 out_reply/6, -\011 out_request/6]). + new_in_connection/3, + closed_in_connection/1, + closed_out_connection/1, + in_request_encoded/6, + in_reply_encoded/6, + out_reply_encoded/6, + out_request_encoded/6, + in_request/6, + in_reply/6, + out_reply/6, + out_request/6]). new_in_connection(Arg, Host, Port) -> %% Since we only use one interceptor we do not care about the diff --git a/lib/orber/doc/src/ch_naming_service.xml b/lib/orber/doc/src/ch_naming_service.xml index 510ccf2543..5cc50d95ec 100644 --- a/lib/orber/doc/src/ch_naming_service.xml +++ b/lib/orber/doc/src/ch_naming_service.xml @@ -116,7 +116,7 @@ Figure 1: Contextual object relationships using the Naming Service.</icaption> <p>In order to use the naming service you have to fetch an initial reference to it. This is done with:</p> <code type="none"> -\011NS = corba:resolve_initial_references("NameService"). +NS = corba:resolve_initial_references("NameService"). </code> <note> <p>NS in the other use-cases refers to this initial reference.</p> @@ -208,17 +208,17 @@ Sc = corba:string_to_object("corbaname:rir:/NameService#workgroup/services/"). {BList, BIterator} = 'CosNaming_NamingContext':list(Sc, 10). lists:foreach(fun({{Id, Kind},BindingType}) -> case BindingType of -\011nobject -> -\011\011io:format("id: %s, kind: %s, type: object~n", [Id, Kind]); -\011 _ -> -\011\011io:format("id: %s, kind: %s, type: ncontext~n", [Id, Kind]) -\011end end, -\011Blist). + nobject -> + io:format("id: %s, kind: %s, type: object~n", [Id, Kind]); + _ -> + io:format("id: %s, kind: %s, type: ncontext~n", [Id, Kind]) + end end, + Blist). </code> </item> </list> <note> - <p>Normally a <term id="BindingIterator"><termdef>The binding iterator (Like a book mark) indicates which objects have been read from the list.</termdef></term>is helpful in situations where you have a large\011number of objects + <p>Normally a <term id="BindingIterator"><termdef>The binding iterator (Like a book mark) indicates which objects have been read from the list.</termdef></term>is helpful in situations where you have a large number of objects in a list, as the programmer then can traverse it more easily. In Erlang it is not needed, because lists are easily handled in the language itself.</p> @@ -427,7 +427,7 @@ lists:foreach(fun({{Id, Kind},BindingType}) -> case BindingType of <cell align="left" valign="middle">An Id with a trailing '.' is not allowed.</cell> </row> <row> - <cell align="left" valign="middle">"i\\\\/d1/i\\\\.d2"</cell> + <cell align="left" valign="middle">"i\\/d1/i\\.d2"</cell> <cell align="left" valign="middle">[{"i/d1",""},{"i.d2",""}]</cell> <cell align="left" valign="middle">Since '.' and '/' are used to separate the components, these tokens must be escaped to be correctly converted.</cell> </row> diff --git a/lib/orber/doc/src/corba.xml b/lib/orber/doc/src/corba.xml index 6c89279733..cae0e09b0b 100644 --- a/lib/orber/doc/src/corba.xml +++ b/lib/orber/doc/src/corba.xml @@ -99,9 +99,8 @@ <em>MAY ONLY</em> be used during testing and development.</p> <code type="none"> Example: -\011 - corba:create('StackModule_Stack', "IDL:StackModule/Stack:1.0", -\011 {10, test}) + + corba:create('StackModule_Stack', "IDL:StackModule/Stack:1.0", {10, test}) </code> </desc> </func> diff --git a/lib/orber/doc/src/notes.xml b/lib/orber/doc/src/notes.xml index 08bbf4b29c..816ec77d61 100644 --- a/lib/orber/doc/src/notes.xml +++ b/lib/orber/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Orber Release Notes</title> @@ -33,6 +33,36 @@ </header> <section> + <title>Orber 3.6.15</title> + + <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Removed obsolete SSL dependency.</p> + <p> + Own Id: OTP-8374 Aux Id:</p> + </item> + </list> + </section> + + <section> + <title>Fixed Bugs and Malfunctions</title> + <list type="bulleted"> + <item> + <p>Removed superfluous VT in the documentation.</p> + <p>Own id: OTP-8353 Aux Id:</p> + </item> + <item> + <p>Removed superfluous backslash in the documentation.</p> + <p>Own id: OTP-8354 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>Orber 3.6.14</title> <section> @@ -403,8 +433,6 @@ </item> </list> </section> - <!-- p>For information about older versions see - <url href="part_notes_history_frame.html">release notes history</url>.</p --> </section> </chapter> diff --git a/lib/orber/doc/src/notes_history.xml b/lib/orber/doc/src/notes_history.xml deleted file mode 100644 index b493f0e379..0000000000 --- a/lib/orber/doc/src/notes_history.xml +++ /dev/null @@ -1,1523 +0,0 @@ -<?xml version="1.0" encoding="latin1" ?> -<!DOCTYPE chapter SYSTEM "chapter.dtd"> - -<chapter> - <header> - <copyright> - <year>2004</year><year>2009</year> - <holder>Ericsson AB. All Rights Reserved.</holder> - </copyright> - <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - </legalnotice> - - <title>Orber Release Notes History</title> - <prepared></prepared> - <responsible></responsible> - <docno></docno> - <approved></approved> - <checked></checked> - <date>99-02-12</date> - <rev>A</rev> - </header> - - <section> - <title>Orber 3.5.4</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>In some cases, it was possible for a user to delete the - NameService root context.</p> - <p>Own Id: OTP-5202</p> - </item> - <item> - <p>Invoking two, or more, concurrent oe_register operations - it could corrupt the IFR. If this is the case, the - INTF_REPOS system exception is raised. The risk for this - to occur is rather slim.</p> - <p>Own Id: OTP-5526</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.5.3</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>To avoid malicious attacks, it is now possible to configure - Orber to only accept incoming requests up to a certain size. - To be able to use this option, it must be supported by inet - and SSL.</p> - <p>Own id: OTP-5129</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.5.2</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>If a client tried to connect to Orber and immediately - closed the connection, then the process accepting new - connections could end up with a message in the queue - that would never be removed.</p> - <p>Own id: OTP-5105</p> - </item> - <item> - <p>The INS corbaloc/corbaname URL:s did only accept DNS style host - names. Now it is also possible to use, none compressed, IPv6 - addresses.</p> - <p>Own id: OTP-5108</p> - </item> - <item> - <p>When Orber was configured to use IPv6 for inter-ORB communication, - exported IOR:s did not contain a correct IPv6 address. This did not - cause any problems if Orber was configured to use DNS style hostname - instead.</p> - <p>Own id: OTP-5109</p> - </item> - <item> - <p>Orber used external operations not exported in R9B.</p> - <p>Own id: OTP-5111</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.5.1</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When using Light IFR it was not possible unregister data - (i.e., invoking 'MyModule':oe_unregister()). - Introduced in Orber-3.5.0.1.</p> - <p>Own id: OTP-5034</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.5.0.1</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>orber_ifr:contents/3 always returned an empty list when using - Light IFR. Little or no effect.</p> - <p>Own id: OTP-5018</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.5</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>It is now possible to configure Orber to use NAT (Network Address - Translation) friendly parameters. A new section in the User's Guide - describes how to handle communication via firewalls.</p> - <p>Own id: OTP-4698</p> - </item> - <item> - <p>A new module called <c>orber_diagnostics</c> have been added, which - is intended to aid a user during the test and development phase. - For more information, see the reference manual.</p> - <p>Own id: OTP-4699</p> - </item> - <item> - <p><c>IPv6</c> supported.</p> - <p>Own id: OTP-4937</p> - </item> - <item> - <p>Possible to configure Orber so that exported IOR:s contain - multiple IIOP components for different interfaces.</p> - <p>Own id: OTP-4938</p> - </item> - <item> - <p>Improved typechecking of typecode supplied to the operations - <c>orber_tc:check_tc/1</c>, <c>any:create/2</c> and - <c>any:set_typecode/2</c>.</p> - <p>Own id: OTP-4939</p> - </item> - <item> - <p>Server objects can now be started as EXIT tolerant.</p> - <p>Own id: OTP-4940</p> - </item> - <item> - <p>Possible to use interceptors for local invocations as well.</p> - <p>Own id: OTP-4941</p> - </item> - <item> - <p>If the IFR is not explicitly used, Orber can be configured - to use a minimal IFR to reduce memory usage and installation - time.</p> - <p>Own id: OTP-5001</p> - </item> - <item> - <p>To avoid malicious attacks it is now possible to configure - Orber to limit the number of concurrent connections and - requests and the amount of IIOP fragments.</p> - <p>Own id: OTP-5002</p> - </item> - <item> - <p>The operation <c>orber:iiop_connections/0</c> now also include - incoming connections.</p> - <p>Own id: OTP-5004</p> - </item> - <item> - <p>The function <c>orber:add_node/2</c> now accepts more options.</p> - <p>Own id: OTP-5006</p> - </item> - <item> - <p>The module <c>orber_diagnostics</c> now exports a function - which list missing modules generated by IC and required by - Orber.</p> - <p>Own id: OTP-5007</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Orber's NameService did not return a NIL object reference if the total - number of existing bindings was less than, or equal to, - the <c>HowMany</c> parameter passed to - <c>'CosNaming_NamingContext':list/2</c> operation. This have now been - changed to be compliant with the OMG standard. Furthermore, the operation - <c>'CosNaming_BindingIterator':next_n/2</c> did not handle the index - correctly in all situations.</p> - <p>Own id: OTP-4700</p> - </item> - <item> - <p>If the Orber internal gen_server orber_iiop_pm was stopped - in such a way that the terminate function was not invoked, - then ghost processes would appear.</p> - <p>Own id: OTP-5003</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>The work-around introduced in version 3.4.1 (OTP-4608) has - now been removed. Make sure you are using IC-4.2 or later.</p> - </item> - <item> - <p>Since the OMG has defined a default port number (2809), - Orber no longer support the bootstrap port.</p> - <p>Own id: OTP-5005</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.4.2.2</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Due to IFR DB lock mechanisms, concurrent creation - of non-anonymous IFR types could still result in duplicated - entries.</p> - <p>Own id: OTP-4781</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.4.2.1</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>The operation <c>orber:start()</c> could return before - all Mnesia tables were accessible.</p> - <p>Own id: OTP-4780</p> - </item> - <item> - <p>Concurrent creation of non-anonymous IFR types - could result in duplicates in the DB.</p> - <p>Own id: OTP-4781</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.4.2</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Improved type tests for string, wide string and sequence when - passed via IIOP.</p> - <p>Own id: OTP-4759</p> - </item> - <item> - <p>Less (internal) processes are needed when Orber act as client-side ORB - and communicate with another ORB. Due to this change, closed connections - and socket errors are dealt with in a more gentle way. If the latter - occurs, the error_logger application is used to generate an error - report containing a description of what went wrong.</p> - <p>Own id: OTP-4655</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When communicating with another ORB, via SSL, and a socket error occurred, - Orber did not recognize the error message. This occurred when Orber - acted as client-side ORB.</p> - <p>Own id: OTP-4656</p> - </item> - <item> - <p>If an out-going connection was closed and the receiving process had not - been scheduled yet, the close connection message was delivered before - the correct message.</p> - <p>Own id: OTP-4657</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>Since strstream is deprecated and not accepted by gcc-3.3, - Orber no longer includes the InitalReference lib. The source - code is still included.</p> - <p>Own id: OTP-4767</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.4.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>It is now possible to use IC-versions older than 4.2. But, this is - only temporary so it is still necessary upgrade to a correct - version.</p> - <p>Own id: OTP-4608</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.4</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>If a call-back module illegally caused an EXIT, clients - residing on another ORB was not notified (hanged).</p> - <p>Own id: OTP-4577</p> - </item> - <item> - <p>The stub/skeleton-files generated by IC have been improved, - i.e., depending on the IDL-files, reduced the size of the - erl- and beam-files and decreased dependencies off Orber's - Interface Repository. It is necessary to re-compile all IDL-files - and use COS-applications, including Orber, compiled with - IC-4.2.</p> - <p>Own id: OTP-4576</p> - </item> - <item> - <p>It is now possible to configure Orber to use the host name - in exported IOR:s instead of the IP-number.</p> - <p>Own id: OTP-4541</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When Orber acted as server-side ORB and one tried to setup a - SSL-connection and using native Interceptors at the same time - it failed.</p> - <p>Own Id: OTP-4542</p> - </item> - <item> - <p>Oneway operations, using a multi-node Orber, failed for inter-node - communication.</p> - <p>Own Id: OTP-4543</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.3</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Orber now supports fragmented IIOP messages for 1.2.</p> - <p>Own Id: OTP-4462</p> - </item> - <item> - <p>Orber now has its own set of unique VMCID:s which - is used for minor codes in system exceptions. All system exceptions raised - by Orber now uses this VMCID base or OMG:s VMCID base. See also the function - <c>orber:exception_info/1</c>.</p> - <p>Own Id: OTP-4463</p> - </item> - <item> - <p>Since some ORB:s, non-compliant with the OMG specification, - have problems using IOR:s which embeds a CodeSet component, it is now - possible to configure Orber to exclude it from exported IOR:s.</p> - <p>Own Id: OTP-4469</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When combining interceptors and oneway operations, Orber - incorrectly sent a MessageError over the connection to the - client ORB.</p> - <p>Own Id: OTP-4460</p> - </item> - <item> - <p>After (2^32)-1 requests, Orber used the request number 0 twice - in a row.</p> - <p>Own Id: OTP-4461</p> - </item> - <item> - <p>The COMM_FAILURE exception should only be raised when connection - problems occur. Now Orber raises the correct exceptions. Note, when - Orber act as client side ORB you must be able to handle any of the system - exceptions defined by the OMG. Some of the COMM_FAILURE exceptions - have been replaced with the correct TRANSIENT and TIMEOUT exceptions.</p> - <p>Own Id: OTP-4465</p> - </item> - <item> - <p>The default port used for corbaloc and corbaname was - incorrect. Now changed to follow the OMG standard (2809).</p> - <p>Own Id: OTP-4466</p> - </item> - <item> - <p>When Orber acted as a client-side ORB, it failed to encode - unions with a default case (i.e. defined in the IDL-code and a - default label used).</p> - <p>Own Id: OTP-4472</p> - </item> - <item> - <p>The operation corba:print_object/1/2 did not include host/port - data for IIOP-1.0 IOR:s.</p> - <p>Own Id: OTP-4483</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>Some of the COMM_FAILURE exceptions have been replaced with the correct - TRANSIENT and TIMEOUT exceptions. All minor codes used by Orber - is now based on the OMG assigned VMCIDs.</p> - <p>Own Id: OTP-4465, OTP-4463</p> - </item> - <item> - <p>The default port used for corbaloc and corbaname have been changed - to 2809.</p> - <p>Own Id: OTP-4466</p> - </item> - <item> - <p>To reduce extra overhead Orber now uses a flag parameter, - which makes it possible to configure Orber's behavior in different ways. - Hence, the global activation of Local Typechecking, introduced in the previous - version, have now been changed.</p> - <p>Own Id: OTP-4467</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.13</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>It is now possible to activate automatic typechecking when - invoking operations on CORBA Objects locally. For more - information, see the configuration and debugging chapters - in the User's Guide regarding the <c>local_typecheck</c> - option.</p> - <p>Own Id: OTP-4410</p> - </item> - <item> - <p>Due to the success of the pre-compiled IIOP-trace interceptor, a less - verbose trace interceptor, called <c>orber_iiop_tracer_silent</c>, - have been added as well.</p> - <p>Own Id: OTP-4257</p> - </item> - <item> - <p>Orber now support the Fixed datatype defined by the OMG. To be able - to define Fixed types in an IDL-specification, check that your current - IC version supports this type as well. If not, the only option is - to encapsulate it in an <c>any</c> type.</p> - <p>Own id: OTP-4375</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>It was not possible to use the function <c>corba:print_object/2</c>, - which was introduced in the previous release, only - <c>corba:print_object/1</c>. Now it is also possible to use - the <c>error_logger</c> or receive the data in string form.</p> - <p>Own Id: OTP-4376</p> - </item> - <item> - <p>The functions <c>orber_tc:principal</c> and <c>orber_tc:exception</c> - returned incorrect.</p> - <p>Own Id: -</p> - </item> - <item> - <p>The function <c>orber_ifr:get_primitive</c> tried to access a - non-existing (primitivdefs) table.</p> - <p>Own Id: -</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.12</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Orber now check if an external IOR contains any - TAG_ALTERNATE_IIOP_ADDRESS components when trying to setup - a connection to another ORB.</p> - <p>Own id: OTP-4294</p> - </item> - <item> - <p>It is now possible to add TAG_ALTERNATE_IIOP_ADDRESS components - to a local object reference. See corba:add_alternate_iiop_address/3.</p> - <p>Own id: OTP-4294</p> - </item> - <item> - <p>Orber now allows unions with no default value defined and a - discriminator out of range to be sent via IIOP. The value-field - is set to the atom undefined.</p> - <p>Own id: OTP-4295</p> - </item> - <item> - <p>The corba module now exports a function, print_object/1/2, which - prints IOR's in a more readable form.</p> - <p>Own id: OTP-4296</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Since "all" ORB's accept ISO-8859-1 encoding of chars and strings, - Orber assumed that it could be used at all time to reduce the overhead. - The JDK-1.3 only accepts ISO 646:1991 IRV (US-ASCII), even though - ISO-8859-1 is default, which is why Orber now checks which codeset - is accepted.</p> - <p>Own Id: OTP-4298</p> - </item> - <item> - <p>When invoking a Locate Request, Orber in some cases did not reply - with a Locate Reply header (used a Reply header).</p> - <p>Own Id: OTP-4293</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.11</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>If the underlying OS was not configured to allow Erlang to use the - fully qualified host name the result could an incorrect IP-address. - Hence, if you want to upgrade to Orber-3.2.11 and the fully - qualified name must be used you must upgrade your kernel version. - Most likely, this change will NOT cause any problems, but if in doubt - please contact support or use the mailing-list. - See also the release notes for Orber-3.2.6.</p> - <p>Own id: OTP-3966</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When looking up Initial Service (e.g. using <c>corbaloc</c>, - <c>corbaname</c> or <c>corba:resolve_initial_references_remote/2</c>) - and communicating via SSL, Orber used the wrong port number.</p> - <p>Own Id: OTP-4264</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.10</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>It is now possible to add new initial references, which can, - for example, be accessed via <c>corba:resolve_initial_references/1</c> - or the <c>corbaloc</c> schema.</p> - <p>Own Id: OTP-4258</p> - </item> - <item> - <p>The orber module now exports functions, <c>iiop_connections</c> - and <c>iiop_connections_pending</c>, which, respectively, list - all currently open connections to other ORB's and connections - which are in process of being set up to another ORB.</p> - <p>Own Id: OTP-4262</p> - </item> - <item> - <p>Orber now allows the user to define an interval of ports - which Orber is may use (i.e. ports on the local machine) - when trying to connect to another ORB. This behavior is useful - if Orber resides behind a firewall which only allow applications - to use certain ports when communicating with the outside world. - If this option is set, it is absolutely necessary to - set <c>iiop_connection_timeout</c>. If not, there is risk that - Orber run out of ports, which will result in communication failure. - This option cannot be used when using SSL since it does not support - this feature. The default behavior is that any available port - will be used (as before).</p> - <p>Own Id: OTP-4260</p> - </item> - <item> - <p>One can now install Orber's NameService as disc_copies, but - the default behavior is that Orber uses ram_copies.</p> - <p>Own Id: OTP-4259</p> - </item> - <item> - <p>A pre-compiled IIOP-trace interceptor is now - included in the Orber release. For more information, - see the <c>Debugging</c> chapter in the User's Guide.</p> - <p>Own Id: OTP-4257</p> - </item> - <item> - <p>It is now possible to set Orber's configuration parameters - in, for example, an Erlang shell. Consult <c>corba:orb_init/1</c> and - <c>orber:configure/2</c>.</p> - <p>Own Id: OTP-4261</p> - </item> - <item> - <p>The Orber release now include <c>OrberWeb</c>, which is an extension of - the <c>WebTool</c> application (first released in R8B). Hence, - <c>WebTool</c> must be installed to enable this feature. For more - information, see the chapter <c>OrberWeb</c> in the User's Guide. - <c>OrberWeb</c> is intended to be used during test and development.</p> - <p>Own Id: OTP-4257</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When setting up two Orber ORB's, where one of the ORB's domain - name was a prefix of the other ORB's, communication via IIOP would fail. - To eliminate any further configuration problems, one may not - use <c>^G</c> (i.e. <c>"\\007"</c>) in the domain name. Due to this - change it is not possible to upgrade during run-time.</p> - <p>Own Id: OTP-4229</p> - </item> - <item> - <p>When using a mix of IIOP-versions (1.0 vs 1.1/1.2) and - sending/receiving IOR's to/from Orber could result in a - MARSHAL exception.</p> - <p>Own Id: OTP-4230</p> - </item> - <item> - <p>Encoding/decoding of wchar/wstring when using IIOP-1.2 do now - follow the OMG standard. If your ORB do not follow the - standard, contact support for information how to make a work-around - to solve this problem. In most cases it is sufficient to - configure the ORB's to communicate via IIOP-1.1.</p> - <p>Own Id: OTP-4263</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>The encoding/decoding of wchar/wstring when using IIOP-1.2 - have been updated. See above.</p> - <p>Own Id: OTP-4263</p> - </item> - <item> - <p>Orber no longer returns a 'EXIT' message when trying - to install Orber, i.e., invoking orber:install/1/2, - on a disc-less node. But if if the installation fails due - to any other reason, Orber still return a 'EXIT' message.</p> - <p>Own Id: OTP-4256</p> - </item> - </list> - </section> - - <section> - <title>Known bugs and problems</title> - <list type="bulleted"> - <item> - <p><c>OrberWeb</c> only tested with <c>Netscape-4.75</c>. Furthermore, - until <c>WebTool</c> reaches version 1.0 OrberWeb should also - be considered to be a beta version.</p> - <p>Own Id: OTP-4257</p> - </item> - <item> - <p><c>OrberWeb</c> do not escape arguments passed when, for example, - creating a new context. Hence, for now you are recommended to - only use letters.</p> - <p>Own Id: OTP-4257</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.9</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>External IOR:s containing unsupported or incorrectly placed - TaggedComponents was corrupted when Orber forwarded the - IOR via IIOP. This bug was introduced in 3.2.6.</p> - <p>Own Id: OTP-4170</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.8</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Orber now support interceptors.</p> - <p>Own Id: -</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.7</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>When Orber acted as server-side and communicating via IIOP the overhead - was unreasonably large and memory consuming (depended on the - IDL-specification). This have now been fixed and will, especially, - improve the performance when invoking operations with no, or simple, - arguments on a complex interface. This change will have little effect - on objects started as pseudo since this problem did not affect them.</p> - <p>Own Id: OTP-4063</p> - </item> - <item> - <p>When Orber tried to set up a connection to another ORB which did not - respond all IIOP access where blocked until the TCP protocol - generated a timeout. Now only requests to that particular ORB are - queued.</p> - <p>Own Id: OTP-4060</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>It was not possible to invoke the operation - CosNaming_BindingIterator:next_one via IIOP if no more bindings - existed.</p> - <p>Own id: OTP-4004</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.6</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Registering data in the IFR overhead reduced.</p> - <p>Own id: OTP-3904</p> - </item> - <item> - <p>The overhead for the function <c>is_a/1</c> have been reduced, which also - affects remote <c>narrow</c> operations for inherited interfaces - (e.g. using Java or C++ ORBs).</p> - <p>Own id: OTP-3904</p> - </item> - <item> - <p>If the underlying OS was not configured to allow Erlang to - lookup the host-name by using the short-name the result was - always the IP-address 127.0.0.1 (loop-back). Now Orber uses - the full name. Hence, make sure the <c>net_adm:localhost/0</c> and - <c>inet:getaddr/2</c> return proper values.</p> - <p>Own id: OTP-3966</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>The CONV_FRAME_CodeSetComponentInfo struct was not placed - correctly in IOR:s. Each profile must be self-sustained - which is why this information must be duplicated in each - profile. Currently this only applies for the IIOP-profile - but will also concern future protocols.</p> - <p>Own id: OTP-3992</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.5</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Orber now defines the configuration variable, - <c>iiop_setup_connection_timeout</c>, which makes it possible to - timeout connection attempts to another ORB before the OS TCP timeout - is activated.</p> - <p>Own id: OTP-3961</p> - </item> - <item> - <p>It is now possible to configure Orber to generate reports when abnormal - situations occurs. For more information consult the User's Guide - regarding the configuration parameter <c>orber_debug_level</c>. - Note, it is not recommended to use this option for delivered systems - since some of the reports is not to be considered as errors.</p> - <p>Own id: OTP-3962</p> - </item> - <item> - <p>Orber now accepts a list of addresses as value for the configuration - parameter <c>orbInitRef</c>.</p> - <p>Own id: OTP-3945</p> - </item> - <item> - <p>Orber now includes services defined by the configuration parameter - <c>orbInitRef</c> when invoking <c>corba:list_initial_services/0</c>.</p> - <p>Own id: OTP-3946</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When using the configuration variable 'orbDefaultInitRef' with - a value pointing to another Orber-ORB it was not possible to - install Orber since Orber used to create default <c>NamingContexts</c>. - Orber no longer add these contexts.</p> - <p>Own id: OTP-3943</p> - </item> - <item> - <p>Orber accessed <c>corbaloc</c> addresses in reverse order. Now fixed.</p> - <p>Own id: OTP-3944</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>When installing Orber no default <c>NamingContext's</c>, i.e., - <c>host</c>, <c>hosts</c>, <c>resources</c>, <c>development</c>, - <c>factories</c> and <c>workgroup</c>, will be added. These contexts - was defined in a cancelled specification.</p> - <p>Own id: OTP-3942</p> - </item> - <item> - <p><c>corbaloc</c> addresses are now accessed in FIFO order (instead of - LIFO).</p> - <p>Own id: OTP-3944</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.4</title> - - <section> - <title>Improvements and New Features</title> - <p>-</p> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When communicating via IIOP using version 1.2 Orber used incorrect - offset for reply bodies containing system exceptions, exceptions and - location forward.</p> - <p>Own id: OTP-3912</p> - </item> - <item> - <p>Orber did not return correct IFR Id:s when raising system exceptions - via IIOP.</p> - <p>Own id: OTP-3911</p> - </item> - <item> - <p>If two different processes concurrently manipulated a - <c>CosNaming::NamingContext</c> the data could become corrupted. - For single-node Orber this error occurred in version 3.2.1, 3.2.2 and - 3.2.3. For multi-node Orber this behavior have been present at all time.</p> - <p>Own id: OTP-3910</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>Since Orber now returns a different, and correct, IFR-id for - systems exceptions other ORB:s and older versions of Orber - might raise a different exception, probably MARSHAL or UNKNOWN. - This only occurs when communicating via IIOP. It is not possible to - upgrade during runtime. Use <c>orber:stop()</c>, load new version and - restart Orber by invoking <c>orber:start()</c>.</p> - <p>Own id: OTP-3911</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.3</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Improved performance for all types, simple and complex, when - communicating via IIOP. It is not possible to upgrade during - runtime. Use <c>orber:stop()</c>, load new version and restart - Orber by invoking <c>orber:start()</c>.</p> - <p>Own id: OTP-3905</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>If a pseudo object raises an exception or exits the exception - was only returned, not thrown.</p> - <p>Own id: OTP-3907</p> - </item> - <item> - <p>Orber defined an incorrect ID for CodeSets. This may cause - INV_OBJREF or DATA_CONVERSION exceptions to be thrown, it - depends on the other ORB.</p> - <p>Own id: OTP-3899</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.2</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>The behavior of Orber when receiving unsupported or incorrect - messages have now been improved.</p> - <p>Own id: OTP-3903</p> - </item> - <item> - <p>Time consumed by <c>oe_MyModule:oe_register()</c> decreased.</p> - <p>Own id: OTP-3904</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When Orber received a 'location_forward' reply, the result - from the second invocation was never delivered to the - client. Now fixed.</p> - <p>Own id: OTP-3814</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>It is now possible to use external <c>NamingContexts</c> - when, for example, using - <c>'CosNaming_NamingContextExt':bind_context/3</c>.</p> - <p>Own id: OTP-3902</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.2</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Orber now supports IIOP-version 1.2.</p> - <p>Own id: OTP-3901</p> - </item> - <item> - <p>Improved encoding and decoding performance for IIOP requests containing - <c>struct</c>, <c>union</c> or user defined <c>exceptions</c>.</p> - <p>Own id: OTP-3900</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Setting the <c>bootstrap_port</c> configuration parameter to a value - less than 1024 made it impossible to start Orber properly. - Now fixed.</p> - <p>Own id: OTP-3898</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.1.8</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Orber now accepts <c>Indirection/Repeated</c><c>CORBA::TypeCode</c> as input and/or - return value when communicating via IIOP.</p> - <p>Own id: -</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When another ORB replied with <c>location forward</c> Orber - failed to decode this. Now fixed.</p> - <p>Own id: OTP-3709</p> - </item> - <item> - <p>Orber failed to encode <c>CORBA::TypeCode</c> containing <c>tk_alias</c>, e.g., - sending an <c>#any{}</c> which encapsulates data defined by <c>typedef</c>.</p> - <p>Own id: OTP-3689</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.1.7</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Earlier, Orber did not use the IIOP/GIOP version specified - in an external object key when invoking an intra-ORB request.</p> - <p>Own id: OTP-3663</p> - </item> - <item> - <p>The OMG standard now support an Interoperable Naming Service. - Initially there where two proposals of which Orber earlier - supported one of them. Now both standards are supported.</p> - <p>Own id: OTP-3664</p> - </item> - <item> - <p>The OMG have redefined the operator, used when encoding requests via IIOP, - for the function <c>corba_object:non_existent/1</c>. CORBA version 2.0 and - 2.2 compliant ORB:s is supposed to support the old definition, while - later versions, i.e., 2.3, is supposed to use the new operator - (<c>_non_existent</c> instead of <c>_not_existent</c>). Orber accepts - both versions.</p> - <p>Own id: OTP-3679</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>If an Orber node crashed and was restarted the object keys could - point to other processes than it should, which may cause problems if, - for example, the other process terminates due to it does not handle - unknown messages. Now Orber GC object keys for objects residing on the - crashed node. If Orber is started as a multi-node ORB of which one or - more nodes runs an older Orber version they can still communicate but - with an increased overhead. Hence, all nodes should be upgraded during - a relatively short time. If Orber is stopped, i.e., orber:stop() or - a shutdown is generated, objects residing on that node will be terminated.</p> - <p>Own id: OTP-3678</p> - </item> - <item> - <p>If an IDL-file contains two interfaces of which the first one - contains an exception and the second interface, which inherits the first - one, contain an operation which raises this exception the IFR - failed since multiple references where found when invoking - orber_ifr:lookup_id/2. Now fixed.</p> - <p>Own id: OTP-3665</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>To be able to start Orber as lightweight the mnesia application - cannot be listed in the "orber.app" file. You might find it - necessary to add 'mnesia' to the applications-list. - For example, you cannot upgrade an older version - of Orber (not started as lightweight) to this version without - adding mnesia to the application dependencies list.</p> - <p>Own id: OTP-3666</p> - </item> - <item> - <p>The function <c>corba_object:non_existent/1</c> have been updated - to follow the CORBA 2.3 standard. Hence, Intra-ORB communication - with ORB:s not supporting this standard will fail. The operation - <c>corba_object:not_existent/1</c> allow users to use the old standard. - Consult the ORB vendor's documentation to decide which function to use.</p> - <p>Own id: OTP-3679</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.1.6</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Cosmetic update of internal functions.</p> - <p>Own id: -</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.1.5</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When decoding TypeCode for an object reference, e.g., as a part of - an #any{}, Orber failed. This is no longer the case. </p> - <p>Own id: OTP-3631</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.1.4</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>The function <c>start_lightweight/1</c> have been added to the - <c>orber</c> module. This function allow us to start orber as - lightweight without, or override, the configuration parameter - <c>-orber lightweight</c>.</p> - <p>Own id: -</p> - </item> - <item> - <p>A new configuration parameter, 'iiop_connection_timeout Secs', is now - available. This parameter's purpose, is to terminate the socket - connection on the client side if a time span of Secs seconds have passed. - The connection will, however, NOT be terminated if a client still waits - for a reply. For the last scenario to happen, the client have been - configured to use a larger timeout value than the configuration - parameter 'iiop_connection_timeout' have been set to.</p> - <p>Own id: -</p> - </item> - <item> - <p>Up until now, invoking an an operation with an extra Timeout parameter - (using the IC option: ic:gen(IdlFile, [{timeout,"module::interface"}])), - only applied to local Objects. Now, using the IC option above, when - compiling the stubs, and adding the extra Timeout parameter, a timeout - will also be triggered when calling Objects residing on other ORB:s. - The return value, after a timeout has been triggered, have changed from - an EXIT message to raising the system exception COMM_FAILURE. For more - information, about how this feature interacts with the configuration - parameter 'iiop_timeout', consult the documentation.</p> - <p>Own id: -</p> - </item> - <item> - <p>When using invalid intra-ORB configuration, i.e., incorrect - Port/IP-address, when trying to connect to another ORB, - a CRASH REPORT was generated if the configuration - parameter '-boot start_sasl' was used. This behavior has now changed.</p> - <p>Own id: -</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>If a client-side ORB terminated the IIOP connection immediately there - was a possibility that the server responsible detecting this did not.</p> - <p>Own id: OTP-3593</p> - </item> - <item> - <p>Setting the configuration parameter 'iiop_timeout' did not result in a - correct behavior, i.e., no timeout triggered.</p> - <p>Own id: OTP-3555</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>When using the IC option, ic:gen(IdlFile, [{timeout,"module::interface"}]), - an EXIT was the timeout result. Now, the system exception COMM_FAILURE is - raised.</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.1.3</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Orber did not ignore unrecognized TaggedProfiles. Other vendors may have - registered own TAG's with the OMG. These TAG's are valid but not - necessarily handled by other vendors.</p> - <p>Own id: OTP-3514</p> - </item> - <item> - <p>When passing Object references over IIOP, decoding local references could - fail. Now fixed.</p> - <p>Own id: OTP-3515</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.1.2</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Previously the OMG have published two suggestions for <c>Interoperable Name Service</c>, - of which, the <c>CORBA 3</c> specify <c>orbos/98-10-11</c> to be implemented. - Unfortunately, the Interoperable Name Service Orber supports, is the one not chosen. - Hence, the <c>InitialReferences.idl</c> will not be according to the future standard. - The modules name is now changed from <c>CORBA</c> to <c>Orber</c>. This will affect - code which are using this interface. The idl specification must be recompiled and - then <c>CORBA</c> must be changed to <c>Orber</c> in the client.</p> - <p>Own id: OTP-3468, OTP-3155</p> - </item> - <item> - <p>Now possible to run oe_unregister when the IDL-specification contains - exceptions correctly.</p> - <p>Own Id: OTP-3447</p> - </item> - <item> - <p>Now possible to run oe_unregister when the IDL-specification contains - attributes.</p> - <p>Own Id: OTP-3439</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <p>The change in <c>InitialReferences.idl</c> to clash with the Corba standard implies changes - in code that use this interface. See the OTP-3468 and OTP-3155 in the <c>Fixed Bugs and Malfunctions</c> - chapter above.</p> - </section> - </section> - - <section> - <title>Orber 3.1.1</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>When introducing the configuration parameter <c>ip_address</c> - it was no longer possible to have the same default behavior - as before. Now fixed.</p> - <p>Own Id: OTP-3431</p> - </item> - <item> - <p>The internal request number handling never checked if maximum reached. - Now the counter restart at 0 after reaching max.</p> - <p>Own Id: OTP-3415</p> - </item> - <item> - <p>Orber did not handle locate-requests correctly, i.e., not able to - recognize the new internal representation of object references.</p> - <p>Own Id: OTP-3414</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>It is now possible to start Orber as lightweight.</p> - <p>Own Id: -</p> - </item> - <item> - <p>It is now possible to create pseudo objects, i.e., not server objects.</p> - <p>Own Id: -</p> - </item> - <item> - <p>One new system exception introduced; 'BAD_QOS'.</p> - <p>Own Id: -</p> - </item> - <item> - <p>Orber now supports the types 'long long' and 'unsigned long long'</p> - <p>Own Id: -</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Encoding typecode for complex exceptions (non-empty body) was not done - correctly.</p> - <p>Own Id: OTP-3390</p> - </item> - <item> - <p>orber_iiop_pm crashed when it received an 'EXIT'. Now fixed.</p> - <p>Own Id: OTP-3391</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.0.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Orber is now able to handle upgrade properly.</p> - <p>Own Id: -</p> - </item> - </list> - </section> - </section> - - <section> - <title>Orber 3.0</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>It is now possible to use secure IIOP connections to and from Orber. - Orber currently only supports security with the help of SSL and not SECIOP.</p> - <p>Own Id: OTP-1510</p> - </item> - <item> - <p>It is now possible to start Orber objects as supervisor children using - Module_Interface:oe_create_link/2 or corba:create_link/4 as the start function.</p> - <p>Own Id: -</p> - </item> - <item> - <p>It is now possible to start a Orber object and be able to tell apart if it is in - the process of being restarted or has permanently terminated. This is also the reason - for introducing <c>objectkeys_gc_time</c> configuration parameter.</p> - <p>Own Id: -</p> - </item> - <item> - <p>The service CosEvent has been removed from orber and become its own application, called cosEvent.</p> - <p>Own Id: -</p> - </item> - <item> - <p>The service CosTransactions is now available as a separate application, called cosTransactions.</p> - <p>Own Id: OTP-1741</p> - </item> - <item> - <p>Three new system exceptions, 'TRANSACTION_REQUIRED', 'TRANSACTION_ROLLEDBACK' - and 'INVALID_TRANSACTION', introduced. Required by the cosTransactions application.</p> - <p>Own Id: -</p> - </item> - <item> - <p>An configuration variable ip_address has been added, so it's possible - to listen on a specific ip interface on a multi interface host. - The value is the ip address as a string or a tuple of four integers, - default value is all interfaces.</p> - <p>Own Id: OTP-3294</p> - </item> - </list> - </section> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>set- and get-operations for the 'any'-module now behaves properly.</p> - <p>Own Id: OTP-3355</p> - </item> - <item> - <p>Orber can now handle IORs which contain more than one "Tagged Profile".</p> - <p>Own Id: OTP-3266</p> - </item> - </list> - </section> - - <section> - <title>Incompatibilities</title> - <list type="bulleted"> - <item> - <p>CosEvent include paths have changed since it is now a separate application, called cosEvent.</p> - </item> - <item> - <p>The internal representation of object references have changed. Orber do, however, - recognize the old representation. But object references (created by Orber 2.2.2 or older) - stored and used through several Orber upgrades may not be supported.</p> - </item> - <item> - <p>The functions oe_create/2 and oe_create_link/2 now take an - options list as its second argument. Orber still allow - oe_create*(Env, {Type,RegName}) to be used, but may not in future releases.</p> - </item> - </list> - </section> - </section> -</chapter> - diff --git a/lib/orber/doc/src/orber.xml b/lib/orber/doc/src/orber.xml index da5fd05f98..05036667cc 100644 --- a/lib/orber/doc/src/orber.xml +++ b/lib/orber/doc/src/orber.xml @@ -558,7 +558,7 @@ <desc> <p>This function installs all the necessary mnesia tables and load default data in some of them. If one or more Orber tables - already exists the installation fails. The function\011 + already exists the installation fails. The function <em>uninstall</em> may be used, if it is safe, i.e., no other application is running Orber.</p> <p>Preconditions:</p> diff --git a/lib/orber/doc/src/part_notes.xml b/lib/orber/doc/src/part_notes.xml index 0ff4453d8c..10b3a64373 100644 --- a/lib/orber/doc/src/part_notes.xml +++ b/lib/orber/doc/src/part_notes.xml @@ -30,8 +30,6 @@ <description> <p>The Orber Application is an Erlang implementation of a CORBA Object Request Broker.</p> - <p>For information about older versions see - <url href="part_notes_history_frame.html">release notes history</url>.</p> </description> <xi:include href="notes.xml"/> </part> diff --git a/lib/orber/doc/src/part_notes_history.xml b/lib/orber/doc/src/part_notes_history.xml deleted file mode 100644 index 624865014e..0000000000 --- a/lib/orber/doc/src/part_notes_history.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="latin1" ?> -<!DOCTYPE part SYSTEM "part.dtd"> - -<part> - <header> - <copyright> - <year>2004</year> - <year>2007</year> - <holder>Ericsson AB, All Rights Reserved</holder> - </copyright> - <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - The Initial Developer of the Original Code is Ericsson AB. - </legalnotice> - - <title>Orber Release Notes History</title> - <prepared>Niclas Eklund</prepared> - <docno></docno> - <date>2004-09-15</date> - <rev>1.0</rev> - </header> - <description> - <p>The Orber Application is an Erlang implementation of a CORBA Object - Request Broker.</p> - </description> - <include file="notes_history"></include> -</part> - diff --git a/lib/orber/vsn.mk b/lib/orber/vsn.mk index 8ccdc9792c..8bfa13eb03 100644 --- a/lib/orber/vsn.mk +++ b/lib/orber/vsn.mk @@ -1,7 +1,11 @@ -ORBER_VSN = 3.6.14 +ORBER_VSN = 3.6.15 -TICKETS = OTP-8201 +TICKETS = OTP-8353 \ + OTP-8354 \ + OTP-8374 + +TICKETS_3.6.14 = OTP-8201 TICKETS_3.6.13 = OTP-7987 diff --git a/lib/public_key/src/pubkey_cert_records.erl b/lib/public_key/src/pubkey_cert_records.erl index 36b7c47a9c..c7d4080adb 100644 --- a/lib/public_key/src/pubkey_cert_records.erl +++ b/lib/public_key/src/pubkey_cert_records.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -23,7 +23,7 @@ -include("public_key.hrl"). --export([decode_cert/2, encode_cert/1, encode_tbs_cert/1]). +-export([decode_cert/2, encode_cert/1, encode_tbs_cert/1, transform/2]). -export([old_decode_cert/2, old_encode_cert/1]). %% Debugging and testing new code. diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl index b0b0b7a832..52c695523f 100644 --- a/lib/public_key/src/public_key.erl +++ b/lib/public_key/src/public_key.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -30,7 +30,7 @@ sign/2, sign/3, verify_signature/3, verify_signature/4, verify_signature/5, pem_to_der/1, pem_to_der/2, - pkix_decode_cert/2, pkix_encode_cert/1, + pkix_decode_cert/2, pkix_encode_cert/1, pkix_transform/2, pkix_is_self_signed/1, pkix_is_fixed_dh_cert/1, pkix_issuer_id/2, pkix_is_issuer/2, pkix_normalize_general_name/1, @@ -162,6 +162,20 @@ pkix_encode_cert(Cert) -> pubkey_cert_records:encode_cert(Cert). %%-------------------------------------------------------------------- +%% Function: pkix_transform(CertPart, Op) -> TransformedCertPart +%% +%% CertPart = pkix part data +%% Op = encode | decode +%% +%% Description: Transform parts of a pkix certificate between 'plain' format +%% and the internal 'otp' format, see pkix_decode_cert/2. +%% Decode transforms from 'plain' to 'otp' and encode from 'otp' to 'plain' +%% format. +%%-------------------------------------------------------------------- +pkix_transform(CertPart, Op) -> + pubkey_cert_records:transform(CertPart, Op). + +%%-------------------------------------------------------------------- %% Function: pkix_path_validation(TrustedCert, CertChain, Options) -> %% {ok, {{algorithm(), public_key(), public_key_params()} policy_tree()}} | %% {error, Reason} diff --git a/lib/ssh/doc/src/Makefile b/lib/ssh/doc/src/Makefile index d2907a39d7..e02f04e7ad 100644 --- a/lib/ssh/doc/src/Makefile +++ b/lib/ssh/doc/src/Makefile @@ -53,8 +53,8 @@ XML_REF3_FILES = \ ssh_sftp.xml \ ssh_sftpd.xml \ -XML_PART_FILES = part_notes.xml part_notes_history.xml -XML_CHAPTER_FILES = notes.xml notes_history.xml +XML_PART_FILES = part_notes.xml +XML_CHAPTER_FILES = notes.xml BOOK_FILES = book.xml @@ -70,8 +70,6 @@ EXTRA_FILES = \ $(XML_REF3_FILES:%.xml=$(HTMLDIR)/%.html) \ $(XML_CHAPTER_FILES:%.xml=$(HTMLDIR)/%.html) -# notes_history.html \ - MAN3_FILES = $(XML_REF3_FILES:%.xml=$(MAN3DIR)/%.3) diff --git a/lib/ssh/doc/src/notes.xml b/lib/ssh/doc/src/notes.xml index 54e0cf9059..ef49bb8b3d 100644 --- a/lib/ssh/doc/src/notes.xml +++ b/lib/ssh/doc/src/notes.xml @@ -29,6 +29,19 @@ <file>notes.xml</file> </header> + <section><title>Ssh 1.1.8</title> + + <section><title>Improvements and New Features</title> + <list> + <item> + <p>Old release notes removed.</p> + <p>Own Id: OTP-8356 Aux Id:</p> + </item> + </list> + </section> + + </section> + <section><title>Ssh 1.1.7</title> <section><title>Fixed Bugs and Malfunctions</title> @@ -581,8 +594,6 @@ </list> </section> - <!-- p>For information about older versions see - <url href="part_notes_history_frame.html">release notes history</url>.</p --> </section> </chapter> diff --git a/lib/ssh/doc/src/notes_history.xml b/lib/ssh/doc/src/notes_history.xml deleted file mode 100644 index bfebcd4bf4..0000000000 --- a/lib/ssh/doc/src/notes_history.xml +++ /dev/null @@ -1,737 +0,0 @@ -<?xml version="1.0" encoding="latin1" ?> -<!DOCTYPE chapter SYSTEM "chapter.dtd"> - -<chapter> - <header> - <copyright> - <year>2009</year> - <year>2009</year> - <holder>Ericsson AB, All Rights Reserved</holder> - </copyright> - <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - The Initial Developer of the Original Code is Ericsson AB. - </legalnotice> - - <title>SSH Release Notes History</title> - <prepared></prepared> - <responsible></responsible> - <docno></docno> - <approved></approved> - <checked></checked> - <date></date> - <rev>A</rev> - <file>notes_history.xml</file> - </header> - - <section><title>Ssh 0.9.9.6</title> - - <section><title>Improvements and New Features</title> - <list> - <item> - <p> - Updated asn1 file due to change in the asn1 compiler. - This has no semantical effect on the ssh application.</p> - <p> - Own Id: OTP-7246</p> - </item> - <item> - <p> - Allows for the option {fd, FD} in listen and connect - calls. The option is passed on to gen_tcp:listen and - gen_tcp:connect</p> - <p> - Own Id: OTP-7247</p> - </item> - </list> - </section> -</section> - - <section><title>Ssh 0.9.9.5</title> - - <section><title>Fixed Bugs and Malfunctions</title> - <list> - <item> - <p> - Putty version 0.60 sends ignore messages, which hanged - the OTP ssh server.</p> - <p> - Own Id: OTP-7076</p> - </item> - <item> - <p> - ssh_cm hanged when connection was closed during - handshake. (Triggered by putty 0.60 client.)</p> - <p> - Own Id: OTP-7089</p> - </item> - <item> - <p> - Fixed crash in server when receiving an empty ignore-msg. - (From the putty 0.60 client.)</p> - <p> - Own Id: OTP-7135</p> - </item> - </list> - </section> - - - <section><title>Improvements and New Features</title> - <list> - <item> - <p> - Now uses the base 64 encode/decode function in stdlib.</p> - <p> - Own Id: OTP-6486</p> - </item> - <item> - <p> - Removed runtime dependency on asn1.</p> - <p> - Own Id: OTP-6570</p> - </item> - <item> - <p> - Documentation update of ssh.</p> - <p> - Own Id: OTP-7063 Aux Id: seq10789 </p> - </item> - <item> - <p> - Same listener is used for both sshd and sftpd. Previously - the sftpd server had to be run on a separate port, now - the sshd listener will start an sftpd server when an sftp - client connects.</p> - <p> - Own Id: OTP-7090 Aux Id: seq10675 </p> - </item> - <item> - <p> - Kebord-interactive support, according to rfc 4256, has - been added to the ssh client. Also the option - <c>quiet_mode</c> has been added so that unwanted banners - may be suppressed.</p> - <p> - Own Id: OTP-7106 Aux Id: seq10841 </p> - </item> - </list> - </section> - - </section> - - <section><title>Ssh 0.9.9.4</title> - - <section><title>Improvements and New Features</title> - <list> - <item> - <p> - [sftpd] - Root parameter now behaves as expected, - instead of making sftpd malfunction.</p> - <p> - Own Id: OTP-7057 Aux Id: seq10830 </p> - </item> - </list> - </section> - </section> - - <section><title>Ssh 0.9.9.3</title> - - <section><title>Fixed Bugs and Malfunctions</title> - <list> - <item> - <p> - The sftp-server could crash if a "ls" was done on the - client, and a file was removed while ssh_sftpd:list_dir - was reading the directory, an error code from - read_file_info wasn't handled properly. This fix makes ls - return an error code instead.</p> - <p> - Own Id: OTP-6854 Aux Id: seq10740 </p> - </item> - <item> - <p> - Fixed bugs in prompting in ssl_cli. Prompts like \003> - were written as \300>. Also, newlines and returns was - removed.</p> - <p> - Own Id: OTP-6917 Aux Id: seq10773 </p> - </item> - </list> - </section> - - <section><title>Improvements and New Features</title> - <list> - <item> - <p> - [sftpd] - New option "root" to set the root of the - sftp-server and the callback module for file handling now - has a state parameter.</p> - <p> - Own Id: OTP-7075 Aux Id: seq10675 </p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.9.2</title> - <section> - <title>Better error-handling in ssh_sshd:listen</title> - <list type="bulleted"> - <item> - <p>The caller was hanged when listening with ssh_sshd:listen - (or ssh_sftpd:listen) on a port and IP already in use. - Now an error is returned instead.</p> - <p>Own Id: OTP-6727</p> - </item> - </list> - </section> - - <section> - <title>Fix in ssh_sftpd</title> - <list type="bulleted"> - <item> - <p>Cd ../.. didn't work when connecting to a ssh_sftpd server.</p> - <p>Own Id: OTP-6727</p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.9.1</title> - - <section> - <title>Minor Makefile changes</title> - <list type="bulleted"> - <item> - <p>Removed use of <c><![CDATA[erl_flags]]></c> from Makefile.</p> - <p>Own Id: OTP-6689</p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.9</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A race condition that could make the server crash if a - client sent a SSH_MSG_USERAUTH_REQUEST packet immediately - after its SSH_MSG_SERVICE_REQUEST, is removed.</p> - <p>Own Id: OTP-6379 Aux Id: seq10523 </p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.8</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Corrected minor bugs and removed dead code found by - dialyzer.</p> - <p>Own Id: OTP-6524</p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.7</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>[sftp] - The function ssh_sftp:make_symlink/3 was not - fully implemented.</p> - <p>Own Id: OTP-6446</p> - </item> - <item> - <p>[ssh] - An internal value was, due to a bug, always set - to undefined even when it was not, this could lead to - connections being wrongly refused.</p> - <p>Own Id: OTP-6450</p> - </item> - <item> - <p>A pattern matching was missing "/binary" resulting in - that the internal function ssh_xfer:decode_acl/2 did not - work as expected.</p> - <p>Own Id: OTP-6458</p> - </item> - <item> - <p>[sftp] - read_link/2 did not return the documented value</p> - <p>Own Id: OTP-6471</p> - </item> - <item> - <p>Removed debugg printouts from ssh_cli.erl</p> - <p>Own Id: OTP-6483</p> - </item> - <item> - <p>[sftp, ssh] - The connection timeout was overridden by an - internal gen_server default timeout.</p> - <p>Own Id: OTP-6488 Aux Id: seq10569 </p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.6</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Removed debug printout from production code.</p> - <p>Own Id: OTP-6348 Aux Id: seq10510 </p> - </item> - <item> - <p>[sftpd] - When the sftp client ends the session the - server will now behave correctly and not leave the client - hanging.</p> - <p>Own Id: OTP-6349 Aux Id: seq10510 </p> - </item> - <item> - <p>[sftpd] - No longer used files were not closed until the - session was ended.</p> - <p>Own Id: OTP-6350 Aux Id: seq10514 </p> - </item> - <item> - <p>[sftpd] - File rename requests sent by sftp version 3 - clients were not handled.</p> - <p>Own Id: OTP-6352 Aux Id: seq10513 </p> - </item> - <item> - <p>[sftpd] - Request that did not fit into one ssh message - were not handled.</p> - <p>Own Id: OTP-6353 Aux Id: seq10515 </p> - </item> - <item> - <p>Removed error logging of auth method none, as this is not - an error but rather a feature, that is used to get - initial information from the server.</p> - <p>Own Id: OTP-6414</p> - </item> - </list> - </section> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>[sftpd] - Added new option to specify a callback module - for the sftpd-server file handling. The default callback - module uses file and filelib.</p> - <p>Own Id: OTP-6356 Aux Id: seq10519 </p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.5</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>The data window in SSH wasn't resized in the ssh_cli - receive data, this made the ssh_cli-server hang if more - than 64K data was received at one time. The option - tcp_nodelay was added, for nodelay in tcp connections.</p> - <p>Own Id: OTP-6231</p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9.4</title> - - <section> - <title>Reported Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Unnecessary explicit start of crypto application - in ssh application. This has been removed. The - app-file specifies that ssh depends on the crypto app. - This is enough. See also the - <seealso marker="ssh">ssh</seealso> module.</p> - <p>Also changed some error reports to info reports.</p> - <p>Own Id: OTP-6183</p> - <p>Aux Id: Seq 10383</p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9.3</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Added way for cli to get peer name</p> - <p>Own Id: OTP-6138</p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9.2</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Added some options to listen</p> - <p>Own Id: OTP-6070</p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9.1</title> - <section><title>Ssh 0.9.9.4</title> - - <section><title>Improvements and New Features</title> - <list> - <item> - <p> - [sftpd] - Root parameter now behaves as expected, - instead of making sftpd malfunction.</p> - <p> - Own Id: OTP-7057 Aux Id: seq10830 </p> - </item> - </list> - </section> - </section> - - <section><title>Ssh 0.9.9.3</title> - - <section><title>Fixed Bugs and Malfunctions</title> - <list> - <item> - <p> - The sftp-server could crash if a "ls" was done on the - client, and a file was removed while ssh_sftpd:list_dir - was reading the directory, an error code from - read_file_info wasn't handled properly. This fix makes ls - return an error code instead.</p> - <p> - Own Id: OTP-6854 Aux Id: seq10740 </p> - </item> - <item> - <p> - Fixed bugs in prompting in ssl_cli. Prompts like \003> - were written as \300>. Also, newlines and returns was - removed.</p> - <p> - Own Id: OTP-6917 Aux Id: seq10773 </p> - </item> - </list> - </section> - - <section><title>Improvements and New Features</title> - <list> - <item> - <p> - [sftpd] - New option "root" to set the root of the - sftp-server and the callback module for file handling now - has a state parameter.</p> - <p> - Own Id: OTP-7075 Aux Id: seq10675 </p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.9.2</title> - <section> - <title>Better error-handling in ssh_sshd:listen</title> - <list type="bulleted"> - <item> - <p>The caller was hanged when listening with ssh_sshd:listen - (or ssh_sftpd:listen) on a port and IP already in use. - Now an error is returned instead.</p> - <p>Own Id: OTP-6727</p> - </item> - </list> - </section> - - <section> - <title>Fix in ssh_sftpd</title> - <list type="bulleted"> - <item> - <p>Cd ../.. didn't work when connecting to a ssh_sftpd server.</p> - <p>Own Id: OTP-6727</p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.9.1</title> - - <section> - <title>Minor Makefile changes</title> - <list type="bulleted"> - <item> - <p>Removed use of <c><![CDATA[erl_flags]]></c> from Makefile.</p> - <p>Own Id: OTP-6689</p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.9</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>A race condition that could make the server crash if a - client sent a SSH_MSG_USERAUTH_REQUEST packet immediately - after its SSH_MSG_SERVICE_REQUEST, is removed.</p> - <p>Own Id: OTP-6379 Aux Id: seq10523 </p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.8</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Corrected minor bugs and removed dead code found by - dialyzer.</p> - <p>Own Id: OTP-6524</p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.7</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>[sftp] - The function ssh_sftp:make_symlink/3 was not - fully implemented.</p> - <p>Own Id: OTP-6446</p> - </item> - <item> - <p>[ssh] - An internal value was, due to a bug, always set - to undefined even when it was not, this could lead to - connections being wrongly refused.</p> - <p>Own Id: OTP-6450</p> - </item> - <item> - <p>A pattern matching was missing "/binary" resulting in - that the internal function ssh_xfer:decode_acl/2 did not - work as expected.</p> - <p>Own Id: OTP-6458</p> - </item> - <item> - <p>[sftp] - read_link/2 did not return the documented value</p> - <p>Own Id: OTP-6471</p> - </item> - <item> - <p>Removed debugg printouts from ssh_cli.erl</p> - <p>Own Id: OTP-6483</p> - </item> - <item> - <p>[sftp, ssh] - The connection timeout was overridden by an - internal gen_server default timeout.</p> - <p>Own Id: OTP-6488 Aux Id: seq10569 </p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.6</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Removed debug printout from production code.</p> - <p>Own Id: OTP-6348 Aux Id: seq10510 </p> - </item> - <item> - <p>[sftpd] - When the sftp client ends the session the - server will now behave correctly and not leave the client - hanging.</p> - <p>Own Id: OTP-6349 Aux Id: seq10510 </p> - </item> - <item> - <p>[sftpd] - No longer used files were not closed until the - session was ended.</p> - <p>Own Id: OTP-6350 Aux Id: seq10514 </p> - </item> - <item> - <p>[sftpd] - File rename requests sent by sftp version 3 - clients were not handled.</p> - <p>Own Id: OTP-6352 Aux Id: seq10513 </p> - </item> - <item> - <p>[sftpd] - Request that did not fit into one ssh message - were not handled.</p> - <p>Own Id: OTP-6353 Aux Id: seq10515 </p> - </item> - <item> - <p>Removed error logging of auth method none, as this is not - an error but rather a feature, that is used to get - initial information from the server.</p> - <p>Own Id: OTP-6414</p> - </item> - </list> - </section> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>[sftpd] - Added new option to specify a callback module - for the sftpd-server file handling. The default callback - module uses file and filelib.</p> - <p>Own Id: OTP-6356 Aux Id: seq10519 </p> - </item> - </list> - </section> - </section> - - <section> - <title>Ssh 0.9.5</title> - - <section> - <title>Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>The data window in SSH wasn't resized in the ssh_cli - receive data, this made the ssh_cli-server hang if more - than 64K data was received at one time. The option - tcp_nodelay was added, for nodelay in tcp connections.</p> - <p>Own Id: OTP-6231</p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9.4</title> - - <section> - <title>Reported Fixed Bugs and Malfunctions</title> - <list type="bulleted"> - <item> - <p>Unnecessary explicit start of crypto application - in ssh application. This has been removed. The - app-file specifies that ssh depends on the crypto app. - This is enough. See also the - <seealso marker="ssh">ssh</seealso> module.</p> - <p>Also changed some error reports to info reports.</p> - <p>Own Id: OTP-6183</p> - <p>Aux Id: Seq 10383</p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9.3</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Added way for cli to get peer name</p> - <p>Own Id: OTP-6138</p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9.2</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Added some options to listen</p> - <p>Own Id: OTP-6070</p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9.1</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>Fixes in ssh_sftp, changes of timeout handling, - expand_fun moved to io:setopts</p> - <p>Own Id: OTP-5877 Aux Id: OTP-5781 </p> - </item> - </list> - </section> - </section> - - <section> - <title>SSH 0.9</title> - - <section> - <title>Improvements and New Features</title> - <list type="bulleted"> - <item> - <p>The previously undocumented and UNSUPPORTED <c><![CDATA[ssh]]></c> - application has been updated and documented. This release - of the <c><![CDATA[ssh]]></c> application is still considered to be a - beta release and (if necessary) there could still be - changes in its API before it reaches 1.0.</p> - <p>Also, more cryptographic algorithms have been added to - the <c><![CDATA[crypto]]></c> application.</p> - <p>*** POTENTIAL INCOMPATIBILITY ***</p> - <p>Own Id: OTP-5631</p> - </item> - </list> - </section> - </section> - </section> - -</chapter> - - diff --git a/lib/ssh/doc/src/part_notes.xml b/lib/ssh/doc/src/part_notes.xml index f87efffe5c..700f76200c 100644 --- a/lib/ssh/doc/src/part_notes.xml +++ b/lib/ssh/doc/src/part_notes.xml @@ -31,8 +31,7 @@ <description> <p>This document describes the changes made to the SSH application. </p> - <p>For information about older versions see - <url href="part_notes_history_frame.html">release notes history</url>.</p> </description> + </description> <xi:include file="notes.xml"/> </part> diff --git a/lib/ssh/doc/src/part_notes_history.xml b/lib/ssh/doc/src/part_notes_history.xml deleted file mode 100644 index 49f72fd3db..0000000000 --- a/lib/ssh/doc/src/part_notes_history.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="latin1" ?> -<!DOCTYPE part SYSTEM "part.dtd"> - -<part> - <header> - <copyright> - <year>2004</year> - <year>2007</year> - <holder>Ericsson AB, All Rights Reserved</holder> - </copyright> - <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. - - The Initial Developer of the Original Code is Ericsson AB. - </legalnotice> - - <title>Ssh</title> - <prepared>Ingela Anderton Andin</prepared> - <docno></docno> - <date></date> - <rev></rev> - <file>part_notes.xml</file> - </header> - <include file="notes_history"></include> -</part> - - diff --git a/lib/ssh/vsn.mk b/lib/ssh/vsn.mk index 016fb30c69..2b9df4ae60 100644 --- a/lib/ssh/vsn.mk +++ b/lib/ssh/vsn.mk @@ -1,9 +1,11 @@ #-*-makefile-*- ; force emacs to enter makefile-mode -SSH_VSN = 1.1.7 +SSH_VSN = 1.1.8 APP_VSN = "ssh-$(SSH_VSN)" -TICKETS = OTP-8121 \ +TICKETS = OTP-8356 + +TICKETS_1.1.7 = OTP-8121 \ OTP-8277 \ OTP-8278 \ OTP-8201 diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl index 178c055cdf..d9377fe3d6 100644 --- a/lib/ssl/src/ssl_connection.erl +++ b/lib/ssl/src/ssl_connection.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -1115,13 +1115,12 @@ do_server_hello(Type, #state{negotiated_version = Version, case ssl_handshake:master_secret(Version, Session, ConnectionStates0, server) of {_, ConnectionStates1} -> - {ConnectionStates, Hashes} = - finished(State#state{connection_states = - ConnectionStates1}), - {next_state, abbreviated, - next_record(State#state{connection_states = - ConnectionStates, - tls_handshake_hashes = Hashes})}; + State1 = State#state{connection_states=ConnectionStates1, + session = Session}, + {ConnectionStates, Hashes} = finalize_server_handshake(State1), + Resumed = State1#state{connection_states = ConnectionStates, + tls_handshake_hashes = Hashes}, + {next_state, abbreviated, next_record(Resumed)}; #alert{} = Alert -> handle_own_alert(Alert, Version, hello, State), {stop, normal, State} diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl index 829e0c2ba6..8c598135ca 100644 --- a/lib/ssl/src/ssl_handshake.erl +++ b/lib/ssl/src/ssl_handshake.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -860,9 +860,31 @@ certificate_types(_) -> %% a RSA_FIXED_DH or DSS_FIXED_DH <<?BYTE(?RSA_SIGN)>>. -certificate_authorities(_) -> - %%TODO Make list of know CA:s - <<>>. +certificate_authorities(CertDbRef) -> + Authorities = certificate_authorities_from_db(CertDbRef), + Enc = fun(#'OTPCertificate'{tbsCertificate=TBSCert}) -> + OTPSubj = TBSCert#'OTPTBSCertificate'.subject, + Subj = public_key:pkix_transform(OTPSubj, encode), + {ok, DNEncoded} = 'OTP-PUB-KEY':encode('Name', Subj), + DNEncodedBin = iolist_to_binary(DNEncoded), + DNEncodedLen = byte_size(DNEncodedBin), + <<?UINT16(DNEncodedLen), DNEncodedBin/binary>> + end, + list_to_binary([Enc(Cert) || {_, Cert} <- Authorities]). + +certificate_authorities_from_db(CertDbRef) -> + certificate_authorities_from_db(CertDbRef, no_candidate, []). + +certificate_authorities_from_db(CertDbRef, PrevKey, Acc) -> + case ssl_certificate_db:issuer_candidate(PrevKey) of + no_more_candidates -> + lists:reverse(Acc); + {{CertDbRef, _, _} = Key, Cert} -> + certificate_authorities_from_db(CertDbRef, Key, [Cert|Acc]); + {Key, _Cert} -> + %% skip certs not from this ssl connection + certificate_authorities_from_db(CertDbRef, Key, Acc) + end. digitally_signed(Hashes, #'RSAPrivateKey'{} = Key) -> public_key:encrypt_private(Hashes, Key, diff --git a/lib/ssl/test/Makefile b/lib/ssl/test/Makefile new file mode 100644 index 0000000000..bd86120c98 --- /dev/null +++ b/lib/ssl/test/Makefile @@ -0,0 +1,137 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1999-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# + +# + +# SSL test suite Makefile +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(GS_VSN) + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- + +MODULES = \ + ssl_test_lib \ + ssl_basic_SUITE \ + ssl_packet_SUITE \ + ssl_payload_SUITE \ + ssl_to_openssl_SUITE \ + ssl_test_MACHINE \ + old_ssl_active_SUITE \ + old_ssl_active_once_SUITE \ + old_ssl_passive_SUITE \ + old_ssl_verify_SUITE \ + old_ssl_peer_cert_SUITE \ + old_ssl_misc_SUITE \ + old_ssl_protocol_SUITE \ + old_transport_accept_SUITE \ + old_ssl_dist_SUITE \ + make_certs + + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = ssl_test_MACHINE.hrl + +HRL_FILES_SRC = \ + ssl_pkix.hrl \ + ssl_alert.hrl \ + ssl_handshake.hrl + +HRL_FILES_INC = \ + OTP-PKIX.hrl + +HRL_FILES_NEEDED_IN_TEST = \ + $(HRL_FILES_SRC:%=../src/%) \ + $(HRL_FILES_INC:%=../include/%) + +TARGET_FILES = $(MODULES:%=$(EBIN)/%.$(EMULATOR)) + +INCLUDES = -I. -I$(ERL_TOP)/lib/test_server/include/ + +DATADIRS = ssl_basic_SUITE_data + +EMAKEFILE=Emakefile +MAKE_EMAKE = $(wildcard $(ERL_TOP)/make/make_emakefile) + +COVER_FILE = ssl.cover + +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/ssl_test + +# ---------------------------------------------------- +# FLAGS +# The path to the test_server ebin dir is needed when +# running the target "targets". +# ---------------------------------------------------- +ERL_COMPILE_FLAGS += -pa ../../../internal_tools/test_server/ebin \ + $(INCLUDES) + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- + +tests debug opt: $(BUILDTARGET) + +targets: $(TARGET_FILES) + +.PHONY: emakebuild + +emakebuild: $(EMAKEFILE) + +$(EMAKEFILE): + $(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) '*_SUITE_make' | grep -v Warning > $(EMAKEFILE) + $(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) | grep -v Warning >> $(EMAKEFILE) + +clean: + rm -f $(EMAKEFILE) + rm -f $(TARGET_FILES) + rm -f core *~ + +docs: + +# ---------------------------------------------------- +# Release Target +# ---------------------------------------------------- +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: opt + +release_tests_spec: opt + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(ERL_FILES) $(HRL_FILES) $(HRL_FILES_NEEDED_IN_TEST) $(COVER_FILE) $(RELSYSDIR) + $(INSTALL_DATA) ssl.spec $(RELSYSDIR) + chmod -f -R u+w $(RELSYSDIR) + @tar cf - *_SUITE_data | (cd $(RELSYSDIR); tar xf -) + +release_docs_spec: + +# Dependencies + +$(TARGET_FILES): $(HRL_FILES) diff --git a/lib/ssl/test/make_certs.erl b/lib/ssl/test/make_certs.erl new file mode 100644 index 0000000000..0cdf33c3e2 --- /dev/null +++ b/lib/ssl/test/make_certs.erl @@ -0,0 +1,288 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2007-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +-module(make_certs). + +-export([all/2]). + +-record(dn, {commonName, + organizationalUnitName = "Erlang OTP", + organizationName = "Ericsson AB", + localityName = "Stockholm", + countryName = "SE", + emailAddress = "[email protected]"}). + +all(DataDir, PrivDir) -> + OpenSSLCmd = "openssl", + create_rnd(DataDir, PrivDir), % For all requests + rootCA(PrivDir, OpenSSLCmd, "erlangCA"), + intermediateCA(PrivDir, OpenSSLCmd, "otpCA", "erlangCA"), + endusers(PrivDir, OpenSSLCmd, "otpCA", ["client", "server"]), + collect_certs(PrivDir, ["erlangCA", "otpCA"], ["client", "server"]), + %% Create keycert files + SDir = filename:join([PrivDir, "server"]), + SC = filename:join([SDir, "cert.pem"]), + SK = filename:join([SDir, "key.pem"]), + SKC = filename:join([SDir, "keycert.pem"]), + append_files([SK, SC], SKC), + CDir = filename:join([PrivDir, "client"]), + CC = filename:join([CDir, "cert.pem"]), + CK = filename:join([CDir, "key.pem"]), + CKC = filename:join([CDir, "keycert.pem"]), + append_files([CK, CC], CKC), + remove_rnd(PrivDir). + +append_files(FileNames, ResultFileName) -> + {ok, ResultFile} = file:open(ResultFileName, [write]), + do_append_files(FileNames, ResultFile). + +do_append_files([], RF) -> + ok = file:close(RF); +do_append_files([F|Fs], RF) -> + {ok, Data} = file:read_file(F), + ok = file:write(RF, Data), + do_append_files(Fs, RF). + +rootCA(Root, OpenSSLCmd, Name) -> + create_ca_dir(Root, Name, ca_cnf(Name)), + DN = #dn{commonName = Name}, + create_self_signed_cert(Root, OpenSSLCmd, Name, req_cnf(DN)), + ok. + +intermediateCA(Root, OpenSSLCmd, CA, ParentCA) -> + CA = "otpCA", + create_ca_dir(Root, CA, ca_cnf(CA)), + CARoot = filename:join([Root, CA]), + DN = #dn{commonName = CA}, + CnfFile = filename:join([CARoot, "req.cnf"]), + file:write_file(CnfFile, req_cnf(DN)), + KeyFile = filename:join([CARoot, "private", "key.pem"]), + ReqFile = filename:join([CARoot, "req.pem"]), + create_req(Root, OpenSSLCmd, CnfFile, KeyFile, ReqFile), + CertFile = filename:join([CARoot, "cert.pem"]), + sign_req(Root, OpenSSLCmd, ParentCA, "ca_cert", ReqFile, CertFile). + +endusers(Root, OpenSSLCmd, CA, Users) -> + lists:foreach(fun(User) -> enduser(Root, OpenSSLCmd, CA, User) end, Users). + +enduser(Root, OpenSSLCmd, CA, User) -> + UsrRoot = filename:join([Root, User]), + file:make_dir(UsrRoot), + CnfFile = filename:join([UsrRoot, "req.cnf"]), + DN = #dn{commonName = User}, + file:write_file(CnfFile, req_cnf(DN)), + KeyFile = filename:join([UsrRoot, "key.pem"]), + ReqFile = filename:join([UsrRoot, "req.pem"]), + create_req(Root, OpenSSLCmd, CnfFile, KeyFile, ReqFile), + CertFile = filename:join([UsrRoot, "cert.pem"]), + sign_req(Root, OpenSSLCmd, CA, "user_cert", ReqFile, CertFile). + +collect_certs(Root, CAs, Users) -> + Bins = lists:foldr( + fun(CA, Acc) -> + File = filename:join([Root, CA, "cert.pem"]), + {ok, Bin} = file:read_file(File), + [Bin, "\n" | Acc] + end, [], CAs), + lists:foreach( + fun(User) -> + File = filename:join([Root, User, "cacerts.pem"]), + file:write_file(File, Bins) + end, Users). + +create_self_signed_cert(Root, OpenSSLCmd, CAName, Cnf) -> + CARoot = filename:join([Root, CAName]), + CnfFile = filename:join([CARoot, "req.cnf"]), + file:write_file(CnfFile, Cnf), + KeyFile = filename:join([CARoot, "private", "key.pem"]), + CertFile = filename:join([CARoot, "cert.pem"]), + Cmd = [OpenSSLCmd, " req" + " -new" + " -x509" + " -config ", CnfFile, + " -keyout ", KeyFile, + " -out ", CertFile], + Env = [{"ROOTDIR", Root}], + cmd(Cmd, Env). + +create_ca_dir(Root, CAName, Cnf) -> + CARoot = filename:join([Root, CAName]), + file:make_dir(CARoot), + create_dirs(CARoot, ["certs", "crl", "newcerts", "private"]), + create_rnd(Root, filename:join([CAName, "private"])), + create_files(CARoot, [{"serial", "01\n"}, + {"index.txt", ""}, + {"ca.cnf", Cnf}]). + +create_req(Root, OpenSSLCmd, CnfFile, KeyFile, ReqFile) -> + Cmd = [OpenSSLCmd, " req" + " -new" + " -config ", CnfFile, + " -keyout ", KeyFile, + " -out ", ReqFile], + Env = [{"ROOTDIR", Root}], + cmd(Cmd, Env). + +sign_req(Root, OpenSSLCmd, CA, CertType, ReqFile, CertFile) -> + CACnfFile = filename:join([Root, CA, "ca.cnf"]), + Cmd = [OpenSSLCmd, " ca" + " -batch" + " -notext" + " -config ", CACnfFile, + " -extensions ", CertType, + " -in ", ReqFile, + " -out ", CertFile], + Env = [{"ROOTDIR", Root}], + cmd(Cmd, Env). + +%% +%% Misc +%% + +create_dirs(Root, Dirs) -> + lists:foreach(fun(Dir) -> + file:make_dir(filename:join([Root, Dir])) end, + Dirs). + +create_files(Root, NameContents) -> + lists:foreach( + fun({Name, Contents}) -> + file:write_file(filename:join([Root, Name]), Contents) end, + NameContents). + +create_rnd(FromDir, ToDir) -> + From = filename:join([FromDir, "RAND"]), + To = filename:join([ToDir, "RAND"]), + file:copy(From, To). + +remove_rnd(Dir) -> + File = filename:join([Dir, "RAND"]), + file:delete(File). + +cmd(Cmd, Env) -> + FCmd = lists:flatten(Cmd), + Port = open_port({spawn, FCmd}, [stream, eof, exit_status, stderr_to_stdout, + {env, Env}]), + eval_cmd(Port). + +eval_cmd(Port) -> + receive + {Port, {data, _}} -> + eval_cmd(Port); + {Port, eof} -> + ok + end, + receive + {Port, {exit_status, Status}} when Status /= 0 -> + %% io:fwrite("exit status: ~w~n", [Status]), + exit({eval_cmd, Status}) + after 0 -> + ok + end. + +%% +%% Contents of configuration files +%% + +req_cnf(DN) -> + ["# Purpose: Configuration for requests (end users and CAs)." + "\n" + "ROOTDIR = $ENV::ROOTDIR\n" + "\n" + + "[req]\n" + "input_password = secret\n" + "output_password = secret\n" + "default_bits = 1024\n" + "RANDFILE = $ROOTDIR/RAND\n" + "encrypt_key = no\n" + "default_md = sha1\n" + "#string_mask = pkix\n" + "x509_extensions = ca_ext\n" + "prompt = no\n" + "distinguished_name= name\n" + "\n" + + "[name]\n" + "commonName = ", DN#dn.commonName, "\n" + "organizationalUnitName = ", DN#dn.organizationalUnitName, "\n" + "organizationName = ", DN#dn.organizationName, "\n" + "localityName = ", DN#dn.localityName, "\n" + "countryName = ", DN#dn.countryName, "\n" + "emailAddress = ", DN#dn.emailAddress, "\n" + "\n" + + "[ca_ext]\n" + "basicConstraints = critical, CA:true\n" + "keyUsage = cRLSign, keyCertSign\n" + "subjectKeyIdentifier = hash\n" + "subjectAltName = email:copy\n"]. + + +ca_cnf(CA) -> + ["# Purpose: Configuration for CAs.\n" + "\n" + "ROOTDIR = $ENV::ROOTDIR\n" + "default_ca = ca\n" + "\n" + + "[ca]\n" + "dir = $ROOTDIR/", CA, "\n" + "certs = $dir/certs\n" + "crl_dir = $dir/crl\n" + "database = $dir/index.txt\n" + "new_certs_dir = $dir/newcerts\n" + "certificate = $dir/cert.pem\n" + "serial = $dir/serial\n" + "crl = $dir/crl.pem\n" + "private_key = $dir/private/key.pem\n" + "RANDFILE = $dir/private/RAND\n" + "\n" + "x509_extensions = user_cert\n" + "default_days = 3600\n" + "default_md = sha1\n" + "preserve = no\n" + "policy = policy_match\n" + "\n" + + "[policy_match]\n" + "commonName = supplied\n" + "organizationalUnitName = optional\n" + "organizationName = match\n" + "countryName = match\n" + "localityName = match\n" + "emailAddress = supplied\n" + "\n" + + "[user_cert]\n" + "basicConstraints = CA:false\n" + "keyUsage = nonRepudiation, digitalSignature, keyEncipherment\n" + "subjectKeyIdentifier = hash\n" + "authorityKeyIdentifier = keyid,issuer:always\n" + "subjectAltName = email:copy\n" + "issuerAltName = issuer:copy\n" + "\n" + + "[ca_cert]\n" + "basicConstraints = critical,CA:true\n" + "keyUsage = cRLSign, keyCertSign\n" + "subjectKeyIdentifier = hash\n" + "authorityKeyIdentifier = keyid:always,issuer:always\n" + "subjectAltName = email:copy\n" + "issuerAltName = issuer:copy\n"]. diff --git a/lib/ssl/test/old_ssl_active_SUITE.erl b/lib/ssl/test/old_ssl_active_SUITE.erl new file mode 100644 index 0000000000..fc44fa23dd --- /dev/null +++ b/lib/ssl/test/old_ssl_active_SUITE.erl @@ -0,0 +1,387 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(old_ssl_active_SUITE). + +-export([all/1, + init_per_testcase/2, + fin_per_testcase/2, + config/1, + finish/1, + cinit_return_chkclose/1, + sinit_return_chkclose/1, + cinit_big_return_chkclose/1, + sinit_big_return_chkclose/1, + cinit_big_echo_chkclose/1, + cinit_huge_echo_chkclose/1, + sinit_big_echo_chkclose/1, + cinit_few_echo_chkclose/1, + cinit_many_echo_chkclose/1, + cinit_cnocert/1 + ]). + +-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7, + test_server_only/6]). + +-include("test_server.hrl"). +-include("ssl_test_MACHINE.hrl"). + +-define(MANYCONNS, ssl_test_MACHINE:many_conns()). + +init_per_testcase(_Case, Config) -> + WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT), + [{watchdog, WatchDog}| Config]. + +fin_per_testcase(_Case, Config) -> + WatchDog = ?config(watchdog, Config), + test_server:timetrap_cancel(WatchDog). + +all(doc) -> + "Test of ssl.erl interface in active mode."; +all(suite) -> + {conf, + config, + [cinit_return_chkclose, + sinit_return_chkclose, + cinit_big_return_chkclose, + sinit_big_return_chkclose, + cinit_big_echo_chkclose, + cinit_huge_echo_chkclose, + sinit_big_echo_chkclose, + cinit_few_echo_chkclose, + cinit_many_echo_chkclose, + cinit_cnocert], + finish}. + +config(doc) -> + "Want to se what Config contains, and record the number of available " + "file descriptors"; +config(suite) -> + []; +config(Config) -> + io:format("Config: ~p~n", [Config]), + case os:type() of + {unix, _} -> + ?line io:format("Max fd value: ~s", [os:cmd("ulimit -n")]); + _ -> + ok + end, + %% XXX Also record: Erlang/SSL version, version of OpenSSL, + %% operating system, version of OTP, Erts, kernel and stdlib. + + %% Check if SSL exists. If this case fails, all other cases are skipped + case ssl:start() of + ok -> ssl:stop(); + {error, {already_started, _}} -> ssl:stop(); + Error -> ?t:fail({failed_starting_ssl,Error}) + end, + Config. + +finish(doc) -> + "This test case has no mission other than closing the conf case"; +finish(suite) -> + []; +finish(Config) -> + Config. + +cinit_return_chkclose(doc) -> + "Client sends 1000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +cinit_return_chkclose(suite) -> + []; +cinit_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_return_chkclose(doc) -> + "Server sends 1000 bytes to client, that receives them, sends them " + "back, and closes. Server waits for close. Both have certs."; +sinit_return_chkclose(suite) -> + []; +sinit_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {recv, DataSize}, {send, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_big_return_chkclose(doc) -> + "Client sends 50000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +cinit_big_return_chkclose(suite) -> + []; +cinit_big_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_big_return_chkclose(doc) -> + "Server sends 50000 bytes to client, that receives them, sends them " + "back, and closes. Server waits for close. Both have certs."; +sinit_big_return_chkclose(suite) -> + []; +sinit_big_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {recv, DataSize}, {send, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_big_echo_chkclose(doc) -> + "Client sends 50000 bytes to server, that echoes them back " + "and closes. Client waits for close. Both have certs."; +cinit_big_echo_chkclose(suite) -> + []; +cinit_big_echo_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {echo, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_huge_echo_chkclose(doc) -> + "Client sends 500000 bytes to server, that echoes them back " + "and closes. Client waits for close. Both have certs."; +cinit_huge_echo_chkclose(suite) -> + []; +cinit_huge_echo_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 500000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {echo, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_big_echo_chkclose(doc) -> + "Server sends 50000 bytes to client, that echoes them back " + "and closes. Server waits for close. Both have certs."; +sinit_big_echo_chkclose(suite) -> + []; +sinit_big_echo_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {echo, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + + +%% This case is repeated several times. + +cinit_few_echo_chkclose(X) -> cinit_many_echo_chkclose(X, 7). + +cinit_many_echo_chkclose(X) -> cinit_many_echo_chkclose(X, ?MANYCONNS). + +cinit_many_echo_chkclose(doc, _NConns) -> + "N client sends 10000 bytes to server, that echoes them back " + "and closes. Clients wait for close. All have certs."; +cinit_many_echo_chkclose(suite, _NConns) -> + []; +cinit_many_echo_chkclose(Config, NConns) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 10000, LPort = 3456, + Timeout = 80000, + + io:format("~w connections", [NConns]), + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {echo, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + + +cinit_cnocert(doc) -> + "Client sends 1000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Client has no cert, " + "but server has."; +cinit_cnocert(suite) -> + []; +cinit_cnocert(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3457, + Timeout = 40000, NConns = 1, + + ?line {ok, {_CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + + diff --git a/lib/ssl/test/old_ssl_active_once_SUITE.erl b/lib/ssl/test/old_ssl_active_once_SUITE.erl new file mode 100644 index 0000000000..6224b17aa7 --- /dev/null +++ b/lib/ssl/test/old_ssl_active_once_SUITE.erl @@ -0,0 +1,409 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2002-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(old_ssl_active_once_SUITE). + +-export([all/1, + init_per_testcase/2, + fin_per_testcase/2, + config/1, + finish/1, + server_accept_timeout/1, + cinit_return_chkclose/1, + sinit_return_chkclose/1, + cinit_big_return_chkclose/1, + sinit_big_return_chkclose/1, + cinit_big_echo_chkclose/1, + cinit_huge_echo_chkclose/1, + sinit_big_echo_chkclose/1, + cinit_few_echo_chkclose/1, + cinit_many_echo_chkclose/1, + cinit_cnocert/1 + ]). + +-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7, + test_server_only/6]). +-include("test_server.hrl"). +-include("ssl_test_MACHINE.hrl"). + +-define(MANYCONNS, ssl_test_MACHINE:many_conns()). + +init_per_testcase(_Case, Config) -> + WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT), + [{watchdog, WatchDog}| Config]. + +fin_per_testcase(_Case, Config) -> + WatchDog = ?config(watchdog, Config), + test_server:timetrap_cancel(WatchDog). + +all(doc) -> + "Test of ssl.erl interface in passive mode."; +all(suite) -> + {conf, + config, + [server_accept_timeout, + cinit_return_chkclose, + sinit_return_chkclose, + cinit_big_return_chkclose, + sinit_big_return_chkclose, + cinit_big_echo_chkclose, + cinit_huge_echo_chkclose, + sinit_big_echo_chkclose, + cinit_few_echo_chkclose, + cinit_many_echo_chkclose, + cinit_cnocert], + finish}. + +config(doc) -> + "Want to se what Config contains."; +config(suite) -> + []; +config(Config) -> + io:format("Config: ~p~n", [Config]), + + %% Check if SSL exists. If this case fails, all other cases are skipped + case ssl:start() of + ok -> ssl:stop(); + {error, {already_started, _}} -> ssl:stop(); + Error -> ?t:fail({failed_starting_ssl,Error}) + end, + Config. + +finish(doc) -> + "This test case has no mission other than closing the conf case"; +finish(suite) -> + []; +finish(Config) -> + Config. + +server_accept_timeout(doc) -> + "Server has one pending accept with timeout. Checks that return " + "value is {error, timeout}."; +server_accept_timeout(suite) -> + []; +server_accept_timeout(Config) when list(Config) -> + process_flag(trap_exit, true), + LPort = 3456, + Timeout = 40000, NConns = 1, + AccTimeout = 3000, + + ?line {ok, {_, SsslOpts}} = mk_ssl_cert_opts(Config), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, AccTimeout}, + accept_timeout], + ?line test_server_only(NConns, LCmds, ACmds, Timeout, ?MODULE, + Config). + +cinit_return_chkclose(doc) -> + "Client sends 1000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +cinit_return_chkclose(suite) -> + []; +cinit_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_return_chkclose(doc) -> + "Server sends 1000 bytes to client, that receives them, sends them " + "back, and closes. Server waits for close. Both have certs."; +sinit_return_chkclose(suite) -> + []; +sinit_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {recv, DataSize}, {send, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_big_return_chkclose(doc) -> + "Client sends 50000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +cinit_big_return_chkclose(suite) -> + []; +cinit_big_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + %% Set {active, false} so that accept is passive to begin with. + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {sockopts, [{active, once}]}, % {active, once} here. + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_big_return_chkclose(doc) -> + "Server sends 50000 bytes to client, that receives them, sends them " + "back, and closes. Server waits for close. Both have certs."; +sinit_big_return_chkclose(suite) -> + []; +sinit_big_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {recv, DataSize}, {send, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_big_echo_chkclose(doc) -> + "Client sends 50000 bytes to server, that echoes them back " + "and closes. Client waits for close. Both have certs."; +cinit_big_echo_chkclose(suite) -> + []; +cinit_big_echo_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {echo, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_huge_echo_chkclose(doc) -> + "Client sends 500000 bytes to server, that echoes them back " + "and closes. Client waits for close. Both have certs."; +cinit_huge_echo_chkclose(suite) -> + []; +cinit_huge_echo_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 500000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {echo, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_big_echo_chkclose(doc) -> + "Server sends 50000 bytes to client, that echoes them back " + "and closes. Server waits for close. Both have certs."; +sinit_big_echo_chkclose(suite) -> + []; +sinit_big_echo_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {echo, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_few_echo_chkclose(X) -> cinit_many_echo_chkclose(X, 7). + +cinit_many_echo_chkclose(X) -> cinit_many_echo_chkclose(X, ?MANYCONNS). + +cinit_many_echo_chkclose(doc, _NConns) -> + "client send 10000 bytes to server, that echoes them back " + "and closes. Clients wait for close. All have certs."; +cinit_many_echo_chkclose(suite, _NConns) -> + []; +cinit_many_echo_chkclose(Config, NConns) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 10000, LPort = 3456, + Timeout = 80000, + + io:format("~w connections", [NConns]), + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {echo, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_cnocert(doc) -> + "Client sends 1000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Client has no cert, " + "but server has."; +cinit_cnocert(suite) -> + []; +cinit_cnocert(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3457, + Timeout = 40000, NConns = 1, + + ?line {ok, {_CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, once}]}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + + diff --git a/lib/ssl/test/old_ssl_dist_SUITE.erl b/lib/ssl/test/old_ssl_dist_SUITE.erl new file mode 100644 index 0000000000..56209c3530 --- /dev/null +++ b/lib/ssl/test/old_ssl_dist_SUITE.erl @@ -0,0 +1,595 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2007-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% + + +%%%------------------------------------------------------------------- +%%% File : ssl_dist_SUITE.erl +%%% Author : Rickard Green +%%% Description : Test that the Erlang distribution works over ssl. +%%% +%%% Created : 15 Nov 2007 by Rickard Green +%%%------------------------------------------------------------------- +-module(old_ssl_dist_SUITE). + +-include("test_server.hrl"). + +-define(DEFAULT_TIMETRAP_SECS, 240). + +-define(AWAIT_SLL_NODE_UP_TIMEOUT, 30000). + +-export([all/1]). +-export([init_per_suite/1, + end_per_suite/1, + init_per_testcase/2, + fin_per_testcase/2]). +-export([cnct2tstsrvr/1]). + +-export([basic/1]). + +-record(node_handle, {connection_handler, socket, name, nodename}). + +all(doc) -> + []; +all(suite) -> + [basic]. + +init_per_suite(Config) -> + add_ssl_opts_config(Config). + +end_per_suite(Config) -> + Config. + +init_per_testcase(Case, Config) when list(Config) -> + Dog = ?t:timetrap(?t:seconds(?DEFAULT_TIMETRAP_SECS)), + [{watchdog, Dog},{testcase, Case}|Config]. + +fin_per_testcase(_Case, Config) when list(Config) -> + Dog = ?config(watchdog, Config), + ?t:timetrap_cancel(Dog), + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% +%% Testcases %% +%% %% + +basic(doc) -> + ["Test that two nodes can connect via ssl distribution"]; +basic(suite) -> + []; +basic(Config) when is_list(Config) -> + ?line NH1 = start_ssl_node(Config), + ?line Node1 = NH1#node_handle.nodename, + ?line NH2 = start_ssl_node(Config), + ?line Node2 = NH2#node_handle.nodename, + + ?line pong = apply_on_ssl_node(NH1, fun () -> net_adm:ping(Node2) end), + + ?line [Node2] = apply_on_ssl_node(NH1, fun () -> nodes() end), + ?line [Node1] = apply_on_ssl_node(NH2, fun () -> nodes() end), + + %% The test_server node has the same cookie as the ssl nodes + %% but it should not be able to communicate with the ssl nodes + %% via the erlang distribution. + ?line pang = net_adm:ping(Node1), + ?line pang = net_adm:ping(Node2), + + + %% + %% Check that we are able to communicate over the erlang + %% distribution between the ssl nodes. + %% + ?line Ref = make_ref(), + ?line spawn(fun () -> + apply_on_ssl_node( + NH1, + fun () -> + tstsrvr_format("Hi from ~p!~n", + [node()]), + send_to_tstcntrl({Ref, self()}), + receive + {From, ping} -> + From ! {self(), pong} + end + end) + end), + ?line receive + {Ref, SslPid} -> + ?line ok = apply_on_ssl_node( + NH2, + fun () -> + tstsrvr_format("Hi from ~p!~n", + [node()]), + SslPid ! {self(), ping}, + receive + {SslPid, pong} -> + ok + end + end) + end, + + ?line stop_ssl_node(NH1), + ?line stop_ssl_node(NH2), + ?line success(Config). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% +%% Internal functions %% +%% %% + +%% +%% ssl_node side api +%% + +tstsrvr_format(Fmt, ArgList) -> + send_to_tstsrvr({format, Fmt, ArgList}). + +send_to_tstcntrl(Message) -> + send_to_tstsrvr({message, Message}). + + +%% +%% test_server side api +%% + +apply_on_ssl_node(Node, M, F, A) when atom(M), atom(F), list(A) -> + Ref = make_ref(), + send_to_ssl_node(Node, {apply, self(), Ref, M, F, A}), + receive + {Ref, Result} -> + Result + end. + +apply_on_ssl_node(Node, Fun) when is_function(Fun, 0) -> + Ref = make_ref(), + send_to_ssl_node(Node, {apply, self(), Ref, Fun}), + receive + {Ref, Result} -> + Result + end. + +stop_ssl_node(#node_handle{connection_handler = Handler, + socket = Socket, + name = Name}) -> + ?t:format("Trying to stop ssl node ~s.~n", [Name]), + Mon = erlang:monitor(process, Handler), + unlink(Handler), + case gen_tcp:send(Socket, term_to_binary(stop)) of + ok -> + receive + {'DOWN', Mon, process, Handler, Reason} -> + case Reason of + normal -> ok; + _ -> exit(Reason) + end + end; + Error -> + erlang:demonitor(Mon, [flush]), + exit(Error) + end. + +start_ssl_node(Config) -> + start_ssl_node(Config, ""). + +start_ssl_node(Config, XArgs) -> + Name = mk_node_name(Config), + SSL = ?config(ssl_opts, Config), + SSLDistOpts = setup_dist_opts(Name, ?config(priv_dir, Config)), + start_ssl_node_raw(Name, SSL ++ " " ++ SSLDistOpts ++ XArgs). + +start_ssl_node_raw(Name, Args) -> + {ok, LSock} = gen_tcp:listen(0, + [binary, {packet, 4}, {active, false}]), + {ok, ListenPort} = inet:port(LSock), + CmdLine = mk_node_cmdline(ListenPort, Name, Args), + ?t:format("Attempting to start ssl node ~s: ~s~n", [Name, CmdLine]), + case open_port({spawn, CmdLine}, []) of + Port when port(Port) -> + unlink(Port), + erlang:port_close(Port), + case await_ssl_node_up(Name, LSock) of + #node_handle{} = NodeHandle -> + ?t:format("Ssl node ~s started.~n", [Name]), + NodeName = list_to_atom(Name ++ "@" ++ host_name()), + NodeHandle#node_handle{nodename = NodeName}; + Error -> + exit({failed_to_start_node, Name, Error}) + end; + Error -> + exit({failed_to_start_node, Name, Error}) + end. + +%% +%% command line creation +%% + +host_name() -> + [$@ | Host] = lists:dropwhile(fun ($@) -> false; (_) -> true end, + atom_to_list(node())), + Host. + +mk_node_name(Config) -> + {A, B, C} = erlang:now(), + Case = ?config(testcase, Config), + atom_to_list(?MODULE) + ++ "_" + ++ atom_to_list(Case) + ++ "_" + ++ integer_to_list(A) + ++ "-" + ++ integer_to_list(B) + ++ "-" + ++ integer_to_list(C). + +mk_node_cmdline(ListenPort, Name, Args) -> + Static = "-detached -noinput", + Pa = filename:dirname(code:which(?MODULE)), + Prog = case catch init:get_argument(progname) of + {ok,[[P]]} -> P; + _ -> exit(no_progname_argument_found) + end, + NameSw = case net_kernel:longnames() of + false -> "-sname "; + _ -> "-name " + end, + {ok, Pwd} = file:get_cwd(), + Prog ++ " " + ++ Static ++ " " + ++ NameSw ++ " " ++ Name ++ " " + ++ "-pa " ++ Pa ++ " " + ++ "-run " ++ atom_to_list(?MODULE) ++ " cnct2tstsrvr " + ++ host_name() ++ " " + ++ integer_to_list(ListenPort) ++ " " + ++ Args ++ " " + ++ "-env ERL_CRASH_DUMP " ++ Pwd ++ "/erl_crash_dump." ++ Name ++ " " + ++ "-setcookie " ++ atom_to_list(erlang:get_cookie()). + +%% +%% Connection handler test_server side +%% + +await_ssl_node_up(Name, LSock) -> + case gen_tcp:accept(LSock, ?AWAIT_SLL_NODE_UP_TIMEOUT) of + timeout -> + gen_tcp:close(LSock), + ?t:format("Timeout waiting for ssl node ~s to come up~n", + [Name]), + timeout; + {ok, Socket} -> + gen_tcp:close(LSock), + case gen_tcp:recv(Socket, 0) of + {ok, Bin} -> + check_ssl_node_up(Socket, Name, Bin); + {error, closed} -> + gen_tcp:close(Socket), + exit({lost_connection_with_ssl_node_before_up, Name}) + end; + {error, Error} -> + gen_tcp:close(LSock), + exit({accept_failed, Error}) + end. + +check_ssl_node_up(Socket, Name, Bin) -> + case catch binary_to_term(Bin) of + {'EXIT', _} -> + gen_tcp:close(Socket), + exit({bad_data_received_from_ssl_node, Name, Bin}); + {ssl_node_up, NodeName} -> + case list_to_atom(Name++"@"++host_name()) of + NodeName -> + Parent = self(), + Go = make_ref(), + %% Spawn connection handler on test server side + Pid = spawn_link( + fun () -> + receive Go -> ok end, + tstsrvr_con_loop(Name, Socket, Parent) + end), + ok = gen_tcp:controlling_process(Socket, Pid), + Pid ! Go, + #node_handle{connection_handler = Pid, + socket = Socket, + name = Name}; + _ -> + exit({unexpected_ssl_node_connected, NodeName}) + end; + Msg -> + exit({unexpected_msg_instead_of_ssl_node_up, Name, Msg}) + end. + +send_to_ssl_node(#node_handle{connection_handler = Hndlr}, Term) -> + Hndlr ! {relay_to_ssl_node, term_to_binary(Term)}, + ok. + +tstsrvr_con_loop(Name, Socket, Parent) -> + inet:setopts(Socket,[{active,once}]), + receive + {relay_to_ssl_node, Data} when is_binary(Data) -> + case gen_tcp:send(Socket, Data) of + ok -> + ok; + _Error -> + gen_tcp:close(Socket), + exit({failed_to_relay_data_to_ssl_node, Name, Data}) + end; + {tcp, Socket, Bin} -> + case catch binary_to_term(Bin) of + {'EXIT', _} -> + gen_tcp:close(Socket), + exit({bad_data_received_from_ssl_node, Name, Bin}); + {format, FmtStr, ArgList} -> + ?t:format(FmtStr, ArgList); + {message, Msg} -> + Parent ! Msg; + {apply_res, To, Ref, Res} -> + To ! {Ref, Res}; + bye -> + ?t:format("Ssl node ~s stopped.~n", [Name]), + gen_tcp:close(Socket), + exit(normal); + Unknown -> + exit({unexpected_message_from_ssl_node, Name, Unknown}) + end; + {tcp_closed, Socket} -> + gen_tcp:close(Socket), + exit({lost_connection_with_ssl_node, Name}) + end, + tstsrvr_con_loop(Name, Socket, Parent). + +%% +%% Connection handler ssl_node side +%% + +% cnct2tstsrvr() is called via command line arg -run ... +cnct2tstsrvr([Host, Port]) when list(Host), list(Port) -> + %% Spawn connection handler on ssl node side + ConnHandler + = spawn(fun () -> + case catch gen_tcp:connect(Host, + list_to_integer(Port), + [binary, + {packet, 4}, + {active, false}]) of + {ok, Socket} -> + notify_ssl_node_up(Socket), + ets:new(test_server_info, + [set, + public, + named_table, + {keypos, 1}]), + ets:insert(test_server_info, + {test_server_handler, self()}), + ssl_node_con_loop(Socket); + _Error -> + halt("Failed to connect to test server") + end + end), + spawn(fun () -> + Mon = erlang:monitor(process, ConnHandler), + receive + {'DOWN', Mon, process, ConnHandler, Reason} -> + receive after 1000 -> ok end, + halt("test server connection handler terminated: " + ++ + lists:flatten(io_lib:format("~p", [Reason]))) + end + end). + +notify_ssl_node_up(Socket) -> + case catch gen_tcp:send(Socket, + term_to_binary({ssl_node_up, node()})) of + ok -> ok; + _ -> halt("Failed to notify test server that I'm up") + end. + +send_to_tstsrvr(Term) -> + case catch ets:lookup_element(test_server_info, test_server_handler, 2) of + Hndlr when pid(Hndlr) -> + Hndlr ! {relay_to_test_server, term_to_binary(Term)}, ok; + _ -> + receive after 200 -> ok end, + send_to_tstsrvr(Term) + end. + +ssl_node_con_loop(Socket) -> + inet:setopts(Socket,[{active,once}]), + receive + {relay_to_test_server, Data} when is_binary(Data) -> + case gen_tcp:send(Socket, Data) of + ok -> + ok; + _Error -> + gen_tcp:close(Socket), + halt("Failed to relay data to test server") + end; + {tcp, Socket, Bin} -> + case catch binary_to_term(Bin) of + {'EXIT', _} -> + gen_tcp:close(Socket), + halt("test server sent me bad data"); + {apply, From, Ref, M, F, A} -> + spawn_link( + fun () -> + send_to_tstsrvr({apply_res, + From, + Ref, + (catch apply(M, F, A))}) + end); + {apply, From, Ref, Fun} -> + spawn_link(fun () -> + send_to_tstsrvr({apply_res, + From, + Ref, + (catch Fun())}) + end); + stop -> + gen_tcp:send(Socket, term_to_binary(bye)), + gen_tcp:close(Socket), + init:stop(), + receive after infinity -> ok end; + _Unknown -> + halt("test server sent me an unexpected message") + end; + {tcp_closed, Socket} -> + halt("Lost connection to test server") + end, + ssl_node_con_loop(Socket). + +%% +%% Setup ssl dist info +%% + +rand_bin(N) -> + rand_bin(N, []). + +rand_bin(0, Acc) -> + Acc; +rand_bin(N, Acc) -> + rand_bin(N-1, [random:uniform(256)-1|Acc]). + +make_randfile(Dir) -> + {ok, IoDev} = file:open(filename:join([Dir, "RAND"]), [write]), + {A, B, C} = erlang:now(), + random:seed(A, B, C), + ok = file:write(IoDev, rand_bin(1024)), + file:close(IoDev). + +append_files(FileNames, ResultFileName) -> + {ok, ResultFile} = file:open(ResultFileName, [write]), + do_append_files(FileNames, ResultFile). + +do_append_files([], RF) -> + ok = file:close(RF); +do_append_files([F|Fs], RF) -> + {ok, Data} = file:read_file(F), + ok = file:write(RF, Data), + do_append_files(Fs, RF). + +setup_dist_opts(Name, PrivDir) -> + NodeDir = filename:join([PrivDir, Name]), + RGenDir = filename:join([NodeDir, "rand_gen"]), + ok = file:make_dir(NodeDir), + ok = file:make_dir(RGenDir), + make_randfile(RGenDir), + make_certs:all(RGenDir, NodeDir), + SDir = filename:join([NodeDir, "server"]), + SC = filename:join([SDir, "cert.pem"]), + SK = filename:join([SDir, "key.pem"]), + SKC = filename:join([SDir, "keycert.pem"]), + append_files([SK, SC], SKC), + CDir = filename:join([NodeDir, "client"]), + CC = filename:join([CDir, "cert.pem"]), + CK = filename:join([CDir, "key.pem"]), + CKC = filename:join([CDir, "keycert.pem"]), + append_files([CK, CC], CKC), + "-proto_dist inet_ssl " + ++ "-ssl_dist_opt server_certfile " ++ SKC ++ " " + ++ "-ssl_dist_opt client_certfile " ++ CKC ++ " " +.% ++ "-ssl_dist_opt verify 1 depth 1". + +%% +%% Start scripts etc... +%% + +add_ssl_opts_config(Config) -> + %% + %% Start with boot scripts if on an installed system; otherwise, + %% just point out ssl ebin with -pa. + %% + try + Dir = ?config(priv_dir, Config), + LibDir = code:lib_dir(), + Apps = application:which_applications(), + {value, {stdlib, _, STDL_VSN}} = lists:keysearch(stdlib, 1, Apps), + {value, {kernel, _, KRNL_VSN}} = lists:keysearch(kernel, 1, Apps), + StdlDir = filename:join([LibDir, "stdlib-" ++ STDL_VSN]), + KrnlDir = filename:join([LibDir, "kernel-" ++ KRNL_VSN]), + {ok, _} = file:read_file_info(StdlDir), + {ok, _} = file:read_file_info(KrnlDir), + SSL_VSN = case lists:keysearch(ssl, 1, Apps) of + {value, {ssl, _, VSN}} -> + VSN; + _ -> + application:start(ssl), + try + {value, + {ssl, + _, + VSN}} = lists:keysearch(ssl, + 1, + application:which_applications()), + VSN + after + application:stop(ssl) + end + end, + SslDir = filename:join([LibDir, "ssl-" ++ SSL_VSN]), + {ok, _} = file:read_file_info(SslDir), + %% We are using an installed otp system, create the boot script. + Script = filename:join(Dir, atom_to_list(?MODULE)), + {ok, RelFile} = file:open(Script ++ ".rel", [write]), + io:format(RelFile, + "{release, ~n" + " {\"SSL distribution test release\", \"~s\"},~n" + " {erts, \"~s\"},~n" + " [{kernel, \"~s\"},~n" + " {stdlib, \"~s\"},~n" + " {ssl, \"~s\"}]}.~n", + [case catch erlang:system_info(otp_release) of + {'EXIT', _} -> "R11B"; + Rel -> Rel + end, + erlang:system_info(version), + KRNL_VSN, + STDL_VSN, + SSL_VSN]), + ok = file:close(RelFile), + ok = systools:make_script(Script, []), + [{ssl_opts, "-boot " ++ Script} | Config] + catch + _:_ -> + [{ssl_opts, "-pa " ++ filename:dirname(code:which(ssl))} + | add_comment_config( + "Bootscript wasn't used since the test wasn't run on an " + "installed OTP system.", + Config)] + end. + +%% +%% Add common comments to config +%% + +add_comment_config(Comment, []) -> + [{comment, Comment}]; +add_comment_config(Comment, [{comment, OldComment} | Cs]) -> + [{comment, Comment ++ " " ++ OldComment} | Cs]; +add_comment_config(Comment, [C|Cs]) -> + [C|add_comment_config(Comment, Cs)]. + +%% +%% Call when test case success +%% + +success(Config) -> + case lists:keysearch(comment, 1, Config) of + {value, {comment, _} = Res} -> Res; + _ -> ok + end. diff --git a/lib/ssl/test/old_ssl_misc_SUITE.erl b/lib/ssl/test/old_ssl_misc_SUITE.erl new file mode 100644 index 0000000000..55d1b71025 --- /dev/null +++ b/lib/ssl/test/old_ssl_misc_SUITE.erl @@ -0,0 +1,105 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2003-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(old_ssl_misc_SUITE). + +-export([all/1, + init_per_testcase/2, + fin_per_testcase/2, + config/1, + finish/1, + seed/1, + app/1 + ]). + +-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7, + test_server_only/6]). +-include("test_server.hrl"). +-include("ssl_test_MACHINE.hrl"). + +-define(MANYCONNS, 5). + +init_per_testcase(_Case, Config) -> + WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT), + [{watchdog, WatchDog}| Config]. + +fin_per_testcase(_Case, Config) -> + WatchDog = ?config(watchdog, Config), + test_server:timetrap_cancel(WatchDog). + +all(doc) -> + "Test of misc in ssl.erl interface."; +all(suite) -> + {conf, + config, + [seed, app], + finish + }. + +config(doc) -> + "Want to se what Config contains."; +config(suite) -> + []; +config(Config) -> + io:format("Config: ~p~n", [Config]), + + %% Check if SSL exists. If this case fails, all other cases are skipped + case ssl:start() of + ok -> ssl:stop(); + {error, {already_started, _}} -> ssl:stop(); + Error -> ?t:fail({failed_starting_ssl,Error}) + end, + Config. + +finish(doc) -> + "This test case has no mission other than closing the conf case"; +finish(suite) -> + []; +finish(Config) -> + Config. + +seed(doc) -> + "Test that ssl:seed/1 works."; +seed(suite) -> + []; +seed(Config) when list(Config) -> + process_flag(trap_exit, true), + LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {_, SsslOpts}} = mk_ssl_cert_opts(Config), + + LCmds = [{seed, "tjosan"}, + {sockopts, [{backlog, NConns}, {active, once}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ?line test_server_only(NConns, LCmds, [], Timeout, ?MODULE, + Config). + +app(doc) -> + "Test that the ssl app file is ok"; +app(suite) -> + []; +app(Config) when list(Config) -> + ?line ok = test_server:app_test(ssl). + + diff --git a/lib/ssl/test/old_ssl_passive_SUITE.erl b/lib/ssl/test/old_ssl_passive_SUITE.erl new file mode 100644 index 0000000000..4cb8c1f0cd --- /dev/null +++ b/lib/ssl/test/old_ssl_passive_SUITE.erl @@ -0,0 +1,374 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(old_ssl_passive_SUITE). + +-export([all/1, + init_per_testcase/2, + fin_per_testcase/2, + config/1, + finish/1, + server_accept_timeout/1, + cinit_return_chkclose/1, + sinit_return_chkclose/1, + cinit_big_return_chkclose/1, + sinit_big_return_chkclose/1, + cinit_big_echo_chkclose/1, + sinit_big_echo_chkclose/1, + cinit_few_echo_chkclose/1, + cinit_many_echo_chkclose/1, + cinit_cnocert/1 + ]). + +-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7, + test_server_only/6]). + +-include("test_server.hrl"). +-include("ssl_test_MACHINE.hrl"). + +-define(MANYCONNS, ssl_test_MACHINE:many_conns()). + +init_per_testcase(_Case, Config) -> + WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT), + [{watchdog, WatchDog}| Config]. + +fin_per_testcase(_Case, Config) -> + WatchDog = ?config(watchdog, Config), + test_server:timetrap_cancel(WatchDog). + +all(doc) -> + "Test of ssl.erl interface in passive mode."; +all(suite) -> + {conf, + config, + [server_accept_timeout, + cinit_return_chkclose, + sinit_return_chkclose, + cinit_big_return_chkclose, + sinit_big_return_chkclose, + cinit_big_echo_chkclose, + sinit_big_echo_chkclose, + cinit_few_echo_chkclose, + cinit_many_echo_chkclose, + cinit_cnocert], + finish}. + +config(doc) -> + "Want to se what Config contains."; +config(suite) -> + []; +config(Config) -> + io:format("Config: ~p~n", [Config]), + + %% Check if SSL exists. If this case fails, all other cases are skipped + case ssl:start() of + ok -> ssl:stop(); + {error, {already_started, _}} -> ssl:stop(); + Error -> ?t:fail({failed_starting_ssl,Error}) + end, + Config. + +finish(doc) -> + "This test case has no mission other than closing the conf case"; +finish(suite) -> + []; +finish(Config) -> + Config. + +server_accept_timeout(doc) -> + "Server has one pending accept with timeout. Checks that return " + "value is {error, timeout}."; +server_accept_timeout(suite) -> + []; +server_accept_timeout(Config) when list(Config) -> + process_flag(trap_exit, true), + LPort = 3456, + Timeout = 40000, NConns = 1, + AccTimeout = 3000, + + ?line {ok, {_, SsslOpts}} = mk_ssl_cert_opts(Config), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, AccTimeout}, + accept_timeout], + ?line test_server_only(NConns, LCmds, ACmds, Timeout, ?MODULE, Config). + +cinit_return_chkclose(doc) -> + "Client sends 1000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +cinit_return_chkclose(suite) -> + []; +cinit_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, false}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_return_chkclose(doc) -> + "Server sends 1000 bytes to client, that receives them, sends them " + "back, and closes. Server waits for close. Both have certs."; +sinit_return_chkclose(suite) -> + []; +sinit_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, false}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {recv, DataSize}, {send, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_big_return_chkclose(doc) -> + "Client sends 50000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +cinit_big_return_chkclose(suite) -> + []; +cinit_big_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, false}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_big_return_chkclose(doc) -> + "Server sends 50000 bytes to client, that receives them, sends them " + "back, and closes. Server waits for close. Both have certs."; +sinit_big_return_chkclose(suite) -> + []; +sinit_big_return_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, false}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {recv, DataSize}, {send, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_big_echo_chkclose(doc) -> + "Client sends 50000 bytes to server, that echoes them back " + "and closes. Client waits for close. Both have certs."; +cinit_big_echo_chkclose(suite) -> + []; +cinit_big_echo_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {echo, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, false}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +sinit_big_echo_chkclose(doc) -> + "Server sends 50000 bytes to client, that echoes them back " + "and closes. Server waits for close. Both have certs."; +sinit_big_echo_chkclose(suite) -> + []; +sinit_big_echo_chkclose(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 50000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {send, DataSize}, {recv, DataSize}, + await_close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, false}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {echo, DataSize}, + close], + + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + + +cinit_few_echo_chkclose(X) -> cinit_many_echo_chkclose(X, 7). + +cinit_many_echo_chkclose(X) -> cinit_many_echo_chkclose(X, ?MANYCONNS). + +cinit_many_echo_chkclose(doc, _NConns) -> + "clients send 10000 bytes to server, that echoes them back " + "and closes. Clients wait for close. All have certs."; +cinit_many_echo_chkclose(suite, _NConns) -> + []; +cinit_many_echo_chkclose(Config, NConns) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 10000, LPort = 3456, + Timeout = 80000, + + io:format("~w connections", [NConns]), + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {echo, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, false}]}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + +cinit_cnocert(doc) -> + "Client sends 1000 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Client has no cert, " + "but server has."; +cinit_cnocert(suite) -> + []; +cinit_cnocert(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3457, + Timeout = 40000, NConns = 1, + + ?line {ok, {_CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}, {active, false}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, {send, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sockopts, [{active, false}]}, + {connect, {Host, LPort}}, + {send, DataSize}, {recv, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE, + Config). + diff --git a/lib/ssl/test/old_ssl_peer_cert_SUITE.erl b/lib/ssl/test/old_ssl_peer_cert_SUITE.erl new file mode 100644 index 0000000000..f0b8db2607 --- /dev/null +++ b/lib/ssl/test/old_ssl_peer_cert_SUITE.erl @@ -0,0 +1,180 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2003-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(old_ssl_peer_cert_SUITE). + +-export([all/1, + init_per_testcase/2, + fin_per_testcase/2, + config/1, + finish/1, + cinit_plain/1, + cinit_both_verify/1, + cinit_cnocert/1 + ]). + +-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7, + test_server_only/6]). +-include("test_server.hrl"). +-include("ssl_test_MACHINE.hrl"). + + +init_per_testcase(_Case, Config) -> + WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT), + [{watchdog, WatchDog}| Config]. + +fin_per_testcase(_Case, Config) -> + WatchDog = ?config(watchdog, Config), + test_server:timetrap_cancel(WatchDog). + +all(doc) -> + "Test of ssl verification and peer certificate retrieval."; +all(suite) -> + {conf, + config, + [cinit_plain, + cinit_both_verify, + cinit_cnocert], + finish}. + +config(doc) -> + "Want to se what Config contains."; +config(suite) -> + []; +config(Config) -> + io:format("Config: ~p~n", [Config]), + + %% Check if SSL exists. If this case fails, all other cases are skipped + case ssl:start() of + ok -> ssl:stop(); + {error, {already_started, _}} -> ssl:stop(); + Error -> ?t:fail({failed_starting_ssl,Error}) + end, + Config. + +finish(doc) -> + "This test case has no mission other than closing the conf case"; +finish(suite) -> + []; +finish(Config) -> + Config. + +cinit_plain(doc) -> + "Server closes after accept, Client waits for close. Both have certs " + "but both use the defaults for verify and depth, but still tries " + "to retreive each others certificates."; +cinit_plain(suite) -> + []; +cinit_plain(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config), + + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + nopeercert, + {recv, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + peercert, + {send, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, + ?MODULE, Config). + +cinit_both_verify(doc) -> + "Server closes after accept, Client waits for close. Both have certs " + "and both verify each other."; +cinit_both_verify(suite) -> + []; +cinit_both_verify(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts0, SsslOpts0}} = mk_ssl_cert_opts(Config), + ?line CsslOpts = [{verify, 2}, {depth, 2} | CsslOpts0], + ?line SsslOpts = [{verify, 2}, {depth, 3} | SsslOpts0], + + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + peercert, + {recv, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + peercert, + {send, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, + ?MODULE, Config). + +cinit_cnocert(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close."; +cinit_cnocert(suite) -> + []; +cinit_cnocert(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3457, + Timeout = 40000, NConns = 1, + + ?line {ok, {_, SsslOpts0}} = mk_ssl_cert_opts(Config), + ?line SsslOpts = [{verify, 0}, {depth, 2} | SsslOpts0], + + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {connect, {Host, LPort}}, + peercert, + {send, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, + ?MODULE, Config). + + diff --git a/lib/ssl/test/old_ssl_protocol_SUITE.erl b/lib/ssl/test/old_ssl_protocol_SUITE.erl new file mode 100644 index 0000000000..7bde5d6749 --- /dev/null +++ b/lib/ssl/test/old_ssl_protocol_SUITE.erl @@ -0,0 +1,169 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(old_ssl_protocol_SUITE). + +-export([all/1, init_per_testcase/2, fin_per_testcase/2, config/1, + finish/1, sslv2/1, sslv3/1, tlsv1/1, sslv2_sslv3/1, + sslv2_tlsv1/1, sslv3_tlsv1/1, sslv2_sslv3_tlsv1/1]). + +-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7, + test_server_only/6]). +-include("test_server.hrl"). +-include("ssl_test_MACHINE.hrl"). + + +init_per_testcase(_Case, Config) -> + WatchDog = test_server:timetrap(?DEFAULT_TIMEOUT), + [{watchdog, WatchDog}| Config]. + +fin_per_testcase(_Case, Config) -> + WatchDog = ?config(watchdog, Config), + test_server:timetrap_cancel(WatchDog). + +all(doc) -> + "Test of configuration protocol_version."; +all(suite) -> + {conf, + config, + [sslv2, sslv3, tlsv1, sslv2_sslv3, sslv2_tlsv1, sslv3_tlsv1, + sslv2_sslv3_tlsv1], + finish}. + +config(doc) -> + "Want to se what Config contains."; +config(suite) -> + []; +config(Config) -> + io:format("Config: ~p~n", [Config]), + + %% Check if SSL exists. If this case fails, all other cases are skipped + case ssl:start() of + ok -> ssl:stop(); + {error, {already_started, _}} -> ssl:stop(); + Error -> ?t:fail({failed_starting_ssl,Error}) + end, + Config. + +finish(doc) -> + "This test case has no other purpose than closing the conf case."; +finish(suite) -> + []; +finish(Config) -> + Config. + +%%%%% + +sslv2(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close. " + "Client and server choose SSLv2."; +sslv2(suite) -> + []; +sslv2(Config) when list(Config) -> + do_run_test(Config, [sslv2]). + +sslv3(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close. " + "Client and server choose SSLv3."; +sslv3(suite) -> + []; +sslv3(Config) when list(Config) -> + do_run_test(Config, [sslv3]). + +tlsv1(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close. " + "Client and server choose TLSv1."; +tlsv1(suite) -> + []; +tlsv1(Config) when list(Config) -> + do_run_test(Config, [tlsv1]). + +sslv2_sslv3(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close. " + "Client and server choose between SSLv2 and SSLv3."; +sslv2_sslv3(suite) -> + []; +sslv2_sslv3(Config) when list(Config) -> + do_run_test(Config, [sslv2, sslv3]). + +sslv2_tlsv1(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close. " + "Client and server choose between SSLv2 and TLSv1."; +sslv2_tlsv1(suite) -> + []; +sslv2_tlsv1(Config) when list(Config) -> + do_run_test(Config, [sslv2, tlsv1]). + +sslv3_tlsv1(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close. " + "Client and server choose between SSLv3 and TLSv1."; +sslv3_tlsv1(suite) -> + []; +sslv3_tlsv1(Config) when list(Config) -> + do_run_test(Config, [sslv3, tlsv1]). + +sslv2_sslv3_tlsv1(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close. " + "Client and server choose between SSLv2, SSLv3, and TLSv1."; +sslv2_sslv3_tlsv1(suite) -> + []; +sslv2_sslv3_tlsv1(Config) when list(Config) -> + do_run_test(Config, [sslv2, sslv3, tlsv1]). + +%%%% + +do_run_test(Config0, Protocols) -> + process_flag(trap_exit, true), + LPort = 3456, + Timeout = 40000, NConns = 1, + DataSize = 10, + + ?line {ok, {_, SsslOpts0}} = mk_ssl_cert_opts(Config0), + ?line SsslOpts = [{verify, 0}, {depth, 2} | SsslOpts0], + + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + connection_info, + {recv, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {connect, {Host, LPort}}, + connection_info, + {send, DataSize}, + await_close], + Config1 = [{env, [{protocol_version, Protocols}]} | Config0], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, + ?MODULE, Config1). + + diff --git a/lib/ssl/test/old_ssl_verify_SUITE.erl b/lib/ssl/test/old_ssl_verify_SUITE.erl new file mode 100644 index 0000000000..5db964526f --- /dev/null +++ b/lib/ssl/test/old_ssl_verify_SUITE.erl @@ -0,0 +1,141 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(old_ssl_verify_SUITE). + +-export([all/1, + init_per_testcase/2, + fin_per_testcase/2, + config/1, + finish/1, + cinit_both_verify/1, + cinit_cnocert/1 + ]). + +-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7, + test_server_only/6]). +-include("test_server.hrl"). +-include("ssl_test_MACHINE.hrl"). + + +init_per_testcase(_Case, Config) -> + WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT), + [{watchdog, WatchDog}| Config]. + +fin_per_testcase(_Case, Config) -> + WatchDog = ?config(watchdog, Config), + test_server:timetrap_cancel(WatchDog). + +all(doc) -> + "Test of ssl.erl interface in active mode."; +all(suite) -> + {conf, + config, + [cinit_both_verify, + cinit_cnocert], + finish}. + +config(doc) -> + "Want to se what Config contains."; +config(suite) -> + []; +config(Config) -> + io:format("Config: ~p~n", [Config]), + + %% Check if SSL exists. If this case fails, all other cases are skipped + case ssl:start() of + ok -> ssl:stop(); + {error, {already_started, _}} -> ssl:stop(); + Error -> ?t:fail({failed_starting_ssl,Error}) + end, + Config. + +finish(doc) -> + "This test case has no mission other than closing the conf case"; +finish(suite) -> + []; +finish(Config) -> + Config. + +cinit_both_verify(doc) -> + "Server closes after accept, Client waits for close. Both have certs " + "and both verify each other."; +cinit_both_verify(suite) -> + []; +cinit_both_verify(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3456, + Timeout = 40000, NConns = 1, + + ?line {ok, {CsslOpts0, SsslOpts0}} = mk_ssl_cert_opts(Config), + ?line CsslOpts = [{verify, 2}, {depth, 2} | CsslOpts0], + ?line SsslOpts = [{verify, 2}, {depth, 3} | SsslOpts0], + + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {sslopts, CsslOpts}, + {connect, {Host, LPort}}, + {send, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, + ?MODULE, Config). + +cinit_cnocert(doc) -> + "Client has no cert. Nor the client, nor the server is verifying its " + "peer. Server closes, client waits for close."; +cinit_cnocert(suite) -> + []; +cinit_cnocert(Config) when list(Config) -> + process_flag(trap_exit, true), + DataSize = 1000, LPort = 3457, + Timeout = 40000, NConns = 1, + + ?line {ok, {_, SsslOpts0}} = mk_ssl_cert_opts(Config), + ?line SsslOpts = [{verify, 0}, {depth, 2} | SsslOpts0], + + ?line {ok, Host} = inet:gethostname(), + + LCmds = [{sockopts, [{backlog, NConns}]}, + {sslopts, SsslOpts}, + {listen, LPort}, + wait_sync, + lclose], + ACmds = [{timeout, Timeout}, + accept, + {recv, DataSize}, + close], + CCmds = [{timeout, Timeout}, + {connect, {Host, LPort}}, + {send, DataSize}, + await_close], + ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, + ?MODULE, Config). + + diff --git a/lib/ssl/test/old_transport_accept_SUITE.erl b/lib/ssl/test/old_transport_accept_SUITE.erl new file mode 100644 index 0000000000..4bb09cee19 --- /dev/null +++ b/lib/ssl/test/old_transport_accept_SUITE.erl @@ -0,0 +1,238 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2007-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(old_transport_accept_SUITE). +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +%% Default timetrap timeout (set in init_per_testcase). +-define(default_timeout, ?t:minutes(1)). +-define(application, ssh). + +-export([all/1, + init_per_testcase/2, + fin_per_testcase/2, + config/1, + echo_once/1, + echo_twice/1, + close_before_ssl_accept/1, + server/5, + tolerant_server/5, + client/5 + ]). + +init_per_testcase(_Case, Config) -> + WatchDog = ssl_test_lib:timetrap(?default_timeout), + [{watchdog, WatchDog}, {protomod, gen_tcp}, {serialize_accept, true}| + Config]. + +fin_per_testcase(_Case, Config) -> + WatchDog = ?config(watchdog, Config), + test_server:timetrap_cancel(WatchDog). + +all(doc) -> + "Test transport_accept and ssl_accept"; +all(suite) -> + [config, echo_once, echo_twice, close_before_ssl_accept]. + +config(doc) -> + "Want to se what Config contains."; +config(suite) -> + []; +config(Config) -> + io:format("Config: ~p~n", [Config]), + ok. + +echo_once(doc) -> + "Client sends 256 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +echo_once(suite) -> + []; +echo_once(Config) when list(Config) -> + process_flag(trap_exit, true), + LPort = 3456, + {ok, Host} = inet:gethostname(), + {ok, {COpts, SOpts}} = ssl_test_MACHINE:mk_ssl_cert_opts(Config), + N = 1, + Msg = lists:seq(0, 255), + Self = self(), + Params = "-pa " ++ filename:dirname(code:which(?MODULE)), + Node = start_node(server, Params), + CNode = start_node(client, Params), + Server = spawn_link(Node, ?MODULE, server, [Self, LPort, SOpts, Msg, N]), + Client = spawn_link(Node, ?MODULE, client, [Host, LPort, COpts, Msg, N]), + ok = receive + {Server, listening} -> + Client ! {Server, listening}, + ok; + E -> + io:format("bad receive (1) ~p\n", [E]), + E + end, + receive + {Server, done} -> + ok + end, + test_server:stop_node(Node), + test_server:stop_node(CNode). + +close_before_ssl_accept(doc) -> + "Client sends 256 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +close_before_ssl_accept(suite) -> + []; +close_before_ssl_accept(Config) when list(Config) -> + process_flag(trap_exit, true), + LPort = 3456, + {ok, Host} = inet:gethostname(), + {ok, {COpts, SOpts}} = ssl_test_MACHINE:mk_ssl_cert_opts(Config), + Msg = lists:seq(0, 255), + Self = self(), + Params = "-pa " ++ filename:dirname(code:which(?MODULE)), + Node = start_node(server, Params), + CNode = start_node(client, Params), + Server = spawn_link(Node, ?MODULE, tolerant_server, + [Self, LPort, SOpts, Msg, 2]), + Client = spawn_link(Node, ?MODULE, client, + [Host, LPort, COpts, Msg, 1]), + ok = receive + {Server, listening} -> + {ok, S} = gen_tcp:connect(Host, LPort, []), + gen_tcp:close(S), + Client ! {Server, listening}, + ok; + E -> + io:format("bad receive (1) ~p\n", [E]), + E + end, + receive + {Server, done} -> + ok + end, + test_server:stop_node(Node), + test_server:stop_node(CNode). + +client(Host, LPort, COpts, Msg, N) -> + ok = receive + {_Server, listening} -> + ok; + E -> + io:format("bad receive (2) ~p\n", [E]), + E + end, + Opts = COpts ++ [{packet, raw}, {active, false}], + app(), + lists:foreach(fun(_) -> + {ok, S} = ssl:connect(Host, LPort, Opts), + ssl:send(S, Msg), + {ok, Msg} = ssl:recv(S, length(Msg)), + ssl:close(S) + end, lists:seq(1, N)). + +echo_twice(doc) -> + "Two clients sends 256 bytes to server, that receives them, sends them " + "back, and closes. Client waits for close. Both have certs."; +echo_twice(suite) -> + []; +echo_twice(Config) when list(Config) -> + process_flag(trap_exit, true), + LPort = 3456, + {ok, Host} = inet:gethostname(), + {ok, {COpts, SOpts}} = ssl_test_MACHINE:mk_ssl_cert_opts(Config), + N = 2, + Msg = lists:seq(0, 255), + Self = self(), + Params = "-pa " ++ filename:dirname(code:which(?MODULE)), + Node = start_node(server, Params), + CNode = start_node(client, Params), + Server = spawn_link(Node, ?MODULE, server, + [Self, LPort, SOpts, Msg, N]), + Client = spawn_link(Node, ?MODULE, client, + [Host, LPort, COpts, Msg, N]), + ok = receive + {Server, listening} -> + Client ! {Server, listening}, + ok; + E -> + io:format("bad receive (3) ~p\n", [E]), + E + end, + receive + {Server, done} -> + ok + end, + test_server:stop_node(Node), + test_server:stop_node(CNode). + +server(Client, Port, SOpts, Msg, N) -> + app(), + process_flag(trap_exit, true), + Opts = SOpts ++ [{packet, raw}, {active, false}], + {ok, LSock} = ssl:listen(Port, Opts), + Client ! {self(), listening}, + server_loop(Client, LSock, Msg, N). + +server_loop(Client, _, _, 0) -> + Client ! {self(), done}; +server_loop(Client, LSock, Msg, N) -> + {ok, S} = ssl:transport_accept(LSock), + ok = ssl:ssl_accept(S), + %% P = ssl:controlling_process(S, Proxy), + {ok, Msg} = ssl:recv(S, length(Msg)), + ok = ssl:send(S, Msg), + ok = ssl:close(S), + server_loop(Client, LSock, Msg, N-1). + +tolerant_server(Client, Port, SOpts, Msg, N) -> + app(), + process_flag(trap_exit, true), + Opts = SOpts ++ [{packet, raw}, {active, false}], + {ok, LSock} = ssl:listen(Port, Opts), + Client ! {self(), listening}, + tolerant_server_loop(Client, LSock, Msg, N). + +tolerant_server_loop(Client, _, _, 0) -> + Client ! {self(), done}; +tolerant_server_loop(Client, LSock, Msg, N) -> + {ok, S} = ssl:transport_accept(LSock), + case ssl:ssl_accept(S) of + ok -> + %% P = ssl:controlling_process(S, Proxy), + {ok, Msg} = ssl:recv(S, length(Msg)), + ok = ssl:send(S, Msg), + ok = ssl:close(S); + E -> + io:format("ssl_accept error: ~p\n", [E]) + end, + tolerant_server_loop(Client, LSock, Msg, N-1). + +app() -> + case application:get_application(ssl) of + undefined -> + application:start(ssl); + _ -> + ok + end. + +start_node(Kind, Params) -> + S = atom_to_list(?MODULE)++"_" ++ atom_to_list(Kind), + {ok, Node} = test_server:start_node(list_to_atom(S), slave, [{args, Params}]), + Node. + diff --git a/lib/ssl/test/ssl.cover b/lib/ssl/test/ssl.cover new file mode 100644 index 0000000000..138bf96b9d --- /dev/null +++ b/lib/ssl/test/ssl.cover @@ -0,0 +1,7 @@ +{exclude, [ssl_pkix_oid, + 'PKIX1Algorithms88', + 'PKIX1Explicit88', + 'PKIX1Implicit88', + 'PKIXAttributeCertificate', + 'SSL-PKIX']}. + diff --git a/lib/ssl/test/ssl.spec b/lib/ssl/test/ssl.spec new file mode 100644 index 0000000000..6ef4fb73db --- /dev/null +++ b/lib/ssl/test/ssl.spec @@ -0,0 +1 @@ +{topcase, {dir, "../ssl_test"}}. diff --git a/lib/ssl/test/ssl_basic_SUITE.erl b/lib/ssl/test/ssl_basic_SUITE.erl new file mode 100644 index 0000000000..2b247532ee --- /dev/null +++ b/lib/ssl/test/ssl_basic_SUITE.erl @@ -0,0 +1,2075 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2007-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% + +-module(ssl_basic_SUITE). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +-define('24H_in_sec', 86400). +-define(TIMEOUT, 60000). +-define(EXPIRE, 10). + +-behaviour(ssl_session_cache_api). + +%% For the session cache tests +-export([init/0, terminate/1, lookup/2, update/3, + delete/2, foldl/3, select_session/2]). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initialization before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + crypto:start(), + ssl:start(), + Result = + (catch make_certs:all(?config(data_dir, Config), + ?config(priv_dir, Config))), + test_server:format("Make certs ~p~n", [Result]), + ssl_test_lib:cert_options(Config). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ssl:stop(), + crypto:stop(). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initialization before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initialization before each test case +%%-------------------------------------------------------------------- +init_per_testcase(session_cache_process_list, Config) -> + init_customized_session_cache(Config); + +init_per_testcase(session_cache_process_mnesia, Config) -> + mnesia:start(), + init_customized_session_cache(Config); + +init_per_testcase(reuse_session_expired, Config0) -> + Config = lists:keydelete(watchdog, 1, Config0), + Dog = ssl_test_lib:timetrap(?EXPIRE * 1000 * 5), + ssl:stop(), + application:load(ssl), + application:set_env(ssl, session_lifetime, ?EXPIRE), + ssl:start(), + [{watchdog, Dog} | Config]; + +init_per_testcase(_TestCase, Config0) -> + Config = lists:keydelete(watchdog, 1, Config0), + Dog = test_server:timetrap(?TIMEOUT), + [{watchdog, Dog} | Config]. + +init_customized_session_cache(Config0) -> + Config = lists:keydelete(watchdog, 1, Config0), + Dog = test_server:timetrap(?TIMEOUT), + ssl:stop(), + application:load(ssl), + application:set_env(ssl, session_cb, ?MODULE), + ssl:start(), + [{watchdog, Dog} | Config]. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(session_cache_process_list, Config) -> + application:unset_env(ssl, session_cb), + end_per_testcase(default_action, Config); +end_per_testcase(session_cache_process_mnesia, Config) -> + application:unset_env(ssl, session_cb), + mnesia:stop(), + end_per_testcase(default_action, Config); +end_per_testcase(reuse_session_expired, Config) -> + application:unset_env(ssl, session_lifetime), + end_per_testcase(default_action, Config); +end_per_testcase(_TestCase, Config) -> + Dog = ?config(watchdog, Config), + case Dog of + undefined -> + ok; + _ -> + test_server:timetrap_cancel(Dog) + end. + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test the basic ssl functionality"]; + +all(suite) -> + [app, connection_info, controlling_process, controller_dies, + peercert, connect_dist, + peername, sockname, socket_options, versions, cipher_suites, upgrade, + upgrade_with_timeout, + ipv6, ekeyfile, ecertfile, ecacertfile, eoptions, shutdown, + shutdown_write, shutdown_both, shutdown_error, ciphers, + send_close, + server_verify_peer_passive, + server_verify_peer_active, server_verify_peer_active_once, + server_verify_none_passive, server_verify_none_active, + server_verify_none_active_once, + server_verify_no_cacerts, client_verify_none_passive, + client_verify_none_active, client_verify_none_active_once + %%, session_cache_process_list, session_cache_process_mnesia + ,reuse_session, reuse_session_expired, server_does_not_want_to_reuse_session + ]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- +app(doc) -> + "Test that the ssl app file is ok"; +app(suite) -> + []; +app(Config) when is_list(Config) -> + ok = test_server:app_test(ssl). + +connection_info(doc) -> + ["Test the API function ssl:connection_info/1"]; +connection_info(suite) -> + []; +connection_info(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, connection_info_result, []}}, + {options, ServerOpts}]), + + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, connection_info_result, []}}, + {options, + [{ciphers,[{rsa,rc4_128,sha,no_export}]} | + ClientOpts]}]), + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + Version = + ssl_record:protocol_version(ssl_record:highest_protocol_version([])), + + ServerMsg = ClientMsg = {ok, {Version, {rsa,rc4_128,sha,no_export}}}, + + ssl_test_lib:check_result(Server, ServerMsg, Client, ClientMsg), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +connection_info_result(Socket) -> + ssl:connection_info(Socket). + +%%-------------------------------------------------------------------- + +controlling_process(doc) -> + ["Test API function controlling_process/2"]; + +controlling_process(suite) -> + []; + +controlling_process(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + ClientMsg = "Hello server", + ServerMsg = "Hello client", + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, + controlling_process_result, [self(), + ServerMsg]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + controlling_process_result, [self(), + ClientMsg]}}, + {options, ClientOpts}]), + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + receive + {ssl, _, ServerMsg} -> + receive + {ssl, _, ClientMsg} -> + ok + end; + {ssl, _, ClientMsg} -> + receive + {ssl, _, ServerMsg} -> + ok + end; + Unexpected -> + test_server:fail(Unexpected) + end, + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +controlling_process_result(Socket, Pid, Msg) -> + ok = ssl:controlling_process(Socket, Pid), + %% Make sure other side has evaluated controlling_process + %% before message is sent + test_server:sleep(100), + ssl:send(Socket, Msg), + no_result_msg. + + +controller_dies(doc) -> + ["Test that the socket is closed after controlling process dies"]; +controller_dies(suite) -> []; +controller_dies(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + ClientMsg = "Hello server", + ServerMsg = "Hello client", + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, + controller_dies_result, [self(), + ServerMsg]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + controller_dies_result, [self(), + ClientMsg]}}, + {options, ClientOpts}]), + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", [self(), Client, Server]), + timer:sleep(200), %% so that they are connected + + process_flag(trap_exit, true), + + %% Test that clients die + exit(Client, killed), + get_close(Client, ?LINE), + + %% Test that clients die when process disappear + Server ! listen, timer:sleep(200), + Tester = self(), + Connect = fun(Pid) -> + {ok, Socket} = ssl:connect(Hostname, Port, + [{reuseaddr,true},{ssl_imp,new}]), + Pid ! {self(), connected, Socket}, + receive die_nice -> normal end + end, + Client2 = spawn_link(fun() -> Connect(Tester) end), + receive {Client2, connected, _Socket} -> Client2 ! die_nice end, + + get_close(Client2, ?LINE), + + %% Test that clients die when the controlling process have changed + Server ! listen, timer:sleep(200), + + Client3 = spawn_link(fun() -> Connect(Tester) end), + Controller = spawn_link(fun() -> receive die_nice -> normal end end), + receive + {Client3, connected, Socket} -> + ok = ssl:controlling_process(Socket, Controller), + Client3 ! die_nice + end, + + test_server:format("Wating on exit ~p~n",[Client3]), + receive {'EXIT', Client3, normal} -> ok end, + + receive %% Client3 is dead but that doesn't matter, socket should not be closed. + Unexpected -> + test_server:format("Unexpected ~p~n",[Unexpected]), + test_server:fail({line, ?LINE-1}) + after 1000 -> + ok + end, + Controller ! die_nice, + get_close(Controller, ?LINE), + + %% Test that servers die + Server ! listen, timer:sleep(200), + LastClient = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + controller_dies_result, [self(), + ClientMsg]}}, + {options, [{reuseaddr,true}|ClientOpts]}]), + timer:sleep(200), %% so that they are connected + + exit(Server, killed), + get_close(Server, ?LINE), + process_flag(trap_exit, false), + ssl_test_lib:close(LastClient). + +controller_dies_result(_Socket, _Pid, _Msg) -> + receive Result -> Result end. + +get_close(Pid, Where) -> + receive + {'EXIT', Pid, _Reason} -> + receive + {_, {ssl_closed, Socket}} -> + test_server:format("Socket closed ~p~n",[Socket]); + Unexpected -> + test_server:format("Unexpected ~p~n",[Unexpected]), + test_server:fail({line, ?LINE-1}) + after 5000 -> + test_server:fail({timeout, {line, ?LINE, Where}}) + end; + Unexpected -> + test_server:format("Unexpected ~p~n",[Unexpected]), + test_server:fail({line, ?LINE-1}) + after 5000 -> + test_server:fail({timeout, {line, ?LINE, Where}}) + end. + +%%-------------------------------------------------------------------- +peercert(doc) -> + [""]; + +peercert(suite) -> + []; + +peercert(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, peercert_result, []}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, peercert_result, []}}, + {options, ClientOpts}]), + + CertFile = proplists:get_value(certfile, ServerOpts), + {ok, [{cert, BinCert, _}]} = public_key:pem_to_der(CertFile), + {ok, ErlCert} = public_key:pkix_decode_cert(BinCert, otp), + + ServerMsg = {{error, no_peercert}, {error, no_peercert}}, + ClientMsg = {{ok, BinCert}, {ok, ErlCert}}, + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + ssl_test_lib:check_result(Server, ServerMsg, Client, ClientMsg), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +peercert_result(Socket) -> + Result1 = ssl:peercert(Socket), + Result2 = ssl:peercert(Socket, [ssl]), + {Result1, Result2}. + +%%-------------------------------------------------------------------- +connect_dist(doc) -> + ["Test a simple connect as is used by distribution"]; + +connect_dist(suite) -> + []; + +connect_dist(Config) when is_list(Config) -> + ClientOpts0 = ?config(client_kc_opts, Config), + ClientOpts = [{ssl_imp, new},{active, false}, {packet,4}|ClientOpts0], + ServerOpts0 = ?config(server_kc_opts, Config), + ServerOpts = [{ssl_imp, new},{active, false}, {packet,4}|ServerOpts0], + + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, connect_dist_s, []}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, connect_dist_c, []}}, + {options, ClientOpts}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +connect_dist_s(S) -> + Msg = term_to_binary({erlang,term}), + ok = ssl:send(S, <<(size(Msg)):32, Msg/binary>>). + +connect_dist_c(S) -> + Test = binary_to_list(term_to_binary({erlang,term})), + {ok, Test} = ssl:recv(S, 0, 10000), + ok. + + +%%-------------------------------------------------------------------- +peername(doc) -> + ["Test API function peername/1"]; + +peername(suite) -> + []; + +peername(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, peername_result, []}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, peername_result, []}}, + {options, [{port, 0} | ClientOpts]}]), + + ClientPort = ssl_test_lib:inet_port(Client), + ServerIp = ssl_test_lib:node_to_hostip(ServerNode), + ClientIp = ssl_test_lib:node_to_hostip(ClientNode), + ServerMsg = {ok, {ClientIp, ClientPort}}, + ClientMsg = {ok, {ServerIp, Port}}, + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + ssl_test_lib:check_result(Server, ServerMsg, Client, ClientMsg), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +peername_result(S) -> + ssl:peername(S). + +%%-------------------------------------------------------------------- +sockname(doc) -> + ["Test API function sockname/1"]; + +sockname(suite) -> + []; + +sockname(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, sockname_result, []}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, sockname_result, []}}, + {options, [{port, 0} | ClientOpts]}]), + ClientPort = ssl_test_lib:inet_port(Client), + ServerIp = ssl_test_lib:node_to_hostip(ServerNode), + ClientIp = ssl_test_lib:node_to_hostip(ClientNode), + ServerMsg = {ok, {ServerIp, Port}}, + ClientMsg = {ok, {ClientIp, ClientPort}}, + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + ssl_test_lib:check_result(Server, ServerMsg, Client, ClientMsg), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +sockname_result(S) -> + ssl:sockname(S). + +%%-------------------------------------------------------------------- +cipher_suites(doc) -> + ["Test API function cipher_suites/0"]; + +cipher_suites(suite) -> + []; + +cipher_suites(Config) when is_list(Config) -> + MandatoryCipherSuite = {rsa,'3des_ede_cbc',sha,no_export}, + [_|_] = Suites = ssl:cipher_suites(), + true = lists:member(MandatoryCipherSuite, Suites). +%%-------------------------------------------------------------------- +socket_options(doc) -> + ["Test API function getopts/2 and setopts/2"]; + +socket_options(suite) -> + []; + +socket_options(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Values = [{mode, list}, {packet, 0}, {header, 0}, + {active, true}], + %% Shall be the reverse order of Values! + Options = [active, header, packet, mode], + + NewValues = [{mode, binary}, {active, once}], + %% Shall be the reverse order of NewValues! + NewOptions = [active, mode], + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, socket_options_result, + [Options, Values, NewOptions, NewValues]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, socket_options_result, + [Options, Values, NewOptions, NewValues]}}, + {options, ClientOpts}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +socket_options_result(Socket, Options, DefaultValues, NewOptions, NewValues) -> + %% Test get/set emulated opts + {ok, DefaultValues} = ssl:getopts(Socket, Options), + ssl:setopts(Socket, NewValues), + {ok, NewValues} = ssl:getopts(Socket, NewOptions), + %% Test get/set inet opts + {ok,[{nodelay,false}]} = ssl:getopts(Socket, [nodelay]), + ok. + +%%-------------------------------------------------------------------- +versions(doc) -> + ["Test API function versions/0"]; + +versions(suite) -> + []; + +versions(Config) when is_list(Config) -> + [_|_] = Versions = ssl:versions(), + test_server:format("~p~n", [Versions]). + +%%-------------------------------------------------------------------- +send_recv(doc) -> + [""]; + +send_recv(suite) -> + []; + +send_recv(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = + ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = + ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false} | ClientOpts]}]), + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +send_close(doc) -> + [""]; + +send_close(suite) -> + []; + +send_close(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = + ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + {ok, TcpS} = rpc:call(ClientNode, gen_tcp, connect, + [Hostname,Port,[binary, {active, false}, {reuseaddr, true}]]), + {ok, SslS} = rpc:call(ClientNode, ssl, connect, + [TcpS,[{active, false}|ClientOpts]]), + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), self(), Server]), + ok = ssl:send(SslS, "HejHopp"), + {ok,<<"Hejhopp">>} = ssl:recv(SslS, 7), + gen_tcp:close(TcpS), + {error, _} = ssl:send(SslS, "HejHopp"), + ssl_test_lib:close(Server). + +%%-------------------------------------------------------------------- +upgrade(doc) -> + ["Test that you can upgrade an tcp connection to an ssl connection"]; + +upgrade(suite) -> + []; + +upgrade(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + TcpOpts = [binary, {reuseaddr, true}], + + Server = ssl_test_lib:start_upgrade_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, + upgrade_result, []}}, + {tcp_options, TcpOpts}, + {ssl_options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_upgrade_client([{node, ClientNode}, + {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, upgrade_result, []}}, + {tcp_options, TcpOpts}, + {ssl_options, ClientOpts}]), + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +upgrade_result(Socket) -> + ok = ssl:send(Socket, "Hejhopp"), + %% Make sure binary is inherited from tcp socket and that we do + %% not get the list default! + receive + {ssl, _, <<"Hejhopp">>} -> + ok + end. + +%%-------------------------------------------------------------------- +upgrade_with_timeout(doc) -> + ["Test ssl_accept/3"]; + +upgrade_with_timeout(suite) -> + []; + +upgrade_with_timeout(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + TcpOpts = [binary, {reuseaddr, true}], + + Server = ssl_test_lib:start_upgrade_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {timeout, 5000}, + {mfa, {?MODULE, + upgrade_result, []}}, + {tcp_options, TcpOpts}, + {ssl_options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_upgrade_client([{node, ClientNode}, + {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, upgrade_result, []}}, + {tcp_options, TcpOpts}, + {ssl_options, ClientOpts}]), + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). +%%-------------------------------------------------------------------- +ipv6(doc) -> + ["Test ipv6."]; +ipv6(suite) -> + []; +ipv6(Config) when is_list(Config) -> + {ok, Hostname0} = inet:gethostname(), + + case lists:member(list_to_atom(Hostname0), ?config(ipv6_hosts, Config)) of + true -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = + ssl_test_lib:run_where(Config, ipv6), + Server = ssl_test_lib:start_server([{node, ServerNode}, + {port, 0}, {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, + [inet6, {active, false} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, + [inet6, {active, false} | ClientOpts]}]), + + test_server:format("Testcase ~p, Client ~p Server ~p ~n", + [self(), Client, Server]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client); + false -> + {skip, "Host does not support IPv6"} + end. + +%%-------------------------------------------------------------------- + +ekeyfile(doc) -> + ["Test what happens with an invalid key file"]; + +ekeyfile(suite) -> + []; + +ekeyfile(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + BadOpts = ?config(server_bad_key, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Port = ssl_test_lib:inet_port(ServerNode), + + Server = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, BadOpts}]), + Client = + ssl_test_lib:start_client_error([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {from, self()}, {options, ClientOpts}]), + + ssl_test_lib:check_result(Server, {error, ekeyfile}, Client, + {error, closed}). + +%%-------------------------------------------------------------------- + +ecertfile(doc) -> + ["Test what happens with an invalid cert file"]; + +ecertfile(suite) -> + []; + +ecertfile(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerBadOpts = ?config(server_bad_cert, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Port = ssl_test_lib:inet_port(ServerNode), + + Server0 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, ServerBadOpts}]), + Client0 = + ssl_test_lib:start_client_error([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {from, self()}, + {options, ClientOpts}]), + + ssl_test_lib:check_result(Server0, {error, ecertfile}, Client0, + {error, closed}). + + +%%-------------------------------------------------------------------- +ecacertfile(doc) -> + ["Test what happens with an invalid cacert file"]; + +ecacertfile(suite) -> + []; + +ecacertfile(Config) when is_list(Config) -> + ClientOpts = [{reuseaddr, true}|?config(client_opts, Config)], + ServerBadOpts = [{reuseaddr, true}|?config(server_bad_ca, Config)], + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Port = ssl_test_lib:inet_port(ServerNode), + + Server0 = + ssl_test_lib:start_server_error([{node, ServerNode}, + {port, Port}, {from, self()}, + {options, ServerBadOpts}]), + Client0 = + ssl_test_lib:start_client_error([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {from, self()}, + {options, ClientOpts}]), + + ssl_test_lib:check_result(Server0, {error, ecacertfile}, + Client0, {error, closed}), + + File0 = proplists:get_value(cacertfile, ServerBadOpts), + File = File0 ++ "do_not_exit.pem", + ServerBadOpts1 = [{cacertfile, File}|proplists:delete(cacertfile, ServerBadOpts)], + + Server1 = + ssl_test_lib:start_server_error([{node, ServerNode}, + {port, Port}, {from, self()}, + {options, ServerBadOpts1}]), + Client1 = + ssl_test_lib:start_client_error([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {from, self()}, + {options, ClientOpts}]), + + ssl_test_lib:check_result(Server1, {error, ecacertfile}, + Client1, {error, closed}), + ok. + + + +%%-------------------------------------------------------------------- +eoptions(doc) -> + ["Test what happens when we give invalid options"]; + +eoptions(suite) -> + []; + +eoptions(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Port = ssl_test_lib:inet_port(ServerNode), + + %% Emulated opts + Server0 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{active, trice} | ServerOpts]}]), + Client0 = + ssl_test_lib:start_client_error([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {from, self()}, + {options, [{active, trice} | ClientOpts]}]), + ssl_test_lib:check_result(Server0, {error, {eoptions, {active,trice}}}, + Client0, {error, {eoptions, {active,trice}}}), + + test_server:sleep(500), + + Server1 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{header, a} | ServerOpts]}]), + Client1 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, [{header, a} | ClientOpts]}]), + ssl_test_lib:check_result(Server1, {error, {eoptions, {header, a}}}, + Client1, {error, {eoptions, {header, a}}}), + + test_server:sleep(500), + + + Server2 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{mode, a} | ServerOpts]}]), + + Client2 = + ssl_test_lib:start_client_error([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {from, self()}, + {options, [{mode, a} | ClientOpts]}]), + ssl_test_lib:check_result(Server2, {error, {eoptions, {mode, a}}}, + Client2, {error, {eoptions, {mode, a}}}), + + + test_server:sleep(500), + + Server3 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{packet, 8.0} | ServerOpts]}]), + Client3 = + ssl_test_lib:start_client_error([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {from, self()}, + {options, [{packet, 8.0} | ClientOpts]}]), + ssl_test_lib:check_result(Server3, {error, {eoptions, {packet, 8.0}}}, + Client3, {error, {eoptions, {packet, 8.0}}}), + + test_server:sleep(500), + + %% ssl + Server4 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{verify, 4} | ServerOpts]}]), + Client4 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, [{verify, 4} | ClientOpts]}]), + ssl_test_lib:check_result(Server4, {error, {eoptions, {verify, 4}}}, + Client4, {error, {eoptions, {verify, 4}}}), + + test_server:sleep(500), + + Server5 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{depth, four} | ServerOpts]}]), + Client5 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, [{depth, four} | ClientOpts]}]), + ssl_test_lib:check_result(Server5, {error, {eoptions, {depth, four}}}, + Client5, {error, {eoptions, {depth, four}}}), + + test_server:sleep(500), + + Server6 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{cacertfile, ""} | ServerOpts]}]), + Client6 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, [{cacertfile, ""} | ClientOpts]}]), + ssl_test_lib:check_result(Server6, {error, {eoptions, {cacertfile, ""}}}, + Client6, {error, {eoptions, {cacertfile, ""}}}), + + + test_server:sleep(500), + + Server7 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{certfile, 'cert.pem'} | ServerOpts]}]), + Client7 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, [{certfile, 'cert.pem'} | ClientOpts]}]), + ssl_test_lib:check_result(Server7, + {error, {eoptions, {certfile, 'cert.pem'}}}, + Client7, {error, {eoptions, {certfile, 'cert.pem'}}}), + + test_server:sleep(500), + + Server8 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{keyfile,'key.pem' } | ServerOpts]}]), + Client8 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, {options, [{keyfile, 'key.pem'} + | ClientOpts]}]), + ssl_test_lib:check_result(Server8, + {error, {eoptions, {keyfile, 'key.pem'}}}, + Client8, {error, {eoptions, {keyfile, 'key.pem'}}}), + + test_server:sleep(500), + + Server9 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{key, 'key.pem' } | ServerOpts]}]), + Client9 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, {options, [{key, 'key.pem'} + | ClientOpts]}]), + ssl_test_lib:check_result(Server9, {error, {eoptions, {key, 'key.pem'}}}, + Client9, {error, {eoptions, {key, 'key.pem'}}}), + + + test_server:sleep(500), + + Server10 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{password, foo} | ServerOpts]}]), + Client10 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, [{password, foo} | ClientOpts]}]), + ssl_test_lib:check_result(Server10, {error, {eoptions, {password, foo}}}, + Client10, {error, {eoptions, {password, foo}}}), + + test_server:sleep(500), + + %% Misc + Server11 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{ssl_imp, cool} | ServerOpts]}]), + Client11 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, [{ssl_imp, cool} | ClientOpts]}]), + ssl_test_lib:check_result(Server11, {error, {eoptions, {ssl_imp, cool}}}, + Client11, {error, {eoptions, {ssl_imp, cool}}}), + + + test_server:sleep(500), + + Server12 = + ssl_test_lib:start_server_error([{node, ServerNode}, {port, Port}, + {from, self()}, + {options, [{debug, cool} | ServerOpts]}]), + Client12 = + ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, [{debug, cool} | ClientOpts]}]), + ssl_test_lib:check_result(Server12, {error, {eoptions, {debug, cool}}}, + Client12, {error, {eoptions, {debug, cool}}}). + +%%-------------------------------------------------------------------- +shutdown(doc) -> + [""]; + +shutdown(suite) -> + []; + +shutdown(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, shutdown_result, [server]}}, + {options, [{exit_on_close, false}, + {active, false} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, shutdown_result, [client]}}, + {options, + [{exit_on_close, false}, + {active, false} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +shutdown_result(Socket, server) -> + ssl:send(Socket, "Hej"), + ssl:shutdown(Socket, write), + {ok, "Hej hopp"} = ssl:recv(Socket, 8), + ok; + +shutdown_result(Socket, client) -> + {ok, "Hej"} = ssl:recv(Socket, 3), + ssl:send(Socket, "Hej hopp"), + ssl:shutdown(Socket, write), + ok. + +%%-------------------------------------------------------------------- +shutdown_write(doc) -> + [""]; + +shutdown_write(suite) -> + []; + +shutdown_write(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, shutdown_write_result, [server]}}, + {options, [{active, false} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, shutdown_write_result, [client]}}, + {options, [{active, false} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, {error, closed}). + +shutdown_write_result(Socket, server) -> + test_server:sleep(500), + ssl:shutdown(Socket, write); +shutdown_write_result(Socket, client) -> + ssl:recv(Socket, 0). + +%%-------------------------------------------------------------------- +shutdown_both(doc) -> + [""]; + +shutdown_both(suite) -> + []; + +shutdown_both(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, shutdown_both_result, [server]}}, + {options, [{active, false} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, shutdown_both_result, [client]}}, + {options, [{active, false} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, {error, closed}). + +shutdown_both_result(Socket, server) -> + test_server:sleep(500), + ssl:shutdown(Socket, read_write); +shutdown_both_result(Socket, client) -> + ssl:recv(Socket, 0). + +%%-------------------------------------------------------------------- +shutdown_error(doc) -> + [""]; + +shutdown_error(suite) -> + []; + +shutdown_error(Config) when is_list(Config) -> + ServerOpts = ?config(server_opts, Config), + Port = ssl_test_lib:inet_port(node()), + {ok, Listen} = ssl:listen(Port, ServerOpts), + {error, enotconn} = ssl:shutdown(Listen, read_write), + ok = ssl:close(Listen), + {error, closed} = ssl:shutdown(Listen, read_write). + +%%-------------------------------------------------------------------- +ciphers(doc) -> + [""]; + +ciphers(suite) -> + []; + +ciphers(Config) when is_list(Config) -> + Version = + ssl_record:protocol_version(ssl_record:highest_protocol_version([])), + + Ciphers = ssl:cipher_suites(), + Result = lists:map(fun(Cipher) -> + cipher(Cipher, Version, Config) end, + Ciphers), + case lists:flatten(Result) of + [] -> + ok; + Error -> + test_server:format("Cipher suite errors: ~p~n", [Error]), + test_server:fail(cipher_suite_failed_see_test_case_log) + end. + +cipher(CipherSuite, Version, Config) -> + process_flag(trap_exit, true), + test_server:format("Testing CipherSuite ~p~n", [CipherSuite]), + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, connection_info_result, []}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, connection_info_result, []}}, + {options, + [{ciphers,[CipherSuite]} | + ClientOpts]}]), + + ServerMsg = ClientMsg = {ok, {Version, CipherSuite}}, + + Result = ssl_test_lib:wait_for_result(Server, ServerMsg, + Client, ClientMsg), + ssl_test_lib:close(Server), + receive + {'EXIT', Server, normal} -> + ok + end, + ssl_test_lib:close(Client), + receive + {'EXIT', Client, normal} -> + ok + end, + process_flag(trap_exit, false), + case Result of + ok -> + []; + Error -> + [{CipherSuite, Error}] + end. + +%%-------------------------------------------------------------------- +reuse_session(doc) -> + ["Test reuse of sessions (short handshake)"]; + +reuse_session(suite) -> + []; + +reuse_session(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Server = + ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, session_info_result, []}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client0 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, no_result, []}}, + {from, self()}, {options, ClientOpts}]), + SessionInfo = + receive + {Server, Info} -> + Info + end, + + Server ! listen, + + %% Make sure session is registered + test_server:sleep(500), + + Client1 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + receive + {Client1, SessionInfo} -> + ok; + {Client1, Other} -> + test_server:format("Expected: ~p, Unexpected: ~p~n", + [SessionInfo, Other]), + test_server:fail(session_not_reused) + end, + + Server ! listen, + + Client2 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, [{reuse_sessions, false} + | ClientOpts]}]), + receive + {Client2, SessionInfo} -> + test_server:fail( + session_reused_when_session_reuse_disabled_by_client); + {Client2, _} -> + ok + end, + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client0), + ssl_test_lib:close(Client1), + ssl_test_lib:close(Client2), + + + Server1 = + ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, session_info_result, []}}, + {options, [{reuse_sessions, false} | ServerOpts]}]), + + Port1 = ssl_test_lib:inet_port(Server1), + Client3 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port1}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + + SessionInfo1 = + receive + {Server1, Info1} -> + Info1 + end, + + Server1 ! listen, + + %% Make sure session is registered + test_server:sleep(500), + + Client4 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port1}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + + receive + {Client4, SessionInfo1} -> + test_server:fail( + session_reused_when_session_reuse_disabled_by_server); + {Client4, _Other} -> + ok + end, + + ssl_test_lib:close(Server1), + ssl_test_lib:close(Client3), + ssl_test_lib:close(Client4), + process_flag(trap_exit, false). + + +session_info_result(Socket) -> + ssl:session_info(Socket). + +%%-------------------------------------------------------------------- +reuse_session_expired(doc) -> + ["Test sessions is not reused when it has expired"]; + +reuse_session_expired(suite) -> + []; + +reuse_session_expired(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Server = + ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, session_info_result, []}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client0 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, no_result, []}}, + {from, self()}, {options, ClientOpts}]), + SessionInfo = + receive + {Server, Info} -> + Info + end, + + Server ! listen, + + %% Make sure session is registered + test_server:sleep(500), + + Client1 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + receive + {Client1, SessionInfo} -> + ok; + {Client1, Other} -> + test_server:format("Expected: ~p, Unexpected: ~p~n", + [SessionInfo, Other]), + test_server:fail(session_not_reused) + end, + + Server ! listen, + + %% Make sure session is unregistered due to expiration + test_server:sleep((?EXPIRE+1) * 1000), + + Client2 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + receive + {Client2, SessionInfo} -> + test_server:fail(session_reused_when_session_expired); + {Client2, _} -> + ok + end, + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client0), + ssl_test_lib:close(Client1), + ssl_test_lib:close(Client2), + process_flag(trap_exit, false). +%%-------------------------------------------------------------------- +server_does_not_want_to_reuse_session(doc) -> + ["Test reuse of sessions (short handshake)"]; + +server_does_not_want_to_reuse_session(suite) -> + []; + +server_does_not_want_to_reuse_session(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Server = + ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, session_info_result, []}}, + {options, [{reuse_session, fun(_,_,_,_) -> + false + end} | + ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client0 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, no_result, []}}, + {from, self()}, {options, ClientOpts}]), + SessionInfo = + receive + {Server, Info} -> + Info + end, + + Server ! listen, + + %% Make sure session is registered + test_server:sleep(500), + + Client1 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + receive + {Client1, SessionInfo} -> + test_server:fail(session_reused_when_server_does_not_want_to); + {Client1, _Other} -> + ok + end, + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client0), + ssl_test_lib:close(Client1), + process_flag(trap_exit, false). + +%%-------------------------------------------------------------------- + +server_verify_peer_passive(doc) -> + ["Test server option verify_peer"]; + +server_verify_peer_passive(suite) -> + []; + +server_verify_peer_passive(Config) when is_list(Config) -> + ClientOpts = ?config(client_verification_opts, Config), + ServerOpts = ?config(server_verification_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false}, {verify, verify_peer} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- + +server_verify_peer_active(doc) -> + ["Test server option verify_peer"]; + +server_verify_peer_active(suite) -> + []; + +server_verify_peer_active(Config) when is_list(Config) -> + ClientOpts = ?config(client_verification_opts, Config), + ServerOpts = ?config(server_verification_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active, []}}, + {options, [{active, true}, {verify, verify_peer} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active, []}}, + {options, [{active, true} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +server_verify_peer_active_once(doc) -> + ["Test server option verify_peer"]; + +server_verify_peer_active_once(suite) -> + []; + +server_verify_peer_active_once(Config) when is_list(Config) -> + ClientOpts = ?config(client_verification_opts, Config), + ServerOpts = ?config(server_verification_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active_once, []}}, + {options, [{active, once}, {verify, verify_peer} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active_once, []}}, + {options, [{active, once} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- + +server_verify_none_passive(doc) -> + ["Test server option verify_none"]; + +server_verify_none_passive(suite) -> + []; + +server_verify_none_passive(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false}, {verify, verify_none} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- + +server_verify_none_active(doc) -> + ["Test server option verify_none"]; + +server_verify_none_active(suite) -> + []; + +server_verify_none_active(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active, []}}, + {options, [{active, true}, {verify, verify_none} | + ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active, []}}, + {options, [{active, true} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +server_verify_none_active_once(doc) -> + ["Test server option verify_none"]; + +server_verify_none_active_once(suite) -> + []; + +server_verify_none_active_once(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active_once, []}}, + {options, [{active, once}, {verify, verify_none} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active_once, []}}, + {options, [{active, once} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- + +server_verify_no_cacerts(doc) -> + ["Test server must have cacerts if it wants to verify client"]; + +server_verify_no_cacerts(suite) -> + []; + +server_verify_no_cacerts(Config) when is_list(Config) -> + ServerOpts = ServerOpts = ?config(server_opts, Config), + {_, ServerNode, _} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server_error([{node, ServerNode}, {port, 0}, + {from, self()}, + {options, [{verify, verify_peer} + | ServerOpts]}]), + + ssl_test_lib:check_result(Server, {error, {eoptions, {cacertfile, ""}}}). + +%%-------------------------------------------------------------------- + +client_verify_none_passive(doc) -> + ["Test client option verify_none"]; + +client_verify_none_passive(suite) -> + []; + +client_verify_none_passive(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, send_recv_result, []}}, + {options, [{active, false}, + {verify, verify_none} + | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- + +client_verify_none_active(doc) -> + ["Test client option verify_none"]; + +client_verify_none_active(suite) -> + []; + +client_verify_none_active(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, + send_recv_result_active, []}}, + {options, [{active, true} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + send_recv_result_active, []}}, + {options, [{active, true}, + {verify, verify_none} + | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +client_verify_none_active_once(doc) -> + ["Test client option verify_none"]; + +client_verify_none_active_once(suite) -> + []; + +client_verify_none_active_once(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_recv_result_active_once, []}}, + {options, [{active, once} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + %% TODO: send message to test process to make sure + %% verifyfun has beeen run as it has the same behavior as + %% the default fun + VerifyFun = fun([{bad_cert, unknown_ca}]) -> + true; + (_) -> + false + end, + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + send_recv_result_active_once, + []}}, + {options, [{active, once}, + {verify, verify_none}, + {verify_fun, VerifyFun} + | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- +%%% Internal functions +%%-------------------------------------------------------------------- +send_recv_result(Socket) -> + ssl:send(Socket, "Hejhopp"), + test_server:sleep(100), + {ok,"Hejhopp"} = ssl:recv(Socket, 7), + ok. + +send_recv_result_active(Socket) -> + ssl:send(Socket, "Hejhopp"), + test_server:sleep(100), + receive + {ssl, Socket, "Hejhopp"} -> + ok + end. + +send_recv_result_active_once(Socket) -> + ssl:send(Socket, "Hejhopp"), + test_server:sleep(100), + receive + {ssl, Socket, "Hejhopp"} -> + ok + end. + +session_cache_process_list(doc) -> + ["Test reuse of sessions (short handshake)"]; + +session_cache_process_list(suite) -> + []; +session_cache_process_list(Config) when is_list(Config) -> + session_cache_process(list,Config). + +session_cache_process_mnesia(doc) -> + ["Test reuse of sessions (short handshake)"]; + +session_cache_process_mnesia(suite) -> + []; +session_cache_process_mnesia(Config) when is_list(Config) -> + session_cache_process(mnesia,Config). + +session_cache_process(Type,Config) when is_list(Config) -> + process_flag(trap_exit, true), + setup_session_cb(Type), + + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Server = + ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, session_info_result, []}}, + {options, + [{session_cache_cb, ?MODULE}| + ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client0 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, no_result, []}}, + {from, self()}, {options, ClientOpts}]), + SessionInfo = + receive + {Server, Info} -> + Info + end, + + Server ! listen, + + %% Make sure session is registered + test_server:sleep(500), + + Client1 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + receive + {Client1, SessionInfo} -> + ok; + {Client1, Other} -> + test_server:format("Expected: ~p, Unexpected: ~p~n", + [SessionInfo, Other]), + test_server:fail(session_not_reused) + end, + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client0), + ssl_test_lib:close(Client1), + + Server1 = + ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, session_info_result, []}}, + {options, + [{reuse_sessions, false} | ServerOpts]}]), + Port1 = ssl_test_lib:inet_port(Server1), + + Client3 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port1}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + + SessionInfo1 = + receive + {Server1, Info1} -> + Info1 + end, + + Server1 ! listen, + + %% Make sure session is registered + test_server:sleep(500), + + Client4 = + ssl_test_lib:start_client([{node, ClientNode}, + {port, Port1}, {host, Hostname}, + {mfa, {?MODULE, session_info_result, []}}, + {from, self()}, {options, ClientOpts}]), + + receive + {Client4, SessionInfo1} -> + test_server:fail( + session_reused_when_session_reuse_disabled_by_server); + {Client4, _Other} -> + ok + end, + + ssl_test_lib:close(Server1), + ssl_test_lib:close(Client3), + ssl_test_lib:close(Client4), + process_flag(trap_exit, false). + +setup_session_cb(Type) -> + ssl_test = ets:new(ssl_test,[named_table, set,public]), + ets:insert(ssl_test, {type,Type}). + +session_cb() -> + [{type,Type}] = ets:lookup(ssl_test, type), + Type. + +init() -> + io:format("~p~n",[?LINE]), + case session_cb() of + list -> + spawn(fun() -> session_loop([]) end); + mnesia -> + mnesia:start(), + {atomic,ok} = mnesia:create_table(sess_cache, []) + end. + +terminate(Cache) -> + io:format("~p~n",[?LINE]), + case session_cb() of + list -> + Cache ! terminate; + mnesia -> + {atomic,ok} = mnesia:delete_table(sess_cache, []) + end. + +lookup(Cache, Key) -> + io:format("~p~n",[?LINE]), + case session_cb() of + list -> + Cache ! {self(), lookup, Key}, + receive {Cache, Res} -> Res end; + mnesia -> + case mnesia:transaction(fun() -> + mnesia:read(sess_cache, + Key, read) + end) of + {atomic, [Session]} -> Session; + _ -> undefined + end + end. + +update(Cache, Key, Value) -> + io:format("~p~n",[?LINE]), + case session_cb() of + list -> + Cache ! {update, Key, Value}; + mnesia -> + {atomic, ok} = + mnesia:transaction(fun() -> + mnesia:write(sess_cache, + Key, Value) + end) + end. + +delete(Cache, Key) -> + io:format("~p~n",[?LINE]), + case session_cb() of + list -> + Cache ! {delete, Key}; + mnesia -> + {atomic, ok} = + mnesia:transaction(fun() -> + mnesia:delete(sess_cache, Key) + end) + end. + +foldl(Fun, Acc, Cache) -> + io:format("~p~n",[?LINE]), + case session_cb() of + list -> + Cache ! {self(),foldl,Fun,Acc}, + receive {Cache, Res} -> Res end; + mnesia -> + Foldl = fun() -> + mnesia:foldl(Fun, Acc, sess_cache) + end, + {atomic, Res} = mnesia:transaction(Foldl), + Res + end. + +select_session(Cache, PartialKey) -> + io:format("~p~n",[?LINE]), + case session_cb() of + list -> + Cache ! {self(),select_session, PartialKey}, + receive {Cache, Res} -> Res end; + mnesia -> + Sel = fun() -> + mnesia:select(Cache, + [{{{PartialKey,'$1'}, '$2'}, + [],['$$']}]) + end, + {atomic, Res} = mnesia:transaction(Sel), + Res + end. + +session_loop(Sess) -> + receive + terminate -> + ok; + {Pid, lookup, Key} -> + case lists:keysearch(Key,1,Sess) of + {value, {Key,Value}} -> + Pid ! {self(), Value}; + _ -> + Pid ! {self(), undefined} + end, + session_loop(Sess); + {update, Key, Value} -> + session_loop([{Key,Value}|Sess]); + {delete, Key} -> + session_loop(lists:keydelete(Key,1,Sess)); + {Pid,foldl,Fun,Acc} -> + Res = lists:foldl(Fun, Acc,Sess), + Pid ! {self(), Res}, + session_loop(Sess); + {Pid,select_session,PKey} -> + Sel = fun({{Head, _},Session}, Acc) when Head =:= PKey -> + [Session|Acc]; + (_,Acc) -> + Acc + end, + Pid ! {self(), lists:foldl(Sel, [], Sess)}, + session_loop(Sess) + end. + diff --git a/lib/ssl/test/ssl_basic_SUITE_data/RAND b/lib/ssl/test/ssl_basic_SUITE_data/RAND Binary files differnew file mode 100644 index 0000000000..70997bd01f --- /dev/null +++ b/lib/ssl/test/ssl_basic_SUITE_data/RAND diff --git a/lib/ssl/test/ssl_packet_SUITE.erl b/lib/ssl/test/ssl_packet_SUITE.erl new file mode 100644 index 0000000000..929f69c6c6 --- /dev/null +++ b/lib/ssl/test/ssl_packet_SUITE.erl @@ -0,0 +1,1486 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2008-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(ssl_packet_SUITE). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include("test_server.hrl"). + +-define(BYTE(X), X:8/unsigned-big-integer). +-define(UINT16(X), X:16/unsigned-big-integer). +-define(UINT24(X), X:24/unsigned-big-integer). +-define(UINT32(X), X:32/unsigned-big-integer). +-define(UINT64(X), X:64/unsigned-big-integer). +-define(STRING(X), ?UINT32((size(X))), (X)/binary). + +-define(byte(X), << ?BYTE(X) >> ). +-define(uint16(X), << ?UINT16(X) >> ). +-define(uint24(X), << ?UINT24(X) >> ). +-define(uint32(X), << ?UINT32(X) >> ). +-define(uint64(X), << ?UINT64(X) >> ). +-define(TIMEOUT, 60000). + +-define(MANY, 1000). +-define(SOME, 50). + + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initialization before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + crypto:start(), + ssl:start(), + Result = + (catch make_certs:all(?config(data_dir, Config), + ?config(priv_dir, Config))), + test_server:format("Make certs ~p~n", [Result]), + ssl_test_lib:cert_options(Config). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ssl:stop(), + crypto:stop(). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initialization before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initialization before each test case +%%-------------------------------------------------------------------- +init_per_testcase(_TestCase, Config0) -> + Config = lists:keydelete(watchdog, 1, Config0), + Dog = ssl_test_lib:timetrap(?TIMEOUT), + [{watchdog, Dog} | Config]. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, Config) -> + Dog = ?config(watchdog, Config), + case Dog of + undefined -> + ok; + _ -> + test_server:timetrap_cancel(Dog) + end. + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test that erlang:decode_packet/3 seems to be handled correctly." + "We only use the most basic packet types in our tests as testing of" + "the packet types are for inet to verify" + ]; + +all(suite) -> + [packet_raw_passive_many_small, + packet_0_passive_many_small, packet_1_passive_many_small, + packet_2_passive_many_small, packet_4_passive_many_small, + packet_raw_passive_some_big, packet_0_passive_some_big, + packet_1_passive_some_big, + packet_2_passive_some_big, packet_4_passive_some_big, + packet_raw_active_once_many_small, + packet_0_active_once_many_small, packet_1_active_once_many_small, + packet_2_active_once_many_small, packet_4_active_once_many_small, + packet_raw_active_once_some_big, + packet_0_active_once_some_big, packet_1_active_once_some_big, + packet_2_active_once_some_big, packet_4_active_once_some_big, + packet_raw_active_many_small, packet_0_active_many_small, + packet_1_active_many_small, + packet_2_active_many_small, packet_4_active_many_small, + packet_raw_active_some_big, packet_0_active_some_big, + packet_1_active_some_big, packet_2_active_some_big, + packet_4_active_some_big, + packet_wait_passive, packet_wait_active, + packet_baddata_passive, packet_baddata_active, + packet_size_passive, packet_size_active + ]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- +packet_raw_passive_many_small(doc) -> + ["Test packet option {packet, raw} in passive mode."]; + +packet_raw_passive_many_small(suite) -> + []; + +packet_raw_passive_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, raw}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_raw, [Data, ?MANY]}}, + {options, + [{active, false}, + {packet, raw} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- + +packet_raw_passive_some_big(doc) -> + ["Test packet option {packet, raw} in passive mode."]; + +packet_raw_passive_some_big(suite) -> + []; + +packet_raw_passive_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_raw, [Data, ?SOME]}}, + {options, + [{active, false}, + {packet, raw} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_0_passive_many_small(doc) -> + ["Test packet option {packet, 0} in passive mode."]; + +packet_0_passive_many_small(suite) -> + []; + +packet_0_passive_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 0}, equivalent to packet raw.", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_raw, [Data, ?MANY]}}, + {options, [{active, false}, + {packet, 0} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_0_passive_some_big(doc) -> + ["Test packet option {packet, 0} in passive mode."]; + +packet_0_passive_some_big(suite) -> + []; + +packet_0_passive_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_raw, [Data, ?SOME]}}, + {options, [{active, false}, + {packet, 0} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_1_passive_many_small(doc) -> + ["Test packet option {packet, 1} in passive mode."]; + +packet_1_passive_many_small(suite) -> + []; + +packet_1_passive_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 1}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_1 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, + [Data, ?MANY]}}, + {options, [{active, false}, + {packet, 1} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_1_passive_some_big(doc) -> + ["Test packet option {packet, 1} in passive mode."]; + +packet_1_passive_some_big(suite) -> + []; + +packet_1_passive_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(255, "1")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_1 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, + [Data, ?SOME]}}, + {options, [{active, false}, + {packet, 1} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_2_passive_many_small(doc) -> + ["Test packet option {packet, 2} in passive mode"]; + +packet_2_passive_many_small(suite) -> + []; + +packet_2_passive_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 2}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_2 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, + [Data, ?MANY]}}, + {options, [{active, false}, + {packet, 2} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_2_passive_some_big(doc) -> + ["Test packet option {packet, 2} in passive mode"]; + +packet_2_passive_some_big(suite) -> + []; + +packet_2_passive_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_2 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, + [Data, ?SOME]}}, + {options, [{active, false}, + {packet, 2} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_4_passive_many_small(doc) -> + ["Test packet option {packet, 4} in passive mode"]; + +packet_4_passive_many_small(suite) -> + []; + +packet_4_passive_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 4}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, send_4 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, + [Data, ?MANY]}}, + {options, [{active, false}, + {packet, 4} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_4_passive_some_big(doc) -> + ["Test packet option {packet, 4} in passive mode"]; + +packet_4_passive_some_big(suite) -> + []; + +packet_4_passive_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_4 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, + [Data, ?SOME]}}, + {options, [{active, false}, + {packet, 4} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- +packet_raw_active_once_many_small(doc) -> + ["Test packet option {packet, raw} in active once mode."]; + +packet_raw_active_once_many_small(suite) -> + []; + +packet_raw_active_once_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, raw}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, active_once_raw, [Data, ?MANY]}}, + {options, [{active, once}, + {packet, raw} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_raw_active_once_some_big(doc) -> + ["Test packet option {packet, raw} in active once mode."]; + +packet_raw_active_once_some_big(suite) -> + []; + +packet_raw_active_once_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, active_once_raw, [Data, ?SOME]}}, + {options, [{active, once}, + {packet, raw} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_0_active_once_many_small(doc) -> + ["Test packet option {packet, 0} in active once mode."]; + +packet_0_active_once_many_small(suite) -> + []; + +packet_0_active_once_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 0}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, active_once_raw, + [Data, ?MANY]}}, + {options, [{active, once}, + {packet, 0} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- +packet_0_active_once_some_big(doc) -> + ["Test packet option {packet, 0} in active once mode."]; + +packet_0_active_once_some_big(suite) -> + []; + +packet_0_active_once_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw , + [Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, active_once_raw, + [Data, ?SOME]}}, + {options, [{active, once}, + {packet, 0} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_1_active_once_many_small(doc) -> + ["Test packet option {packet, 1} in active once mode."]; + +packet_1_active_once_many_small(suite) -> + []; + +packet_1_active_once_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 1}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_1 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_once_packet, + [Data, ?MANY]}}, + {options, [{active, once}, + {packet, 1} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_1_active_once_some_big(doc) -> + ["Test packet option {packet, 1} in active once mode."]; + +packet_1_active_once_some_big(suite) -> + []; + +packet_1_active_once_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(255, "1")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_1 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_once_packet, + [Data, ?SOME]}}, + {options, [{active, once}, + {packet, 1} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_2_active_once_many_small(doc) -> + ["Test packet option {packet, 2} in active once mode"]; + +packet_2_active_once_many_small(suite) -> + []; + +packet_2_active_once_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 2}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_2 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_once_packet, + [Data, ?MANY]}}, + {options, [{active, once}, + {packet, 2} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- +packet_2_active_once_some_big(doc) -> + ["Test packet option {packet, 2} in active once mode"]; + +packet_2_active_once_some_big(suite) -> + []; + +packet_2_active_once_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_2 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_once_packet, + [Data, ?SOME]}}, + {options, [{active, once}, + {packet, 2} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_4_active_once_many_small(doc) -> + ["Test packet option {packet, 4} in active once mode"]; + +packet_4_active_once_many_small(suite) -> + []; + +packet_4_active_once_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 4}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_4 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_once_packet, + [Data, ?MANY]}}, + {options, [{active, once}, + {packet, 4} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_4_active_once_some_big(doc) -> + ["Test packet option {packet, 4} in active once mode"]; + +packet_4_active_once_some_big(suite) -> + []; + +packet_4_active_once_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_4 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_once_packet, + [Data, ?SOME]}}, + {options, [{active, once}, + {packet, 4} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_raw_active_many_small(doc) -> + ["Test packet option {packet, raw} in active mode."]; + +packet_raw_active_many_small(suite) -> + []; + +packet_raw_active_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, raw}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, active_raw, + [Data, ?MANY]}}, + {options, [{active, true}, + {packet, raw} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- +packet_raw_active_some_big(doc) -> + ["Test packet option {packet, raw} in active mode."]; + +packet_raw_active_some_big(suite) -> + []; + +packet_raw_active_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, active_raw, [Data, ?SOME]}}, + {options, [{active, true}, + {packet, raw} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_0_active_many_small(doc) -> + ["Test packet option {packet, 0} in active mode."]; + +packet_0_active_many_small(suite) -> + []; + +packet_0_active_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 0}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, active_raw, + [Data, ?MANY]}}, + {options, [{active, true}, + {packet, 0} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_0_active_some_big(doc) -> + ["Test packet option {packet, 0} in active mode."]; + +packet_0_active_some_big(suite) -> + []; + +packet_0_active_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_raw ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, active_raw, + [Data, ?SOME]}}, + {options, [{active, true}, + {packet, 0} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- +packet_1_active_many_small(doc) -> + ["Test packet option {packet, 1} in active mode."]; + +packet_1_active_many_small(suite) -> + []; + +packet_1_active_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 1}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_1 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_packet, [Data, ?MANY]}}, + {options, [{active, true}, + {packet, 1} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_1_active_some_big(doc) -> + ["Test packet option {packet, 1} in active mode."]; + +packet_1_active_some_big(suite) -> + []; + +packet_1_active_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(255, "1")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_1 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_packet, [Data, ?SOME]}}, + {options, [{active, true}, + {packet, 1} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_2_active_many_small(doc) -> + ["Test packet option {packet, 2} in active mode"]; + +packet_2_active_many_small(suite) -> + []; + +packet_2_active_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 2}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_2 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_packet, [Data, ?MANY]}}, + {options, [{active, true}, + {packet, 2} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_2_active_some_big(doc) -> + ["Test packet option {packet, 2} in active mode"]; + +packet_2_active_some_big(suite) -> + []; + +packet_2_active_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_2 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_packet, [Data, ?SOME]}}, + {options, [{active, true}, + {packet, 2} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +packet_4_active_many_small(doc) -> + ["Test packet option {packet, 4} in active mode"]; + +packet_4_active_many_small(suite) -> + []; + +packet_4_active_many_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "Packet option is {packet, 4}", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_4 ,[Data, ?MANY]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_packet, [Data, ?MANY]}}, + {options, [{active, true}, + {packet, 4} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- +packet_4_active_some_big(doc) -> + ["Test packet option {packet, 4} in active mode"]; + +packet_4_active_some_big(suite) -> + []; + +packet_4_active_some_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = lists:append(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_4 ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, + active_packet, [Data, ?SOME]}}, + {options, [{active, true}, + {packet, 4} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + + + +%%-------------------------------------------------------------------- +packet_wait_active(doc) -> + ["Test waiting when complete packages have not arrived"]; + +packet_wait_active(suite) -> + []; + +packet_wait_active(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = list_to_binary(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_incomplete ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, active_packet, + [binary_to_list(Data), ?SOME]}}, + {options, [{active, true}, + {packet, 4} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +%%-------------------------------------------------------------------- +packet_wait_passive(doc) -> + ["Test waiting when complete packages have not arrived"]; + +packet_wait_passive(suite) -> + []; + +packet_wait_passive(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = list_to_binary(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_incomplete ,[Data, ?SOME]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, + [binary_to_list(Data), ?SOME]}}, + {options, [{active, false}, + {packet, 4} | + ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). +%%-------------------------------------------------------------------- +packet_baddata_active(doc) -> + ["Test that if a bad packet arrives error msg is sent and socket is closed"]; +packet_baddata_active(suite) -> + []; + +packet_baddata_active(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = list_to_binary(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_incomplete ,[Data, 1]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, active_packet, [Data, 1]}}, + {options, [{active, true}, + {packet, cdr} | + ClientOpts]}]), + receive + {Client, {other, {ssl_error, _Socket, {invalid_packet, _}},{error,closed},1}} -> ok; + Unexpected -> + test_server:fail({unexpected, Unexpected}) + end, + + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). +%%-------------------------------------------------------------------- +packet_baddata_passive(doc) -> + ["Test that if a bad packet arrives error msg is sent and socket is closed"]; + +packet_baddata_passive(suite) -> + []; + +packet_baddata_passive(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = list_to_binary(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_incomplete ,[Data, 1]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, + [Data, 1]}}, + {options, [{active, false}, + {packet, cdr} | + ClientOpts]}]), + + receive + {Client, {other, {error, {invalid_packet, _}},{error,closed}, 1}} -> ok; + Unexpected -> + test_server:fail({unexpected, Unexpected}) + end, + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). +%%-------------------------------------------------------------------- +packet_size_active(doc) -> + ["Test that if a packet of size larger than packet_size arrives error msg is sent and socket is closed"]; +packet_size_active(suite) -> + []; + +packet_size_active(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = list_to_binary(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_incomplete ,[Data, 1]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, active_packet, [Data, 1]}}, + {options, [{active, true}, + {packet, 4}, {packet_size, 10} | + ClientOpts]}]), + receive + {Client, {other, {ssl_error, _Socket, {invalid_packet, _}},{error,closed},1}} -> ok; + Unexpected -> + test_server:fail({unexpected, Unexpected}) + end, + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). +%%-------------------------------------------------------------------- +packet_size_passive(doc) -> + ["Test that if a packet of size larger than packet_size arrives error msg is sent and socket is closed"]; +packet_size_passive(suite) -> + []; + +packet_size_passive(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = list_to_binary(lists:duplicate(100, "1234567890")), + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, send_incomplete ,[Data, 1]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, passive_recv_packet, [Data, 1]}}, + {options, [{active, false}, + {packet, 4}, {packet_size, 30} | + ClientOpts]}]), + receive + {Client, {other, {error, {invalid_packet, _}},{error,closed},1}} -> ok; + Unexpected -> + test_server:fail({unexpected, Unexpected}) + end, + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). +%%-------------------------------------------------------------------- +%% Internal functions + +send_raw(_,_, 0) -> + no_result_msg; +send_raw(Socket, Data, N) -> + ssl:send(Socket, Data), + send_raw(Socket, Data, N-1). + +passive_raw(_, _, 0) -> + ok; +passive_raw(Socket, Data, N) -> + Length = length(Data), + {ok, Data} = ssl:recv(Socket, Length), + passive_raw(Socket, Data, N-1). + +passive_recv_packet(_, _, 0) -> + ok; +passive_recv_packet(Socket, Data, N) -> + case ssl:recv(Socket, 0) of + {ok, Data} -> + passive_recv_packet(Socket, Data, N-1); + Other -> + {other, Other, ssl:session_info(Socket), N} + end. + +send_1(_,_, 0) -> + no_result_msg; +send_1(Socket, Data, N) -> + Length = length(Data), + ssl:send(Socket, [?byte(Length), Data]), + send_1(Socket, Data, N-1). + +send_2(_,_, 0) -> + no_result_msg; +send_2(Socket, Data, N) -> + Length = length(Data), + ssl:send(Socket, [?uint16(Length), Data]), + send_2(Socket, Data, N-1). + +send_4(_,_, 0) -> + no_result_msg; +send_4(Socket, Data, N) -> + Length = length(Data), + ssl:send(Socket, [?uint32(Length), Data]), + send_4(Socket, Data, N-1). + +send_incomplete(Socket, Data, N) -> + send_incomplete(Socket, Data, N, <<>>). +send_incomplete(Socket, _Data, 0, Prev) -> + ssl:send(Socket, Prev), + no_result_msg; +send_incomplete(Socket, Data, N, Prev) -> + Length = size(Data), + <<Part1:42/binary, Rest/binary>> = Data, + ssl:send(Socket, [Prev, ?uint32(Length), Part1]), + send_incomplete(Socket, Data, N-1, Rest). + +active_once_raw(Socket, Data, N) -> + active_once_raw(Socket, Data, N, []). + +active_once_raw(_, _, 0, _) -> + ok; +active_once_raw(Socket, Data, N, Acc) -> + receive + {ssl, Socket, Data} -> + ssl:setopts(Socket, [{active, once}]), + active_once_raw(Socket, Data, N-1, []); + {ssl, Socket, Other} -> + case Acc ++ Other of + Data -> + ssl:setopts(Socket, [{active, once}]), + active_once_raw(Socket, Data, N-1, []); + NewAcc -> + ssl:setopts(Socket, [{active, once}]), + active_once_raw(Socket, Data, N, NewAcc) + end + end. + +active_once_packet(_,_, 0) -> + ok; +active_once_packet(Socket, Data, N) -> + receive + {ssl, Socket, Data} -> + ok + end, + ssl:setopts(Socket, [{active, once}]), + active_once_packet(Socket, Data, N-1). + +active_raw(Socket, Data, N) -> + active_raw(Socket, Data, N, []). + +active_raw(_, _, 0, _) -> + ok; +active_raw(Socket, Data, N, Acc) -> + receive + {ssl, Socket, Data} -> + active_raw(Socket, Data, N-1, []); + {ssl, Socket, Other} -> + case Acc ++ Other of + Data -> + active_raw(Socket, Data, N-1, []); + NewAcc -> + active_raw(Socket, Data, NewAcc) + end + end. + +active_packet(_, _, 0) -> + ok; +active_packet(Socket, Data, N) -> + receive + {ssl, Socket, Data} -> + active_packet(Socket, Data, N -1); + Other -> + {other, Other, ssl:session_info(Socket),N} + end. diff --git a/lib/ssl/test/ssl_payload_SUITE.erl b/lib/ssl/test/ssl_payload_SUITE.erl new file mode 100644 index 0000000000..a0aa92bdf2 --- /dev/null +++ b/lib/ssl/test/ssl_payload_SUITE.erl @@ -0,0 +1,726 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2008-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +-module(ssl_payload_SUITE). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include("test_server.hrl"). + +-define(TIMEOUT, 600000). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initialization before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + crypto:start(), + ssl:start(), + make_certs:all(?config(data_dir, Config), ?config(priv_dir, Config)), + ssl_test_lib:cert_options(Config). + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ssl:stop(), + crypto:stop(). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initialization before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initialization before each test case +%%-------------------------------------------------------------------- +init_per_testcase(_TestCase, Config0) -> + Config = lists:keydelete(watchdog, 1, Config0), + Dog = ssl_test_lib:timetrap(?TIMEOUT), + [{watchdog, Dog} | Config]. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, Config) -> + Dog = ?config(watchdog, Config), + case Dog of + undefined -> + ok; + _ -> + test_server:timetrap_cancel(Dog) + end. + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test payload over ssl in all socket modes, active, active_once," + "and passive mode."]; + +all(suite) -> + [server_echos_passive_small, server_echos_active_once_small, + server_echos_active_small, + client_echos_passive_small, client_echos_active_once_small, + client_echos_active_small, + server_echos_passive_big, server_echos_active_once_big, + server_echos_active_big, + client_echos_passive_big, client_echos_active_once_big, + client_echos_active_big, + server_echos_passive_huge, server_echos_active_once_huge, + server_echos_active_huge, + client_echos_passive_huge, client_echos_active_once_huge, + client_echos_active_huge + ]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- +server_echos_passive_small(doc) -> + ["Client sends 1000 bytes in passive mode to server, that receives them, " + "sends them back, and closes."]; + +server_echos_passive_small(suite) -> + []; + +server_echos_passive_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_passive(Str, 1000, ClientOpts, ServerOpts, + ClientNode, ServerNode, Hostname). + +%%-------------------------------------------------------------------- + +server_echos_active_once_small(doc) -> + ["Client sends 1000 bytes in active once mode to server, that receives " + " them, sends them back, and closes."]; + +server_echos_active_once_small(suite) -> + []; + +server_echos_active_once_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_active_once(Str, 1000, ClientOpts, ServerOpts, + ClientNode, ServerNode, Hostname). + +%%-------------------------------------------------------------------- + +server_echos_active_small(doc) -> + ["Client sends 1000 bytes in active mode to server, that receives them, " + "sends them back, and closes."]; + +server_echos_active_small(suite) -> + []; + +server_echos_active_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_active(Str, 1000, ClientOpts, ServerOpts, + ClientNode, ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_passive_small(doc) -> + ["Server sends 1000 bytes in passive mode to client, that receives them, " + "sends them back, and closes."]; + +client_echos_passive_small(suite) -> + []; + +client_echos_passive_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + client_echos_passive(Str, 1000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_active_once_small(doc) -> + ["Server sends 1000 bytes in active once mode to client, that receives " + "them, sends them back, and closes."]; + +client_echos_active_once_small(suite) -> + []; + +client_echos_active_once_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + client_echos_active_once(Str, 1000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_active_small(doc) -> + ["Server sends 1000 bytes in active mode to client, that receives them, " + "sends them back, and closes."]; + +client_echos_active_small(suite) -> + []; + +client_echos_active_small(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + client_echos_active(Str, 1000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + + +%%-------------------------------------------------------------------- +server_echos_passive_big(doc) -> + ["Client sends 50000 bytes to server in passive mode, that receives them, " + "sends them back, and closes."]; + +server_echos_passive_big(suite) -> + []; + +server_echos_passive_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_passive(Str, 50000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- + +server_echos_active_once_big(doc) -> + ["Client sends 50000 bytes to server in active once mode, that receives " + "them, sends them back, and closes."]; + +server_echos_active_once_big(suite) -> + []; + +server_echos_active_once_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_active_once(Str, 50000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- + +server_echos_active_big(doc) -> + ["Client sends 50000 bytes to server in active once mode, that receives " + " them, sends them back, and closes."]; + +server_echos_active_big(suite) -> + []; + +server_echos_active_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_active(Str, 50000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_passive_big(doc) -> + ["Server sends 50000 bytes to client in passive mode, that receives them, " + "sends them back, and closes."]; + +client_echos_passive_big(suite) -> + []; + +client_echos_passive_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + client_echos_passive(Str, 50000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_active_once_big(doc) -> + ["Server sends 50000 bytes to client in active once mode, that receives" + " them, sends them back, and closes."]; + +client_echos_active_once_big(suite) -> + []; + +client_echos_active_once_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + client_echos_active_once(Str, 50000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_active_big(doc) -> + ["Server sends 50000 bytes to client in active mode, that receives them, " + "sends them back, and closes."]; + +client_echos_active_big(suite) -> + []; + +client_echos_active_big(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + client_echos_active(Str, 50000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +server_echos_passive_huge(doc) -> + ["Client sends 500000 bytes to server in passive mode, that receives " + " them, sends them back, and closes."]; + +server_echos_passive_huge(suite) -> + []; + +server_echos_passive_huge(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_passive(Str, 500000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +server_echos_active_once_huge(doc) -> + ["Client sends 500000 bytes to server in active once mode, that receives " + "them, sends them back, and closes."]; + +server_echos_active_once_huge(suite) -> + []; + +server_echos_active_once_huge(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_active_once(Str, 500000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +server_echos_active_huge(doc) -> + ["Client sends 500000 bytes to server in active mode, that receives them, " + "sends them back, and closes."]; + +server_echos_active_huge(suite) -> + []; + +server_echos_active_huge(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + + server_echos_active(Str, 500000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_passive_huge(doc) -> + ["Server sends 500000 bytes to client in passive mode, that receives " + "them, sends them back, and closes."]; + +client_echos_passive_huge(suite) -> + []; + +client_echos_passive_huge(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + client_echos_passive(Str, 500000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_active_once_huge(doc) -> + ["Server sends 500000 bytes to client in active once mode, that receives " + "them, sends them back, and closes."]; + +client_echos_active_once_huge(suite) -> + []; + +client_echos_active_once_huge(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + client_echos_active_once(Str, 500000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- +client_echos_active_huge(doc) -> + ["Server sends 500000 bytes to client in active mode, that receives them, " + "sends them back, and closes."]; + +client_echos_active_huge(suite) -> + []; + +client_echos_active_huge(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Str = "1234567890", + client_echos_active(Str, 500000, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname). + +%%-------------------------------------------------------------------- + +server_echos_passive(Data, Length, ClientOpts, ServerOpts, + ClientNode, ServerNode, Hostname) -> + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, echoer, + [Data, Length]}}, + {options, + [{active, false},{mode, binary} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, sender, + [Data, + Length]}}, + {options, + [{active, false}, {mode, binary} | + ClientOpts]}]), + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +server_echos_active_once(Data, Length, ClientOpts, ServerOpts, ClientNode, + ServerNode, Hostname) -> + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, echoer_once, + [Data, Length]}}, + {options, [{active, once}, + {mode, binary}| + ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, sender_once, + [Data, Length]}}, + {options, [{active, once}, + {mode, binary} | + ClientOpts]}]), + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +server_echos_active(Data, Length, ClientOpts, ServerOpts, + ClientNode, ServerNode, Hostname) -> + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, echoer_active, + [Data, Length]}}, + {options, + [{active, true}, + {mode, binary} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, sender_active, + [Data, + Length]}}, + {options, + [{active, true}, {mode, binary} + | ClientOpts]}]), + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +client_echos_passive(Data, Length, ClientOpts, ServerOpts, + ClientNode, ServerNode, Hostname) -> + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, sender, + [Data, Length]}}, + {options, + [{active, false}, {mode, binary} | + ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, echoer, + [Data, + Length]}}, + {options, + [{active, false}, {mode, binary} + | ClientOpts]}]), + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +client_echos_active_once(Data, Length, + ClientOpts, ServerOpts, ClientNode, ServerNode, + Hostname) -> + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, sender_once, + [Data, Length]}}, + {options, [{active, once}, + {mode, binary} | + ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, echoer_once, + [Data, + Length]}}, + {options,[{active, once}, + {mode, binary} + | ClientOpts]}]), + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +client_echos_active(Data, Length, ClientOpts, ServerOpts, ClientNode, + ServerNode, + Hostname) -> + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, sender_active, + [Data, Length]}}, + {options, [{active, true}, + {mode, binary} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, + {?MODULE, echoer_active, + [Data, + Length]}}, + {options, [{active, true}, + {mode, binary} + | ClientOpts]}]), + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + +send(_, _, _, 0,_) -> + ok; +send(Socket, Data, Size, Repeate,F) -> + NewData = lists:duplicate(Size div 10, Data), + ssl:send(Socket, NewData), + F(), + send(Socket, Data, Size, Repeate - 1,F). + +sender(Socket, Data, Size) -> + ok = send(Socket, Data, Size, 100, fun() -> do_recv(Socket, Data, Size, <<>>, false) end), + test_server:format("Sender recv: ~p~n", [ssl:getopts(Socket, [active])]), + ok. + +sender_once(Socket, Data, Size) -> + send(Socket, Data, Size, 100, + fun() -> do_active_once(Socket, Data, Size, <<>>, false) end), + test_server:format("Sender active once: ~p~n", + [ssl:getopts(Socket, [active])]), + ok. + +sender_active(Socket, Data, Size) -> + F = fun() -> do_active(Socket, Data, Size, <<>>, false) end, + send(Socket, Data, Size, 100, F), + test_server:format("Sender active: ~p~n", [ssl:getopts(Socket, [active])]), + ok. + +echoer(Socket, Data, Size) -> + test_server:format("Echoer recv: ~p~n", [ssl:getopts(Socket, [active])]), + echo(fun() -> do_recv(Socket, Data, Size, <<>>, true) end, 100). + +echoer_once(Socket, Data, Size) -> + test_server:format("Echoer active once: ~p ~n", + [ssl:getopts(Socket, [active])]), + echo(fun() -> do_active_once(Socket, Data, Size, <<>>, true) end, 100). + +echoer_active(Socket, Data, Size) -> + test_server:format("Echoer active: ~p~n", [ssl:getopts(Socket, [active])]), + echo(fun() -> do_active(Socket, Data, Size, <<>>, true) end, 100). + +echo(_Fun, 0) -> ok; +echo(Fun, N) -> + Fun(), + echo(Fun, N-1). + + +do_recv(_Socket, _Data, 0, _Acc, true) -> + ok; +do_recv(_Socket, Data, 0, Acc, false) -> + Data = lists:sublist(binary_to_list(Acc), 10); + +do_recv(Socket, Data, Size, Acc, Echo) -> + {ok, NewData} = ssl:recv(Socket, 0), + NewSize = size(NewData), + case Echo of + true -> + ssl:send(Socket, NewData), + NewSize = size(NewData), + do_recv(Socket, Data, Size - NewSize, [], Echo); + false -> + case size(Acc) < 10 of + true -> + do_recv(Socket, Data, Size - NewSize, + <<Acc/binary, NewData/binary>>, Echo); + false -> + do_recv(Socket, Data, Size - NewSize, Acc, Echo) + end + end. + +do_active_once(_Socket, _Data, 0, _Acc, true) -> + ok; +do_active_once(_Socket, Data, 0, Acc, false) -> + Data = lists:sublist(binary_to_list(Acc), 10); + +do_active_once(Socket, Data, Size, Acc, Echo) -> + receive + {ssl, Socket, NewData} -> + NewSize = size(NewData), + case Echo of + true -> + ssl:send(Socket, NewData), + ssl:setopts(Socket, [{active, once}]), + do_active_once(Socket, Data, Size - NewSize, [], Echo); + false -> + case size(Acc) < 10 of + true -> + ssl:setopts(Socket, [{active, once}]), + do_active_once(Socket, Data, Size - NewSize, + <<Acc/binary, NewData/binary>>, + Echo); + false -> + ssl:setopts(Socket, [{active, once}]), + do_active_once(Socket, Data, + Size - NewSize, Acc, Echo) + end + end + end. + +do_active(_Socket, _Data, 0, _Acc, true) -> + ok; +do_active(_Socket, Data, 0, Acc, false) -> + Data = lists:sublist(binary_to_list(Acc), 10); + +do_active(Socket, Data, Size, Acc, Echo) -> + receive + {ssl, Socket, NewData} -> + NewSize = size(NewData), + case Echo of + true -> + ssl:send(Socket, NewData), + do_active(Socket, Data, Size - NewSize, [], Echo); + false -> + case size(Acc) < 10 of + true -> + do_active(Socket, Data, Size - NewSize, + <<Acc/binary, NewData/binary>>, + Echo); + false -> + do_active(Socket, Data, + Size - NewSize, Acc, Echo) + end + end + end. diff --git a/lib/ssl/test/ssl_test_MACHINE.erl b/lib/ssl/test/ssl_test_MACHINE.erl new file mode 100644 index 0000000000..e75f7079ed --- /dev/null +++ b/lib/ssl/test/ssl_test_MACHINE.erl @@ -0,0 +1,935 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2003-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(ssl_test_MACHINE). + +-export([many_conns/0, mk_ssl_cert_opts/1, test_one_listener/7, + test_server_only/6]). + +-export([process_init/3, do_start/1]). + + +-include("test_server.hrl"). +-include("ssl_test_MACHINE.hrl"). + +-define(WAIT_TIMEOUT, 10000). +-define(CLOSE_WAIT, 1000). + +%% +%% many_conns() -> ManyConnections +%% +%% Choose a suitable number of "many connections" depending on platform +%% and current limit for file descriptors. +%% +many_conns() -> + case os:type() of + {unix,_} -> many_conns_1(); + _ -> 10 + end. + +many_conns_1() -> + N0 = os:cmd("ulimit -n"), + N1 = lists:reverse(N0), + N2 = lists:dropwhile(fun($\r) -> true; + ($\n) -> true; + (_) -> false + end, N1), + N = list_to_integer(lists:reverse(N2)), + lists:min([(N - 10) div 2, 501]). + +%% +%% mk_ssl_cert_opts(Config) -> {ok, {COpts, SOpts}} +%% +%% +mk_ssl_cert_opts(_Config) -> + Dir = filename:join([code:lib_dir(ssl), "examples", "certs", "etc"]), + COpts = [{cacertfile, filename:join([Dir, "client", "cacerts.pem"])}, + {certfile, filename:join([Dir, "client", "cert.pem"])}, + {keyfile, filename:join([Dir, "client", "key.pem"])}], + SOpts = [{cacertfile, filename:join([Dir, "server", "cacerts.pem"])}, + {certfile, filename:join([Dir, "server", "cert.pem"])}, + {keyfile, filename:join([Dir, "server", "key.pem"])}], + {ok, {COpts, SOpts}}. + +%% +%% Cmds: +%% {protomod, gen_tcp | ssl} default = ssl +%% {serialize_accept, true | false} default = false +%% {timeout, Timeout} +%% {sockopts, Opts} +%% {sslopts, Opts} +%% {protocols, Protocols} [sslv2|sslv3|tlsv1] +%% {listen, Port} +%% {lsock, LSock} listen socket for acceptor +%% peercert +%% accept +%% {connect, {Host, Port}} +%% {recv, N} +%% {send, N} +%% {echo, N} async echo back +%% close close connection socket +%% {close, Time} wait time and then close socket +%% lclose close listen socket +%% await_close wait for close +%% wait_sync listener's wait for sync from parent +%% connection_info +%% {exit, Reason} exit +%% +%% +%% We cannot have more than `backlog' acceptors at the same time. +%% + + +%% +%% test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, Suite, Config) +%% +%% Creates one client and one server node, and runs one listener on +%% the server node (according to LCmds), and creates NConns acceptors +%% on the server node, and the same number of connectors on the client +%% node. The acceptors and and connectors execute according to ACmds +%% and CCmds, respectively. +%% +%% It is a good idea to have the backlog size in LCmds set to +%% be at least as large as NConns. +%% +test_one_listener(NConns, LCmds0, ACmds0, CCmds0, Timeout, Suite, Config) -> + ProtoMod = get_protomod(Config), + SerializeAccept = get_serialize_accept(Config), + ?line {ok, {CNode, SNode}} = start_client_server_nodes(Suite), + case ProtoMod of + ssl -> + ?line ok = start_ssl([CNode, SNode], Config); + gen_tcp -> + ok + end, + LCmds = [{protomod, ProtoMod}| LCmds0], + ACmds = [{protomod, ProtoMod}, {serialize_accept, SerializeAccept}| + ACmds0], + CCmds = [{protomod, ProtoMod}| CCmds0], + + ?line {ok, Listener} = start_process(SNode, self(), LCmds, listener), + ?line {ok, LSock} = wait_lsock(Listener, ?WAIT_TIMEOUT), + ?line {ok, Accs0} = start_processes(NConns, SNode, self(), + [{lsock, LSock}| ACmds], acceptor), + Accs = case ProtoMod of + gen_tcp -> + [Acc1| Accs1] = Accs0, + Acc1 ! {continue_accept, self()}, + Accs1; + ssl -> + Accs0 + end, + ?line {ok, Conns} = start_processes(NConns, CNode, self(), + CCmds, connector), + ?line case wait_ack(Accs, Accs0 ++ Conns, Timeout) of + ok -> + ?line sync([Listener]), + ?line wait_ack([], [Listener], ?WAIT_TIMEOUT); + {error, Reason} -> + ?line stop_node(SNode), + ?line stop_node(CNode), + exit(Reason) + end, + ?line stop_node(SNode), + ?line stop_node(CNode), + ok. + +%% +%% test_server_only(NConns, LCmds, ACmds, Timeout, Suite, Config) +%% +%% Creates only one server node, and runs one listener on +%% the server node (according to LCmds), and creates NConns acceptors +%% on the server node. The acceptors execute according to ACmds. +%% There are no connectors. +%% +test_server_only(NConns, LCmds0, ACmds0, Timeout, Suite, Config) -> + ProtoMod = get_protomod(Config), + ?line {ok, SNode} = start_server_node(Suite), + case ProtoMod of + ssl -> + ?line ok = start_ssl([SNode], Config); + gen_tcp -> + ok + end, + LCmds = [{protomod, ProtoMod}| LCmds0], + ACmds = [{protomod, ProtoMod}| ACmds0], + ?line {ok, Listener} = start_process(SNode, self(), LCmds, listener), + ?line {ok, LSock} = wait_lsock(Listener, ?WAIT_TIMEOUT), + ?line {ok, Accs0} = start_processes(NConns, SNode, self(), + [{lsock, LSock}| ACmds], acceptor), + Accs = case ProtoMod of + gen_tcp -> + [Acc1| Accs1] = Accs0, + Acc1 ! {continue_accept, self()}, + Accs1; + ssl -> + Accs0 + end, + ?line case wait_ack(Accs, Accs0, Timeout) of + ok -> + ?line sync([Listener]), + ?line wait_ack([], [Listener], ?WAIT_TIMEOUT); + {error, Reason} -> + ?line stop_node(SNode), + exit(Reason) + end, + ?line stop_node(SNode), + ok. + +%% +%% start_client_server_nodes(Suite) -> {ok, {CNode, SNode}} +%% +start_client_server_nodes(Suite) -> + {ok, CNode} = start_client_node(Suite), + {ok, SNode} = start_server_node(Suite), + {ok, {CNode, SNode}}. + +start_client_node(Suite) -> + start_node(lists:concat([Suite, "_client"])). + +start_server_node(Suite) -> + start_node(lists:concat([Suite, "_server"])). + +%% +%% start_ssl(Nodes, Config) +%% +start_ssl(Nodes, Config) -> + Env0 = lists:flatten([Env00 || {env, Env00} <- Config]), + Env1 = case os:getenv("SSL_DEBUG") of + false -> + []; + _ -> + Dir = ?config(priv_dir, Config), + [{debug, true}, {debugdir, Dir}] + end, + Env = Env0 ++ Env1, + lists:foreach( + fun(Node) -> rpc:call(Node, ?MODULE, do_start, [Env]) end, Nodes), + ok. + +do_start(Env) -> + application:load(ssl), + lists:foreach( + fun({Par, Val}) -> application:set_env(ssl, Par, Val) end, Env), + application:start(ssl), + application:start(crypto). + +%% +%% start_node(Name) -> {ok, Node} +%% start_node(Name, ExtraParams) -> {ok, Node} +%% +start_node(Name) -> + start_node(Name, []). +start_node(Name, ExtraParams) -> + Params = "-pa " ++ filename:dirname(code:which(?MODULE)) ++ " " ++ + ExtraParams, + test_server:start_node(Name, slave, [{args, Params}]). + +stop_node(Node) -> + test_server:stop_node(Node). + +%% +%% start_processes(N, Node, Parent, Cmds, Type) -> {ok, Pids} +%% +start_processes(M, Node, Parent, Cmds, Type) -> + start_processes1(0, M, Node, Parent, Cmds, Type, []). +start_processes1(M, M, _, _, _, _, Pids) -> + {ok, lists:reverse(Pids)}; +start_processes1(N, M, Node, Parent, Cmds, Type, Pids) -> + {ok, Pid} = start_process(Node, Parent, Cmds, {Type, N + 1}), + start_processes1(N + 1, M, Node, Parent, Cmds, Type, [Pid| Pids]). + +%% +%% start_process(Node, Parent, Cmds, Type) -> {ok, Pid} +%% +start_process(Node, Parent, Cmds0, Type) -> + Cmds = case os:type() of + {win32, _} -> + lists:map(fun(close) -> {close, ?CLOSE_WAIT}; + (Term) -> Term end, Cmds0); + _ -> + Cmds0 + end, + Pid = spawn_link(Node, ?MODULE, process_init, [Parent, Cmds, Type]), + {ok, Pid}. + +process_init(Parent, Cmds, Type) -> + ?debug("#### ~w start~n", [{Type, self()}]), + pre_main_loop(Cmds, #st{parent = Parent, type = Type}). + +%% +%% pre_main_loop +%% +pre_main_loop([], St) -> + ?debug("#### ~w end~n", [{St#st.type, self()}]), + main_loop([], St); +pre_main_loop(Cmds, St) -> + ?debug("#### ~w -> ~w~n", + [{St#st.type, self(), St#st.sock, St#st.port, + St#st.peer, St#st.active}, hd(Cmds)]), + main_loop(Cmds, St). + +%% +%% main_loop(Cmds, St) +%% +main_loop([{protomod, ProtoMod}| Cmds], St) -> + pre_main_loop(Cmds, St#st{protomod = ProtoMod}); + +main_loop([{serialize_accept, Bool}| Cmds], St) -> + pre_main_loop(Cmds, St#st{serialize_accept = Bool}); + +main_loop([{sockopts, Opts}| Cmds], St) -> + pre_main_loop(Cmds, St#st{sockopts = Opts}); + +main_loop([{sslopts, Opts}| Cmds], St) -> + pre_main_loop(Cmds, St#st{sslopts = Opts}); + +main_loop([{protocols, Protocols}| Cmds], St) -> + pre_main_loop(Cmds, St#st{protocols = Protocols}); + +main_loop([{timeout, T}| Cmds], St) -> + pre_main_loop(Cmds, St#st{timeout = T}); + +main_loop([{lsock, LSock}| Cmds], St) -> + pre_main_loop(Cmds, St#st{lsock = LSock}); + +main_loop([{seed, Data}| Cmds], St) -> + case ssl:seed("tjosan") of + ok -> + pre_main_loop(Cmds, St); + {error, Reason} -> + ?error("#### ~w(~w) in seed: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([{listen, Port}| Cmds], St) -> + case listen(St, Port) of + {ok, LSock} -> + ack_lsock(St#st.parent, LSock), + NSt = get_active(St#st{port = Port, sock = LSock, lsock = LSock}), + pre_main_loop(Cmds, St); + {error, Reason} -> + ?error("#### ~w(~w) in listen: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([accept| Cmds], St) -> + case St#st.serialize_accept of + true -> + Parent = St#st.parent, + receive + {continue_accept, Parent} -> + ok + end; + false -> + ok + end, + case accept(St) of + {ok, Sock, Port, Peer} -> + case St#st.serialize_accept of + true -> + St#st.parent ! {one_accept_done, self()}; + false -> + ok + end, + NSt = get_active(St#st{sock = Sock, port = Port, peer = Peer}), + pre_main_loop(Cmds, NSt); + {error, Reason} -> + ?error("#### ~w(~w) in accept: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([accept_timeout| Cmds], St) -> + case accept(St) of + {error, timeout} -> + pre_main_loop(Cmds, St); + {error, Reason} -> + ?error("#### ~w(~w) in accept_timeout: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + + +main_loop([{connect, {Host, Port}}| Cmds], St) -> + case connect(St, Host, Port) of + {ok, Sock, LPort, Peer} -> + NSt = get_active(St#st{sock = Sock, port = LPort, peer = Peer}), + pre_main_loop(Cmds, NSt); + {error, Reason} -> + ?error("#### ~w(~w) in connect: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([connection_info| Cmds], St) -> + case connection_info(St) of + {ok, ProtoInfo} -> + io:fwrite("Got connection_info:~n~p~n", [ProtoInfo]), + pre_main_loop(Cmds, St); + {error, Reason} -> + ?error("#### ~w(~w) in connection_info: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([peercert| Cmds], St) -> + case peercert(St) of + {ok, Cert} -> + io:fwrite("Got cert:~n~p~n", [Cert]), + pre_main_loop(Cmds, St); + {error, Reason} -> + ?error("#### ~w(~w) in peercert: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([nopeercert| Cmds], St) -> + case peercert(St) of + {error, Reason} -> + io:fwrite("Got no cert as expected. reason:~n~p~n", [Reason]), + pre_main_loop(Cmds, St); + {ok, Cert} -> + ?error("#### ~w(~w) in peercert: error: got cert: ~p~n", + [St#st.type, self(), Cert]), + exit(peercert) + end; + +main_loop([{recv, N}| Cmds], St) -> + recv_loop([{recv, N}| Cmds], fun recv/1, St); % Returns to main_loop/2. + +main_loop([{send, N}| Cmds], St) -> + Msg = mk_msg(N), + case send(St, Msg) of + ok -> + pre_main_loop(Cmds, St); + {error, Reason} -> + ?error("#### ~w(~w) in send: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([{echo, N}| Cmds], St) -> + recv_loop([{echo, N}| Cmds], fun echo/1, St); % Returns to main_loop/2. + +main_loop([{close, WaitTime}| Cmds], St) -> + wait(WaitTime), + pre_main_loop([close| Cmds], St); + +main_loop([close| Cmds], St) -> + case close(St) of + ok -> + pre_main_loop(Cmds, St#st{sock = nil}); + {error, Reason} -> + ?error("#### ~w(~w) in close: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([lclose| Cmds], St) -> + case lclose(St) of + ok -> + pre_main_loop(Cmds, St#st{lsock = nil}); + {error, Reason} -> + ?error("#### ~w(~w) in lclose: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([await_close| Cmds], St) -> + case await_close(St) of + ok -> + pre_main_loop(Cmds, St#st{sock = nil}); + {error, Reason} -> + ?error("#### ~w(~w) in await_close: error: ~w~n", + [St#st.type, self(), Reason]), + exit(Reason) + end; + +main_loop([wait_sync| Cmds], St) -> + wait_sync(St), + pre_main_loop(Cmds, St); + +main_loop({exit, Reason}, _St) -> + exit(Reason); + +main_loop([], _St) -> + ok. + +%% +%% recv_loop(Cmds, F, St) +%% +%% F = recv/1 | echo/1 +%% +recv_loop([{_Tag, 0}| Cmds], _, St) -> + pre_main_loop(Cmds, St); +recv_loop([{_Tag, N}| _Cmds], _, St) when N < 0 -> + ?error("#### ~w(~w) in recv_loop: error: too much: ~w~n", + [St#st.type, self(), N]), + exit(toomuch); % XXX or {error, Reason}? +recv_loop([{Tag, N}| Cmds], F, St) -> + case F(St) of + {ok, Len} -> + NSt = St#st{active = new_active(St#st.active)}, + if + Len == N -> + pre_main_loop(Cmds, NSt); + true -> + ?debug("#### ~w -> ~w~n", + [{NSt#st.type, self(), NSt#st.sock, NSt#st.port, + NSt#st.peer, NSt#st.active}, {Tag, N - Len}]), + recv_loop([{Tag, N - Len}| Cmds], F, NSt) + end; + {error, Reason} -> + ?error("#### ~w(~w) in recv_loop: error: ~w, ~w bytes remain~n", + [St#st.type, self(), Reason, N]), + exit(Reason) + end. + +new_active(once) -> + false; +new_active(A) -> + A. + +get_active(St) -> + A = case proplists:get_value(active, St#st.sockopts, undefined) of + undefined -> + Mod = case St#st.protomod of + ssl -> + ssl; + gen_tcp -> + inet + end, + {ok, [{active, Ax}]} = Mod:getopts(St#st.sock, [active]), + Ax; + Ay -> + Ay + end, + ?debug("#### ~w(~w) get_active: ~p\n", [St#st.type, self(), A]), + St#st{active = A}. + + +%% +%% SOCKET FUNCTIONS +%% + +%% +%% ssl +%% + +%% +%% listen(St, LPort) -> {ok, LSock} | {error, Reason} +%% +listen(St, LPort) -> + case St#st.protomod of + ssl -> + ssl:listen(LPort, St#st.sockopts ++ St#st.sslopts); + gen_tcp -> + gen_tcp:listen(LPort, St#st.sockopts) + end. + +%% +%% accept(St) -> {ok, Sock} | {error, Reason} +%% +accept(St) -> + case St#st.protomod of + ssl -> + case ssl:transport_accept(St#st.lsock, St#st.timeout) of + {ok, Sock} -> + case ssl:ssl_accept(Sock, St#st.timeout) of + ok -> + {ok, Port} = ssl:sockname(Sock), + {ok, Peer} = ssl:peername(Sock), + {ok, Sock, Port, Peer}; + Other -> + Other + end; + Other -> + Other + end; + gen_tcp -> + case gen_tcp:accept(St#st.lsock, St#st.timeout) of + {ok, Sock} -> + {ok, Port} = inet:port(Sock), + {ok, Peer} = inet:peername(Sock), + {ok, Sock, Port, Peer}; + Other -> + Other + end + end. + +%% +%% connect(St, Host, Port) -> {ok, Sock} | {error, Reason} +%% +connect(St, Host, Port) -> + + case St#st.protomod of + ssl -> + case ssl:connect(Host, Port, St#st.sockopts ++ St#st.sslopts, + St#st.timeout) of + {ok, Sock} -> + {ok, LPort} = ssl:sockname(Sock), + {ok, Peer} = ssl:peername(Sock), + {ok, Sock, LPort, Peer}; + Other -> + Other + end; + gen_tcp -> + case gen_tcp:connect(Host, Port, St#st.sockopts, St#st.timeout) of + {ok, Sock} -> + {ok, LPort} = inet:port(Sock), + {ok, Peer} = inet:peername(Sock), + {ok, Sock, LPort, Peer}; + Other -> + Other + end + end. + +%% +%% peercert(St) -> {ok, Cert} | {error, Reason} +%% +peercert(St) -> + case St#st.protomod of + ssl -> + ssl:peercert(St#st.sock, [ssl]); + gen_tcp -> + {ok, <<>>} + end. + +%% +%% connection_info(St) -> {ok, ProtoInfo} | {error, Reason} +%% +connection_info(St) -> + case St#st.protomod of + ssl -> + case ssl:connection_info(St#st.sock) of + Res = {ok, {Proto, _}} -> + case St#st.protocols of + [] -> + Res; + Protocols -> + case lists:member(Proto, Protocols) of + true -> + Res; + false -> + {error, Proto} + end + end; + Error -> + Error + end; + gen_tcp -> + {ok, <<>>} + end. + +%% +%% close(St) -> ok | {error, Reason} +%% + +close(St) -> + Mod = St#st.protomod, + case St#st.sock of + nil -> + ok; + _ -> + Mod:close(St#st.sock) + end. + +%% +%% lclose(St) -> ok | {error, Reason} +%% +lclose(St) -> + Mod = St#st.protomod, + case St#st.lsock of + nil -> + ok; + _ -> + Mod:close(St#st.lsock) + end. + +%% +%% recv(St) = {ok, Len} | {error, Reason} +%% +recv(St) -> + case do_recv(St) of + {ok, Msg} -> + {ok, length(Msg)}; + {error, Reason} -> + {error, Reason} + end. + +do_recv(St) when St#st.active == false -> + %% First check that we do *not* have any ssl/gen_tcp messages in the + %% message queue, then call the receive function. + Sock = St#st.sock, + case St#st.protomod of + ssl -> + receive + M = {ssl, Sock, _Msg} -> + {error, {unexpected_messagex, M}}; + M = {ssl_closed, Sock} -> + {error, {unexpected_message, M}}; + M = {ssl_error, Sock, _Reason} -> + {error, {unexpected_message, M}} + after 0 -> + ssl:recv(St#st.sock, 0, St#st.timeout) + end; + gen_tcp -> + receive + M = {tcp, Sock, _Msg} -> + {error, {unexpected_message, M}}; + M = {tcp_closed, Sock} -> + {error, {unexpected_message, M}}; + M = {tcp_error, Sock, _Reason} -> + {error, {unexpected_message, M}} + after 0 -> + gen_tcp:recv(St#st.sock, 0, St#st.timeout) + end + end; +do_recv(St) -> + Sock = St#st.sock, + Timeout = St#st.timeout, + case St#st.protomod of + ssl -> + receive + {ssl, Sock, Msg} -> + {ok, Msg}; + {ssl_closed, Sock} -> + {error, closed}; + {ssl_error, Sock, Reason} -> + {error, Reason} + after Timeout -> + {error, timeout} + end; + gen_tcp -> + receive + {tcp, Sock, Msg} -> + {ok, Msg}; + {tcp_closed, Sock} -> + {error, closed}; + {tcp_error, Sock, Reason} -> + {error, Reason} + after Timeout -> + {error, timeout} + end + end. + +%% +%% echo(St) = {ok, Len} | {error, Reason} +%% +echo(St) -> + Sock = St#st.sock, + case do_recv(St) of + {ok, Msg} -> + Mod = St#st.protomod, + case Mod:send(Sock, Msg) of + ok -> + {ok, length(Msg)}; + {error, Reason} -> + {error, Reason} + end; + {error, Reason} -> + {error, Reason} + end. + +%% +%% send(St, Msg) -> ok | {error, Reason} +%% +send(St, Msg) -> + Mod = St#st.protomod, + Mod:send(St#st.sock, Msg). + +%% +%% await_close(St) -> ok | {error, Reason} +%% +await_close(St) when St#st.active == false -> + %% First check that we do *not* have any ssl/gen_tcp messages in the + %% message queue, then call the receive function. + Sock = St#st.sock, + Res = case St#st.protomod of + ssl -> + receive + M = {ssl, Sock, _Msg0} -> + {error, {unexpected_message, M}}; + M = {ssl_closed, Sock} -> + {error, {unexpected_message, M}}; + M = {ssl_error, Sock, _Reason} -> + {error, {unexpected_message, M}} + after 0 -> + ok + end; + gen_tcp -> + receive + M = {tcp, Sock, _Msg0} -> + {error, {unexpected_message, M}}; + M = {tcp_closed, Sock} -> + {error, {unexpected_message, M}}; + M = {tcp_error, Sock, _Reason} -> + {error, {unexpected_message, M}} + after 0 -> + ok + end + end, + case Res of + ok -> + Mod = St#st.protomod, + case Mod:recv(St#st.sock, 0, St#st.timeout) of + {ok, _Msg} -> + {error, toomuch}; + {error, _} -> + ok + end; + _ -> + Res + end; +await_close(St) -> + Sock = St#st.sock, + Timeout = St#st.timeout, + case St#st.protomod of + ssl -> + receive + {ssl, Sock, _Msg} -> + {error, toomuch}; + {ssl_closed, Sock} -> + ok; + {ssl_error, Sock, Reason} -> + {error, Reason} + after Timeout -> + {error, timeout} + end; + gen_tcp -> + receive + {tcp, Sock, _Msg} -> + {error, toomuch}; + {tcp_closed, Sock} -> + ok; + {tcp_error, Sock, Reason} -> + {error, Reason} + after Timeout -> + {error, timeout} + end + end. + + +%% +%% HELP FUNCTIONS +%% + +wait_ack(_, [], _) -> + ok; +wait_ack(AccPids0, Pids, Timeout) -> + ?debug("#### CONTROLLER: waiting for ~w~n", [Pids]), + receive + {one_accept_done, Pid} -> + case lists:delete(Pid, AccPids0) of + [] -> + wait_ack([], Pids, Timeout); + [AccPid| AccPids1] -> + AccPid ! {continue_accept, self()}, + wait_ack(AccPids1, Pids, Timeout) + end; + {'EXIT', Pid, normal} -> + wait_ack(AccPids0, lists:delete(Pid, Pids), Timeout); + {'EXIT', Pid, Reason} -> + ?error("#### CONTROLLER got abnormal exit: ~w, ~w~n", + [Pid, Reason]), + {error, Reason} + after Timeout -> + ?error("#### CONTROLLER exiting because of timeout = ~w~n", + [Timeout]), + {error, Timeout} + end. + + +%% +%% ack_lsock(Pid, LSock) +%% +ack_lsock(Pid, LSock) -> + Pid ! {lsock, self(), LSock}. + +wait_lsock(Pid, Timeout) -> + receive + {lsock, Pid, LSock} -> + {ok, LSock} + after Timeout -> + exit(timeout) + end. + +%% +%% sync(Pids) +%% +sync(Pids) -> + lists:foreach(fun (Pid) -> Pid ! {self(), sync} end, Pids). + +%% +%% wait_sync(St) +%% +wait_sync(St) -> + Pid = St#st.parent, + receive + {Pid, sync} -> + ok + end. + +%% +%% wait(Time) +%% +wait(Time) -> + receive + after Time -> + ok + end. + +%% +%% mk_msg(Size) +%% +mk_msg(Size) -> + mk_msg(0, Size, []). + +mk_msg(_, 0, Acc) -> + Acc; +mk_msg(Pos, Size, Acc) -> + C = (((Pos + Size) rem 256) - 1) band 255, + mk_msg(Pos, Size - 1, [C| Acc]). + +%% +%% get_protomod(Config) +%% +get_protomod(Config) -> + case lists:keysearch(protomod, 1, Config) of + {value, {_, ProtoMod}} -> + ProtoMod; + false -> + ssl + end. + +%% +%% get_serialize_accept(Config) +%% +get_serialize_accept(Config) -> + case lists:keysearch(serialize_accept, 1, Config) of + {value, {_, Val}} -> + Val; + false -> + false + end. + diff --git a/lib/ssl/test/ssl_test_MACHINE.hrl b/lib/ssl/test/ssl_test_MACHINE.hrl new file mode 100644 index 0000000000..e78b33f505 --- /dev/null +++ b/lib/ssl/test/ssl_test_MACHINE.hrl @@ -0,0 +1,39 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +-record(st, {protomod = ssl, + serialize_accept = false, + parent = nil, + type = nil, + active = nil, + port = 0, + peer = nil, + lsock = nil, + sock = nil, + timeout = infinity, + sockopts = [], + sslopts = [], + protocols = []}). + +%%-define(debug(X, Y), io:format(X, Y)). +-define(debug(X, Y), ok). +-define(error(X, Y), io:format(X, Y)). + +-define(DEFAULT_TIMEOUT, 240000). + diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl new file mode 100644 index 0000000000..7ed19b3a05 --- /dev/null +++ b/lib/ssl/test/ssl_test_lib.erl @@ -0,0 +1,408 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2008-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +-module(ssl_test_lib). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + + +timetrap(Time) -> + Mul = try + test_server:timetrap_scale_factor() + catch _:_ -> 1 end, + test_server:timetrap(1000+Time*Mul). + +%% For now always run locally +run_where(_) -> + ClientNode = node(), + ServerNode = node(), + {ok, Host} = rpc:call(ServerNode, inet, gethostname, []), + {ClientNode, ServerNode, Host}. + +run_where(_, ipv6) -> + ClientNode = node(), + ServerNode = node(), + {ok, Host} = rpc:call(ServerNode, inet, gethostname, []), + {ClientNode, ServerNode, Host}. + +node_to_hostip(Node) -> + [_ , Host] = string:tokens(atom_to_list(Node), "@"), + {ok, Address} = inet:getaddr(Host, inet), + Address. + +start_server(Args) -> + spawn_link(?MODULE, run_server, [Args]). + +run_server(Opts) -> + Node = proplists:get_value(node, Opts), + Port = proplists:get_value(port, Opts), + Options = proplists:get_value(options, Opts), + Pid = proplists:get_value(from, Opts), + test_server:format("ssl:listen(~p, ~p)~n", [Port, Options]), + {ok, ListenSocket} = rpc:call(Node, ssl, listen, [Port, Options]), + case Port of + 0 -> + {ok, {_, NewPort}} = ssl:sockname(ListenSocket), + Pid ! {self(), {port, NewPort}}; + _ -> + ok + end, + run_server(ListenSocket, Opts). + +run_server(ListenSocket, Opts) -> + Node = proplists:get_value(node, Opts), + Pid = proplists:get_value(from, Opts), + test_server:format("ssl:transport_accept(~p)~n", [ListenSocket]), + {ok, AcceptSocket} = rpc:call(Node, ssl, transport_accept, + [ListenSocket]), + test_server:format("ssl:ssl_accept(~p)~n", [AcceptSocket]), + ok = rpc:call(Node, ssl, ssl_accept, [AcceptSocket]), + {Module, Function, Args} = proplists:get_value(mfa, Opts), + test_server:format("Server: apply(~p,~p,~p)~n", + [Module, Function, [AcceptSocket | Args]]), + case rpc:call(Node, Module, Function, [AcceptSocket | Args]) of + no_result_msg -> + ok; + Msg -> + Pid ! {self(), Msg} + end, + receive + listen -> + run_server(ListenSocket, Opts); + close -> + ok = rpc:call(Node, ssl, close, [AcceptSocket]) + end. + +start_client(Args) -> + spawn_link(?MODULE, run_client, [Args]). + +run_client(Opts) -> + Node = proplists:get_value(node, Opts), + Host = proplists:get_value(host, Opts), + Port = proplists:get_value(port, Opts), + Pid = proplists:get_value(from, Opts), + Options = proplists:get_value(options, Opts), + test_server:format("ssl:connect(~p, ~p, ~p)~n", [Host, Port, Options]), + case rpc:call(Node, ssl, connect, [Host, Port, Options]) of + {ok, Socket} -> + test_server:format("Client: connected~n", []), + case proplists:get_value(port, Options) of + 0 -> + {ok, {_, NewPort}} = ssl:sockname(Socket), + Pid ! {self(), {port, NewPort}}; + _ -> + ok + end, + {Module, Function, Args} = proplists:get_value(mfa, Opts), + test_server:format("Client: apply(~p,~p,~p)~n", + [Module, Function, [Socket | Args]]), + case rpc:call(Node, Module, Function, [Socket | Args]) of + no_result_msg -> + ok; + Msg -> + Pid ! {self(), Msg} + end, + receive + close -> + ok = rpc:call(Node, ssl, close, [Socket]) + end; + {error, Reason} -> + test_server:format("Client: connection failed: ~p ~n", [Reason]), + Pid ! {self(), {error, Reason}} + end. + +close(Pid) -> + Pid ! close. + +check_result(Server, ServerMsg, Client, ClientMsg) -> + receive + {Server, ServerMsg} -> + receive + {Client, ClientMsg} -> + ok; + Unexpected -> + Reason = {{expected, {Client, ClientMsg}}, + {got, Unexpected}}, + test_server:fail(Reason) + end; + {Client, ClientMsg} -> + receive + {Server, ServerMsg} -> + ok; + Unexpected -> + Reason = {{expected, {Server, ClientMsg}}, + {got, Unexpected}}, + test_server:fail(Reason) + end; + {Port, {data,Debug}} when is_port(Port) -> + io:format("openssl ~s~n",[Debug]), + check_result(Server, ServerMsg, Client, ClientMsg); + + Unexpected -> + Reason = {{expected, {Client, ClientMsg}}, + {expected, {Server, ServerMsg}}, {got, Unexpected}}, + test_server:fail(Reason) + end. + +check_result(Pid, Msg) -> + receive + {Pid, Msg} -> + ok; + {Port, {data,Debug}} when is_port(Port) -> + io:format("openssl ~s~n",[Debug]), + check_result(Pid,Msg); + Unexpected -> + Reason = {{expected, {Pid, Msg}}, + {got, Unexpected}}, + test_server:fail(Reason) + end. + +wait_for_result(Server, ServerMsg, Client, ClientMsg) -> + receive + {Server, ServerMsg} -> + receive + {Client, ClientMsg} -> + ok; + Unexpected -> + Unexpected + end; + {Client, ClientMsg} -> + receive + {Server, ServerMsg} -> + ok; + Unexpected -> + Unexpected + end; + {Port, {data,Debug}} when is_port(Port) -> + io:format("openssl ~s~n",[Debug]), + wait_for_result(Server, ServerMsg, Client, ClientMsg); + Unexpected -> + Unexpected + end. + + +wait_for_result(Pid, Msg) -> + receive + {Pid, Msg} -> + ok; + {Port, {data,Debug}} when is_port(Port) -> + io:format("openssl ~s~n",[Debug]), + wait_for_result(Pid,Msg); + Unexpected -> + Unexpected + end. + +cert_options(Config) -> + ClientCaCertFile = filename:join([?config(priv_dir, Config), + "client", "cacerts.pem"]), + ClientCertFile = filename:join([?config(priv_dir, Config), + "client", "cert.pem"]), + ServerCaCertFile = filename:join([?config(priv_dir, Config), + "server", "cacerts.pem"]), + ServerCertFile = filename:join([?config(priv_dir, Config), + "server", "cert.pem"]), + ServerKeyFile = filename:join([?config(priv_dir, Config), + "server", "key.pem"]), + ClientKeyFile = filename:join([?config(priv_dir, Config), + "client", "key.pem"]), + ServerKeyCertFile = filename:join([?config(priv_dir, Config), + "server", "keycert.pem"]), + ClientKeyCertFile = filename:join([?config(priv_dir, Config), + "client", "keycert.pem"]), + + BadCaCertFile = filename:join([?config(priv_dir, Config), + "badcacert.pem"]), + BadCertFile = filename:join([?config(priv_dir, Config), + "badcert.pem"]), + BadKeyFile = filename:join([?config(priv_dir, Config), + "badkey.pem"]), + [{client_opts, [{ssl_imp, new}]}, + {client_verification_opts, [{cacertfile, ClientCaCertFile}, + {certfile, ClientCertFile}, + {keyfile, ClientKeyFile}, + {ssl_imp, new}]}, + {server_opts, [{ssl_imp, new},{reuseaddr, true}, + {certfile, ServerCertFile}, {keyfile, ServerKeyFile}]}, + {server_verification_opts, [{ssl_imp, new},{reuseaddr, true}, + {cacertfile, ServerCaCertFile}, + {certfile, ServerCertFile}, {keyfile, ServerKeyFile}]}, + {client_kc_opts, [{certfile, ClientKeyCertFile}, {ssl_imp, new}]}, + {server_kc_opts, [{ssl_imp, new},{reuseaddr, true}, + {certfile, ServerKeyCertFile}]}, + {client_bad_ca, [{cacertfile, BadCaCertFile}, + {certfile, ClientCertFile}, + {keyfile, ClientKeyFile}, + {ssl_imp, new}]}, + {client_bad_cert, [{cacertfile, ClientCaCertFile}, + {certfile, BadCertFile}, + {keyfile, ClientKeyFile}, + {ssl_imp, new}]}, + {server_bad_ca, [{ssl_imp, new},{cacertfile, BadCaCertFile}, + {certfile, ServerCertFile}, + {keyfile, ServerKeyFile}]}, + {server_bad_cert, [{ssl_imp, new},{cacertfile, ServerCaCertFile}, + {certfile, BadCertFile}, {keyfile, ServerKeyFile}]}, + {server_bad_key, [{ssl_imp, new},{cacertfile, ServerCaCertFile}, + {certfile, ServerCertFile}, {keyfile, BadKeyFile}]} + | Config]. + + +start_upgrade_server(Args) -> + spawn_link(?MODULE, run_upgrade_server, [Args]). + +run_upgrade_server(Opts) -> + Node = proplists:get_value(node, Opts), + Port = proplists:get_value(port, Opts), + TimeOut = proplists:get_value(timeout, Opts, infinity), + TcpOptions = proplists:get_value(tcp_options, Opts), + SslOptions = proplists:get_value(ssl_options, Opts), + Pid = proplists:get_value(from, Opts), + + test_server:format("gen_tcp:listen(~p, ~p)~n", [Port, TcpOptions]), + {ok, ListenSocket} = rpc:call(Node, gen_tcp, listen, [Port, TcpOptions]), + + case Port of + 0 -> + {ok, {_, NewPort}} = inet:sockname(ListenSocket), + Pid ! {self(), {port, NewPort}}; + _ -> + ok + end, + + test_server:format("gen_tcp:accept(~p)~n", [ListenSocket]), + {ok, AcceptSocket} = rpc:call(Node, gen_tcp, accept, [ListenSocket]), + + {ok, SslAcceptSocket} = case TimeOut of + infinity -> + test_server:format("ssl:ssl_accept(~p, ~p)~n", + [AcceptSocket, SslOptions]), + rpc:call(Node, ssl, ssl_accept, + [AcceptSocket, SslOptions]); + _ -> + test_server:format("ssl:ssl_accept(~p, ~p, ~p)~n", + [AcceptSocket, SslOptions, TimeOut]), + rpc:call(Node, ssl, ssl_accept, + [AcceptSocket, SslOptions, TimeOut]) + end, + {Module, Function, Args} = proplists:get_value(mfa, Opts), + Msg = rpc:call(Node, Module, Function, [SslAcceptSocket | Args]), + Pid ! {self(), Msg}, + receive + close -> + ok = rpc:call(Node, ssl, close, [SslAcceptSocket]) + end. + +start_upgrade_client(Args) -> + spawn_link(?MODULE, run_upgrade_client, [Args]). + +run_upgrade_client(Opts) -> + Node = proplists:get_value(node, Opts), + Host = proplists:get_value(host, Opts), + Port = proplists:get_value(port, Opts), + Pid = proplists:get_value(from, Opts), + TcpOptions = proplists:get_value(tcp_options, Opts), + SslOptions = proplists:get_value(ssl_options, Opts), + + test_server:format("gen_tcp:connect(~p, ~p, ~p)~n", + [Host, Port, TcpOptions]), + {ok, Socket} = rpc:call(Node, gen_tcp, connect, [Host, Port, TcpOptions]), + + case proplists:get_value(port, Opts) of + 0 -> + {ok, {_, NewPort}} = inet:sockname(Socket), + Pid ! {self(), {port, NewPort}}; + _ -> + ok + end, + + test_server:format("ssl:connect(~p, ~p)~n", [Socket, SslOptions]), + {ok, SslSocket} = rpc:call(Node, ssl, connect, [Socket, SslOptions]), + + {Module, Function, Args} = proplists:get_value(mfa, Opts), + test_server:format("apply(~p, ~p, ~p)~n", + [Module, Function, [SslSocket | Args]]), + Msg = rpc:call(Node, Module, Function, [SslSocket | Args]), + Pid ! {self(), Msg}, + receive + close -> + ok = rpc:call(Node, ssl, close, [SslSocket]) + end. + +start_server_error(Args) -> + spawn_link(?MODULE, run_server_error, [Args]). + +run_server_error(Opts) -> + Node = proplists:get_value(node, Opts), + Port = proplists:get_value(port, Opts), + Options = proplists:get_value(options, Opts), + Pid = proplists:get_value(from, Opts), + test_server:format("ssl:listen(~p, ~p)~n", [Port, Options]), + case rpc:call(Node, ssl, listen, [Port, Options]) of + {ok, ListenSocket} -> + test_server:sleep(2000), %% To make sure error_client will + %% get {error, closed} and not {error, connection_refused} + test_server:format("ssl:transport_accept(~p)~n", [ListenSocket]), + case rpc:call(Node, ssl, transport_accept, [ListenSocket]) of + {error, _} = Error -> + Pid ! {self(), Error}; + {ok, AcceptSocket} -> + test_server:format("ssl:ssl_accept(~p)~n", [AcceptSocket]), + Error = rpc:call(Node, ssl, ssl_accept, [AcceptSocket]), + Pid ! {self(), Error} + end; + Error -> + Pid ! {self(), Error} + end. + +start_client_error(Args) -> + spawn_link(?MODULE, run_client_error, [Args]). + +run_client_error(Opts) -> + Node = proplists:get_value(node, Opts), + Host = proplists:get_value(host, Opts), + Port = proplists:get_value(port, Opts), + Pid = proplists:get_value(from, Opts), + Options = proplists:get_value(options, Opts), + test_server:format("ssl:connect(~p, ~p, ~p)~n", [Host, Port, Options]), + Error = rpc:call(Node, ssl, connect, [Host, Port, Options]), + Pid ! {self(), Error}. + +inet_port(Pid) when is_pid(Pid)-> + receive + {Pid, {port, Port}} -> + Port + end; + +inet_port(Node) -> + {Port, Socket} = do_inet_port(Node), + rpc:call(Node, gen_tcp, close, [Socket]), + Port. + +do_inet_port(Node) -> + {ok, Socket} = rpc:call(Node, gen_tcp, listen, [0, [{reuseaddr, true}]]), + {ok, Port} = rpc:call(Node, inet, port, [Socket]), + {Port, Socket}. + +no_result(_) -> + no_result_msg. diff --git a/lib/ssl/test/ssl_to_openssl_SUITE.erl b/lib/ssl/test/ssl_to_openssl_SUITE.erl new file mode 100644 index 0000000000..c079e12b83 --- /dev/null +++ b/lib/ssl/test/ssl_to_openssl_SUITE.erl @@ -0,0 +1,772 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2008-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% + +-module(ssl_to_openssl_SUITE). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include("test_server.hrl"). +-include("test_server_line.hrl"). +-include("ssl_pkix.hrl"). + +-define(TIMEOUT, 120000). +-define(SLEEP, 1000). + +%% Test server callback functions +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config) -> Config +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Initialization before the whole suite +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + case os:find_executable("openssl") of + false -> + {skip, "Openssl not found"}; + _ -> + crypto:start(), + ssl:start(), + Result = + (catch make_certs:all(?config(data_dir, Config), + ?config(priv_dir, Config))), + test_server:format("Make certs ~p~n", [Result]), + ssl_test_lib:cert_options(Config) + end. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config) -> _ +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after the whole suite +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ssl:stop(), + crypto:stop(). + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config) -> Config +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Initialization before each test case +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%% Description: Initialization before each test case +%%-------------------------------------------------------------------- +init_per_testcase(_TestCase, Config0) -> + Config = lists:keydelete(watchdog, 1, Config0), + Dog = ssl_test_lib:timetrap(?TIMEOUT), + [{watchdog, Dog} | Config]. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config) -> _ +%% Case - atom() +%% Name of the test case that is about to be run. +%% Config - [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Description: Cleanup after each test case +%%-------------------------------------------------------------------- +end_per_testcase(_TestCase, Config) -> + Dog = ?config(watchdog, Config), + case Dog of + undefined -> + ok; + _ -> + test_server:timetrap_cancel(Dog) + end. + +%%-------------------------------------------------------------------- +%% Function: all(Clause) -> TestCases +%% Clause - atom() - suite | doc +%% TestCases - [Case] +%% Case - atom() +%% Name of a test case. +%% Description: Returns a list of all test cases in this test suite +%%-------------------------------------------------------------------- +all(doc) -> + ["Test erlangs ssl against openssl"]; + +all(suite) -> + [erlang_client_openssl_server, + erlang_server_openssl_client, + ssl3_erlang_client_openssl_server, + ssl3_erlang_server_openssl_client, + ssl3_erlang_client_openssl_server_client_cert, + ssl3_erlang_server_openssl_client_client_cert, + ssl3_erlang_server_erlang_client_client_cert, + tls1_erlang_client_openssl_server, + tls1_erlang_server_openssl_client, + tls1_erlang_client_openssl_server_client_cert, + tls1_erlang_server_openssl_client_client_cert, + tls1_erlang_server_erlang_client_client_cert, + ciphers + ]. + +%% Test cases starts here. +%%-------------------------------------------------------------------- + +erlang_client_openssl_server(doc) -> + ["Test erlang client with openssl server"]; +erlang_client_openssl_server(suite) -> + []; +erlang_client_openssl_server(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_opts, Config), + ClientOpts = ?config(client_opts, Config), + + {ClientNode, _, Hostname} = ssl_test_lib:run_where(Config), + + Data = "From openssl to erlang", + + Port = ssl_test_lib:inet_port(node()), + CertFile = proplists:get_value(certfile, ServerOpts), + KeyFile = proplists:get_value(keyfile, ServerOpts), + + Cmd = "openssl s_server -accept " ++ integer_to_list(Port) ++ + " -cert " ++ CertFile ++ " -key " ++ KeyFile, + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpensslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + + test_server:sleep(?SLEEP), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + erlang_ssl_receive, [Data]}}, + {options, ClientOpts}]), + port_command(OpensslPort, Data), + + ssl_test_lib:check_result(Client, ok), + + %% Clean close down! Server needs to be closed first !! + close_port(OpensslPort), + + ssl_test_lib:close(Client), + process_flag(trap_exit, false), + ok. + + +%%-------------------------------------------------------------------- +erlang_server_openssl_client(doc) -> + ["Test erlang server with openssl client"]; +erlang_server_openssl_client(suite) -> + []; +erlang_server_openssl_client(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_opts, Config), + + {_, ServerNode, _} = ssl_test_lib:run_where(Config), + + Data = "From openssl to erlang", + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, erlang_ssl_receive, [Data]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + + test_server:sleep(?SLEEP), + + Cmd = "openssl s_client -port " ++ integer_to_list(Port) ++ + " -host localhost", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpenSslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + port_command(OpenSslPort, Data), + + ssl_test_lib:check_result(Server, ok), + + ssl_test_lib:close(Server), + + close_port(OpenSslPort), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- +ssl3_erlang_client_openssl_server(doc) -> + ["Test erlang client with openssl server"]; +ssl3_erlang_client_openssl_server(suite) -> + []; +ssl3_erlang_client_openssl_server(Config) when is_list(Config) -> + ServerOpts = ?config(server_opts, Config), + ClientOpts = ?config(client_opts, Config), + + {ClientNode, _, Hostname} = ssl_test_lib:run_where(Config), + + Port = ssl_test_lib:inet_port(node()), + CertFile = proplists:get_value(certfile, ServerOpts), + KeyFile = proplists:get_value(keyfile, ServerOpts), + + Cmd = "openssl s_server -accept " ++ integer_to_list(Port) ++ + " -cert " ++ CertFile ++ " -key " ++ KeyFile ++ " -ssl3", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpensslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + + test_server:sleep(?SLEEP), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + connection_info, [sslv3]}}, + {options, + [{versions, [sslv3]} | ClientOpts]}]), + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Client), + %% Clean close down! + close_port(OpensslPort), + test_server:sleep(?SLEEP), + ok. + +%%-------------------------------------------------------------------- + +ssl3_erlang_server_openssl_client(doc) -> + ["Test erlang server with openssl client"]; +ssl3_erlang_server_openssl_client(suite) -> + []; +ssl3_erlang_server_openssl_client(Config) when is_list(Config) -> + ServerOpts = ?config(server_opts, Config), + + {_, ServerNode, _} = ssl_test_lib:run_where(Config), + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, connection_info, [sslv3]}}, + {options, + [{versions, [sslv3]} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + + test_server:sleep(?SLEEP), + + Cmd = "openssl s_client -port " ++ integer_to_list(Port) ++ + " -host localhost -ssl3", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpenSslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + + ssl_test_lib:check_result(Server, ok), + + close_port(OpenSslPort), %% openssl server first + ssl_test_lib:close(Server), + test_server:sleep(?SLEEP), + ok. + +%%-------------------------------------------------------------------- +ssl3_erlang_client_openssl_server_client_cert(doc) -> + ["Test erlang client with openssl server when client sends cert"]; +ssl3_erlang_client_openssl_server_client_cert(suite) -> + []; +ssl3_erlang_client_openssl_server_client_cert(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_verification_opts, Config), + ClientOpts = ?config(client_verification_opts, Config), + + {ClientNode, _, Hostname} = ssl_test_lib:run_where(Config), + + Data = "From openssl to erlang", + + Port = ssl_test_lib:inet_port(node()), + CaCertFile = proplists:get_value(cacertfile, ServerOpts), + CertFile = proplists:get_value(certfile, ServerOpts), + KeyFile = proplists:get_value(keyfile, ServerOpts), + + Cmd = "openssl s_server -accept " ++ integer_to_list(Port) ++ + " -cert " ++ CertFile ++ " -CAfile " ++ CaCertFile + ++ " -key " ++ KeyFile ++ " -Verify 2 -ssl3", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpensslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + + test_server:sleep(?SLEEP), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + erlang_ssl_receive, [Data]}}, + {options, ClientOpts}]), + port_command(OpensslPort, Data), + + ssl_test_lib:check_result(Client, ok), + + %% Clean close down! + close_port(OpensslPort), + ssl_test_lib:close(Client), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- + +ssl3_erlang_server_openssl_client_client_cert(doc) -> + ["Test erlang server with openssl client when client sends cert"]; +ssl3_erlang_server_openssl_client_client_cert(suite) -> + []; +ssl3_erlang_server_openssl_client_client_cert(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_verification_opts, Config), + ClientOpts = ?config(client_verification_opts, Config), + + {_, ServerNode, _} = ssl_test_lib:run_where(Config), + + Data = "From openssl to erlang", + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, + erlang_ssl_receive, [Data]}}, + {options, + [{verify , verify_peer} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + + test_server:sleep(?SLEEP), + + CaCertFile = proplists:get_value(cacertfile, ClientOpts), + CertFile = proplists:get_value(certfile, ClientOpts), + KeyFile = proplists:get_value(keyfile, ClientOpts), + + Cmd = "openssl s_client -cert " ++ CertFile ++ " -CAfile " ++ CaCertFile + ++ " -key " ++ KeyFile ++ " -port " ++ integer_to_list(Port) ++ + " -host localhost -ssl3", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpenSslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + port_command(OpenSslPort, Data), + + ssl_test_lib:check_result(Server, ok), + + close_port(OpenSslPort), %% openssl server first + ssl_test_lib:close(Server), + %% Clean close down! + process_flag(trap_exit, false), + ok. + + +%%-------------------------------------------------------------------- + +ssl3_erlang_server_erlang_client_client_cert(doc) -> + ["Test erlang server with erlang client when client sends cert"]; +ssl3_erlang_server_erlang_client_client_cert(suite) -> + []; +ssl3_erlang_server_erlang_client_client_cert(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_verification_opts, Config), + ClientOpts = ?config(client_verification_opts, Config), + + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "From erlang to erlang", + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, + erlang_ssl_receive, [Data]}}, + {options, + [{verify , verify_peer} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + + test_server:sleep(?SLEEP), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {ssl, send, [Data]}}, + {options, + [{versions, [sslv3]} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- + +tls1_erlang_client_openssl_server(doc) -> + ["Test erlang client with openssl server"]; +tls1_erlang_client_openssl_server(suite) -> + []; +tls1_erlang_client_openssl_server(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_opts, Config), + ClientOpts = ?config(client_opts, Config), + + + test_server:format("Server Opts", [ServerOpts]), + + {ClientNode, _, Hostname} = ssl_test_lib:run_where(Config), + + Port = ssl_test_lib:inet_port(node()), + CertFile = proplists:get_value(certfile, ServerOpts), + KeyFile = proplists:get_value(keyfile, ServerOpts), + + Cmd = "openssl s_server -accept " ++ integer_to_list(Port) ++ + " -cert " ++ CertFile + ++ " -key " ++ KeyFile ++ " -tls1", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpensslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + + test_server:sleep(?SLEEP), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + connection_info, [tlsv1]}}, + {options, + [{versions, [tlsv1]} | ClientOpts]}]), + + ssl_test_lib:check_result(Client, ok), + + ssl_test_lib:close(Client), + %% Clean close down! + close_port(OpensslPort), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- + +tls1_erlang_server_openssl_client(doc) -> + ["Test erlang server with openssl client"]; +tls1_erlang_server_openssl_client(suite) -> + []; +tls1_erlang_server_openssl_client(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_opts, Config), + + {_, ServerNode, _} = ssl_test_lib:run_where(Config), + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, + {?MODULE, connection_info, [tlsv1]}}, + {options, + [{versions, [tlsv1]} | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + + test_server:sleep(?SLEEP), + + Cmd = "openssl s_client -port " ++ integer_to_list(Port) ++ + " -host localhost -tls1", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpenSslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + + ssl_test_lib:check_result(Server, ok), + + %% Clean close down! + close_port(OpenSslPort), + ssl_test_lib:close(Server), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- + +tls1_erlang_client_openssl_server_client_cert(doc) -> + ["Test erlang client with openssl server when client sends cert"]; +tls1_erlang_client_openssl_server_client_cert(suite) -> + []; +tls1_erlang_client_openssl_server_client_cert(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_verification_opts, Config), + ClientOpts = ?config(client_verification_opts, Config), + + {ClientNode, _, Hostname} = ssl_test_lib:run_where(Config), + + Data = "From openssl to erlang", + + Port = ssl_test_lib:inet_port(node()), + CaCertFile = proplists:get_value(cacertfile, ServerOpts), + CertFile = proplists:get_value(certfile, ServerOpts), + KeyFile = proplists:get_value(keyfile, ServerOpts), + + Cmd = "openssl s_server -accept " ++ integer_to_list(Port) ++ + " -cert " ++ CertFile ++ " -CAfile " ++ CaCertFile + ++ " -key " ++ KeyFile ++ " -Verify 2 -tls1", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpensslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + + test_server:sleep(?SLEEP), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, + erlang_ssl_receive, [Data]}}, + {options, ClientOpts}]), + port_command(OpensslPort, Data), + + ssl_test_lib:check_result(Client, ok), + + %% Clean close down! + close_port(OpensslPort), + ssl_test_lib:close(Client), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- + +tls1_erlang_server_openssl_client_client_cert(doc) -> + ["Test erlang server with openssl client when client sends cert"]; +tls1_erlang_server_openssl_client_client_cert(suite) -> + []; +tls1_erlang_server_openssl_client_client_cert(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_verification_opts, Config), + ClientOpts = ?config(client_verification_opts, Config), + + {_, ServerNode, _} = ssl_test_lib:run_where(Config), + + Data = "From openssl to erlang", + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, + erlang_ssl_receive, [Data]}}, + {options, + [{verify , verify_peer} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + + test_server:sleep(?SLEEP), + + CaCertFile = proplists:get_value(cacertfile, ClientOpts), + CertFile = proplists:get_value(certfile, ClientOpts), + KeyFile = proplists:get_value(keyfile, ClientOpts), + + Cmd = "openssl s_client -cert " ++ CertFile ++ " -CAfile " ++ CaCertFile + ++ " -key " ++ KeyFile ++ " -port " ++ integer_to_list(Port) ++ + " -host localhost -tls1", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpenSslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + port_command(OpenSslPort, Data), + + ssl_test_lib:check_result(Server, ok), + + %% Clean close down! + close_port(OpenSslPort), + ssl_test_lib:close(Server), + process_flag(trap_exit, false), + ok. + +%%-------------------------------------------------------------------- +tls1_erlang_server_erlang_client_client_cert(doc) -> + ["Test erlang server with erlang client when client sends cert"]; +tls1_erlang_server_erlang_client_client_cert(suite) -> + []; +tls1_erlang_server_erlang_client_client_cert(Config) when is_list(Config) -> + process_flag(trap_exit, true), + ServerOpts = ?config(server_verification_opts, Config), + ClientOpts = ?config(client_verification_opts, Config), + + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Data = "From erlang to erlang", + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, + erlang_ssl_receive, [Data]}}, + {options, + [{verify , verify_peer} + | ServerOpts]}]), + Port = ssl_test_lib:inet_port(Server), + + test_server:sleep(?SLEEP), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {ssl, send, [Data]}}, + {options, + [{versions, [tlsv1]} | ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + %% Clean close down! + process_flag(trap_exit, false), + ok. +%%-------------------------------------------------------------------- + +ciphers(doc) -> + [""]; + +ciphers(suite) -> + []; + +ciphers(Config) when is_list(Config) -> + Version = + ssl_record:protocol_version(ssl_record:highest_protocol_version([])), + + Ciphers = ssl:cipher_suites(), + Result = lists:map(fun(Cipher) -> + cipher(Cipher, Version, Config) end, + Ciphers), + case lists:flatten(Result) of + [] -> + ok; + Error -> + test_server:format("Cipher suite errors: ~p~n", [Error]), + test_server:fail(cipher_suite_failed_see_test_case_log) + end. + +cipher(CipherSuite, Version, Config) -> + process_flag(trap_exit, true), + test_server:format("Testing CipherSuite ~p~n", [CipherSuite]), + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, _ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Port = ssl_test_lib:inet_port(node()), + CertFile = proplists:get_value(certfile, ServerOpts), + KeyFile = proplists:get_value(keyfile, ServerOpts), + + Cmd = "openssl s_server -accept " ++ integer_to_list(Port) ++ + " -cert " ++ CertFile + ++ " -key " ++ KeyFile ++ "", + + test_server:format("openssl cmd: ~p~n", [Cmd]), + + OpenSslPort = open_port({spawn, Cmd}, [stderr_to_stdout]), + + test_server:sleep(?SLEEP), + + Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, connection_info_result, []}}, + {options, + [{ciphers,[CipherSuite]} | + ClientOpts]}]), + + ClientMsg = {ok, {Version, CipherSuite}}, + + Result = ssl_test_lib:wait_for_result(Client, ClientMsg), + + close_port(OpenSslPort), + %% Clean close down! + ssl_test_lib:close(Client), + receive + {'EXIT', Client, normal} -> + ok + end, + + Return = case Result of + ok -> + []; + Error -> + [{CipherSuite, Error}] + end, + process_flag(trap_exit, false), + Return. + +%%-------------------------------------------------------------------- + +erlang_ssl_receive(Socket, Data) -> + test_server:format("Connection info: ~p~n", + [ssl:connection_info(Socket)]), + receive + {ssl, Socket, Data} -> + io:format("Received ~p~n",[Data]), + %% open_ssl server sometimes hangs waiting in blocking read + ssl:send(Socket, "Got it"), + ok; + {Port, {data,Debug}} when is_port(Port) -> + io:format("openssl ~s~n",[Debug]), + erlang_ssl_receive(Socket,Data); + Other -> + test_server:fail({unexpected_message, Other}) + after 4000 -> + test_server:fail({did_not_get, Data}) + end. + +connection_info(Socket, Version) -> + case ssl:connection_info(Socket) of + {ok, {Version, _} = Info} -> + test_server:format("Connection info: ~p~n", [Info]), + ok; + {ok, {OtherVersion, _}} -> + {wrong_version, OtherVersion} + end. + +connection_info_result(Socket) -> + ssl:connection_info(Socket). + +close_port(Port) -> + port_command(Port, "Q\n"), + %%catch port_command(Port, "quit\n"), + close_loop(Port, 500, false). + +close_loop(Port, Time, SentClose) -> + receive + {Port, {data,Debug}} when is_port(Port) -> + io:format("openssl ~s~n",[Debug]), + close_loop(Port, Time, SentClose); + {ssl,_,Msg} -> + io:format("ssl Msg ~s~n",[Msg]), + close_loop(Port, Time, SentClose); + {Port, closed} -> + io:format("Port Closed~n",[]), + ok; + {'EXIT', Port, Reason} -> + io:format("Port Closed ~p~n",[Reason]), + ok; + Msg -> + io:format("Port Msg ~p~n",[Msg]), + close_loop(Port, Time, SentClose) + after Time -> + case SentClose of + false -> + io:format("Closing port ~n",[]), + catch erlang:port_close(Port), + close_loop(Port, Time, true); + true -> + io:format("Timeout~n",[]) + end + end. diff --git a/lib/ssl/vsn.mk b/lib/ssl/vsn.mk index 603c419653..2239f2eff4 100644 --- a/lib/ssl/vsn.mk +++ b/lib/ssl/vsn.mk @@ -1,25 +1,26 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1999-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1999-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # -SSL_VSN = 3.10.7 +SSL_VSN = 3.10.8 -TICKETS = OTP-8260 OTP-8218 OTP-8250 +TICKETS = OTP-8327 +#TICKETS_3.10.7 = OTP-8260 OTP-8218 OTP-8250 #TICKETS_3.10.6 = OTP-8275 diff --git a/lib/stdlib/src/Makefile b/lib/stdlib/src/Makefile index 68708d6b02..37c836a254 100644 --- a/lib/stdlib/src/Makefile +++ b/lib/stdlib/src/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1996-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1996-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # @@ -173,8 +173,8 @@ $(BOOTSTRAP_COMPILER)/ebin/erl_parse.beam: erl_parse.yrl $(ERLC) -o $(BOOTSTRAP_COMPILER)/egen erl_parse.yrl $(ERLC) -o $(BOOTSTRAP_COMPILER)/ebin $(BOOTSTRAP_COMPILER)/egen/erl_parse.erl -#$(BOOTSTRAP_COMPILER)/ebin/erl_lint.beam: erl_lint.erl -# $(ERLC) -o $(BOOTSTRAP_COMPILER)/ebin erl_lint.erl +$(BOOTSTRAP_TOP)/lib/stdlib/egen/erl_parse.erl: erl_parse.yrl + $(ERLC) $(YRL_FLAGS) -o$(BOOTSTRAP_TOP)/lib/stdlib/egen erl_parse.yrl $(BOOTSTRAP_COMPILER)/ebin/%.beam: %.erl $(ERLC) -o $(BOOTSTRAP_COMPILER)/ebin $< diff --git a/lib/stdlib/src/edlin.erl b/lib/stdlib/src/edlin.erl index d5ab294fb8..0e98bbaa06 100644 --- a/lib/stdlib/src/edlin.erl +++ b/lib/stdlib/src/edlin.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(edlin). diff --git a/lib/stdlib/src/edlin_expand.erl b/lib/stdlib/src/edlin_expand.erl index a38e118e68..516c0aa30b 100644 --- a/lib/stdlib/src/edlin_expand.erl +++ b/lib/stdlib/src/edlin_expand.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(edlin_expand). diff --git a/lib/stdlib/test/ExpandTestCaps.erl b/lib/stdlib/test/ExpandTestCaps.erl index 15da7dbeff..96c4115354 100644 --- a/lib/stdlib/test/ExpandTestCaps.erl +++ b/lib/stdlib/test/ExpandTestCaps.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% Copyright Ericsson AB 2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in diff --git a/lib/stdlib/test/ExpandTestCaps1.erl b/lib/stdlib/test/ExpandTestCaps1.erl index b934f4b9cc..09ee9f81c4 100644 --- a/lib/stdlib/test/ExpandTestCaps1.erl +++ b/lib/stdlib/test/ExpandTestCaps1.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% Copyright Ericsson AB 2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in diff --git a/lib/stdlib/test/edlin_expand_SUITE.erl b/lib/stdlib/test/edlin_expand_SUITE.erl index d757230016..613bfd000e 100644 --- a/lib/stdlib/test/edlin_expand_SUITE.erl +++ b/lib/stdlib/test/edlin_expand_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% Copyright Ericsson AB 2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl index 6016bc9bdc..13c87ca005 100644 --- a/lib/stdlib/test/ets_SUITE.erl +++ b/lib/stdlib/test/ets_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(ets_SUITE). @@ -4530,10 +4530,16 @@ meta_wb(Config) when is_list(Config) -> meta_wb_do(Opts) -> %% Do random new/delete/rename of colliding named tables - Names = [pioneer | colliding_names(pioneer)], + Names0 = [pioneer | colliding_names(pioneer)], + + %% Remove any names that happen to exist as tables already + Names = lists:filter(fun(Name) -> ets:info(Name) == undefined end, + Names0), Len = length(Names), OpFuns = {fun meta_wb_new/4, fun meta_wb_delete/4, fun meta_wb_rename/4}, + ?line true = (Len >= 3), + io:format("Colliding names = ~p\n",[Names]), F = fun(0,_,_) -> ok; (N,Tabs,Me) -> Name1 = lists:nth(random:uniform(Len),Names), diff --git a/lib/stdlib/test/expand_test.erl b/lib/stdlib/test/expand_test.erl index 4a0e0b4784..63e4bc3aa0 100644 --- a/lib/stdlib/test/expand_test.erl +++ b/lib/stdlib/test/expand_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% Copyright Ericsson AB 2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in diff --git a/lib/stdlib/test/expand_test1.erl b/lib/stdlib/test/expand_test1.erl index 8e9344fa31..11b6fec0f3 100644 --- a/lib/stdlib/test/expand_test1.erl +++ b/lib/stdlib/test/expand_test1.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% Copyright Ericsson AB 2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index b352ae7cce..4fc4826238 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -3955,15 +3955,16 @@ Return nil if inside string, t if in a comment." (nth 2 stack-top)))) (t (goto-char (nth 1 stack-top)) - (cond ((looking-at "[({]\\s *\\($\\|%\\)") - ;; Line ends with parenthesis. - (erlang-indent-parenthesis (nth 2 stack-top))) - (t - ;; Indent to the same column as the first - ;; argument. - (goto-char (1+ (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column)))))) + (let ((base (cond ((looking-at "[({]\\s *\\($\\|%\\)") + ;; Line ends with parenthesis. + (erlang-indent-parenthesis (nth 2 stack-top))) + (t + ;; Indent to the same column as the first + ;; argument. + (goto-char (1+ (nth 1 stack-top))) + (skip-chars-forward " \t") + (current-column))))) + (erlang-indent-standard indent-point token base 't))))) ;; ((eq (car stack-top) '<<) ;; Element of binary (possible comprehension) expression, @@ -4047,33 +4048,8 @@ Return nil if inside string, t if in a comment." 0)) base)) ;; old catch (t - ;; Look at last thing to see how we are to move relative - ;; to the base. - (goto-char token) - (cond ((looking-at "||\\|,\\|->") - base) - ((erlang-at-keyword) - (+ (current-column) erlang-indent-level)) - ((or (= (char-syntax (following-char)) ?.) - (erlang-at-operator)) - (+ base erlang-indent-level)) - (t - (goto-char indent-point) - (cond ((memq (following-char) '(?\( ?{)) - ;; Function application or record. - (+ (erlang-indent-find-preceding-expr) - erlang-argument-indent)) - ;; Empty line, or end; treat it as the end of - ;; the block. (Here we have a choice: should - ;; the user be forced to reindent continued - ;; lines, or should the "end" be reindented?) - - ;; Avoid treating comments a continued line. - ((= (following-char) ?%) - base) - ;; Continued line (e.g. line beginning - ;; with an operator.) - (t (+ base erlang-indent-level))))))))) + (erlang-indent-standard indent-point token base 'nil) + )))) )) ((eq (car stack-top) 'when) (goto-char (nth 1 stack-top)) @@ -4105,21 +4081,55 @@ Return nil if inside string, t if in a comment." (+ 2 (nth 2 stack-top))) ((looking-at "::[^_a-zA-Z0-9]") (nth 2 stack-top)) - (t - (goto-char (nth 1 stack-top)) - (cond ((looking-at "::\\s *\\($\\|%\\)") - ;; Line ends with :: - (+ (erlang-indent-find-preceding-expr 2) - erlang-argument-indent)) - ;; (* 2 erlang-indent-level)) - (t - ;; Indent to the same column as the first - ;; argument. - (goto-char (+ 2 (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column)))))) + (t + (let ((start-alternativ (if (looking-at "|") 2 0))) + (goto-char (nth 1 stack-top)) + (- (cond ((looking-at "::\\s *\\($\\|%\\)") + ;; Line ends with :: + (if (eq (car (car (last stack))) 'spec) + (+ (erlang-indent-find-preceding-expr 1) + erlang-argument-indent) + (+ (erlang-indent-find-preceding-expr 2) + erlang-argument-indent))) + (t + ;; Indent to the same column as the first + ;; argument. + (goto-char (+ 2 (nth 1 stack-top))) + (skip-chars-forward " \t") + (current-column))) start-alternativ))))) ))) +(defun erlang-indent-standard (indent-point token base inside-parenthesis) + "Standard indent when in blocks or tuple or arguments. + Look at last thing to see in what state we are, move relative to the base." + (goto-char token) + (cond ((looking-at "||\\|,\\|->\\||") + base) + ((erlang-at-keyword) + (+ (current-column) erlang-indent-level)) + ((or (= (char-syntax (following-char)) ?.) + (erlang-at-operator)) + (+ base erlang-indent-level)) + (t + (goto-char indent-point) + (cond ((memq (following-char) '(?\( ?{)) + ;; Function application or record. + (+ (erlang-indent-find-preceding-expr) + erlang-argument-indent)) + ;; Empty line, or end; treat it as the end of + ;; the block. (Here we have a choice: should + ;; the user be forced to reindent continued + ;; lines, or should the "end" be reindented?) + + ;; Avoid treating comments a continued line. + ((= (following-char) ?%) + base) + ;; Continued line (e.g. line beginning + ;; with an operator.) + (t + (if (or (erlang-at-operator) (not inside-parenthesis)) + (+ base erlang-indent-level) + base)))))) (defun erlang-indent-find-base (stack indent-point &optional offset skip) "Find the base column for current stack." diff --git a/lib/tools/emacs/test.erl.indented b/lib/tools/emacs/test.erl.indented index 1d91b2f155..1ccced9177 100644 --- a/lib/tools/emacs/test.erl.indented +++ b/lib/tools/emacs/test.erl.indented @@ -44,6 +44,24 @@ b }). +-record(record3, {a = 8#42423 bor + 8#4234, + b = 8#5432 + bor 2#1010101 + c = 123 + + 234, + d}). + +-record(record4, { + a = 8#42423 bor + 8#4234, + b = 8#5432 + bor 2#1010101 + c = 123 + + 234, + d}). + + -define(MACRO_1, macro). -define(MACRO_2(_), macro). @@ -51,8 +69,10 @@ -type ann() :: Var :: integer(). -type ann2() :: Var :: - 'return' | 'return_white_spaces' | 'return_comments' - | 'text' | ann(). + 'return' + | 'return_white_spaces' + | 'return_comments' + | 'text' | ann(). -type paren() :: (ann2()). -type t1() :: atom(). @@ -89,7 +109,7 @@ fun((nonempty_maybe_improper_list('integer', any())| 1|2|3|a|b|<<_:3,_:_*14>>|integer()) -> nonempty_maybe_improper_list('integer', any())| - 1|2|3|a|b|<<_:3,_:_*14>>|integer()). + 1|2|3|a|b|<<_:3,_:_*14>>|integer()). -type t20() :: [t19(), ...]. -type t21() :: tuple(). -type t21(A) :: A. @@ -116,6 +136,22 @@ (T :: tuple()) -> R3 :: bar:typen(). -spec mod:t2() -> any(). + +-spec handle_cast(Cast :: {'exchange', node(), [[name(),...]]} + | {'del_member', name(), pid()}, + #state{}) -> {'noreply', #state{}}. + +-spec handle_cast(Cast :: + {'exchange', node(), [[name(),...]]} + | {'del_member', name(), pid()}, + #state{}) -> {'noreply', #state{}}. + + +-spec get_closest_pid(term()) -> + Return :: pid() + | {'error', {'no_process', term()} + | {'no_such_group', term()}}. + -opaque attributes_data() :: [{'column', column()} | {'line', info_line()} | {'text', string()}] | {line(),column()}. @@ -282,7 +318,10 @@ indent_basics(X, Y, Z) c ), - + call(2#42423 bor + #4234, + 2#5432, + other_arg), ok; indent_basics(Xlongname, #struct{a=Foo, @@ -496,7 +535,7 @@ indent_catch() -> B = catch oskar(X), A = catch (baz + - bax), + bax), catch foo(), C = catch B + diff --git a/lib/tools/emacs/test.erl.orig b/lib/tools/emacs/test.erl.orig index 049fc21286..9b4203120b 100644 --- a/lib/tools/emacs/test.erl.orig +++ b/lib/tools/emacs/test.erl.orig @@ -44,6 +44,24 @@ b }). +-record(record3, {a = 8#42423 bor + 8#4234, + b = 8#5432 + bor 2#1010101 + c = 123 + +234, + d}). + +-record(record4, { + a = 8#42423 bor + 8#4234, + b = 8#5432 + bor 2#1010101 + c = 123 + + 234, + d}). + + -define(MACRO_1, macro). -define(MACRO_2(_), macro). @@ -51,8 +69,10 @@ -type ann() :: Var :: integer(). -type ann2() :: Var :: - 'return' | 'return_white_spaces' | 'return_comments' - | 'text' | ann(). + 'return' + | 'return_white_spaces' + | 'return_comments' + | 'text' | ann(). -type paren() :: (ann2()). -type t1() :: atom(). @@ -116,6 +136,22 @@ t15(),t20(),t21(), t22(),t25()}. (T :: tuple()) -> R3 :: bar:typen(). -spec mod:t2() -> any(). + +-spec handle_cast(Cast :: {'exchange', node(), [[name(),...]]} + | {'del_member', name(), pid()}, + #state{}) -> {'noreply', #state{}}. + +-spec handle_cast(Cast :: + {'exchange', node(), [[name(),...]]} + | {'del_member', name(), pid()}, + #state{}) -> {'noreply', #state{}}. + + +-spec get_closest_pid(term()) -> + Return :: pid() + | {'error', {'no_process', term()} + | {'no_such_group', term()}}. + -opaque attributes_data() :: [{'column', column()} | {'line', info_line()} | {'text', string()}] | {line(),column()}. @@ -282,7 +318,10 @@ Y =:= 4711 -> c ), - + call(2#42423 bor + #4234, + 2#5432, + other_arg), ok; indent_basics(Xlongname, #struct{a=Foo, diff --git a/lib/tools/test/Makefile b/lib/tools/test/Makefile new file mode 100644 index 0000000000..a846a3a6f4 --- /dev/null +++ b/lib/tools/test/Makefile @@ -0,0 +1,90 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1997-2010. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +MODULES = \ + cover_SUITE \ + eprof_SUITE \ + emem_SUITE \ + fprof_SUITE \ + cprof_SUITE \ + instrument_SUITE \ + make_SUITE \ + tools_SUITE \ + xref_SUITE \ + ignore_cores + +ERL_FILES= $(MODULES:%=%.erl) + +TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) +INSTALL_PROGS= $(TARGET_FILES) + +EMAKEFILE=Emakefile + +SPEC_FILES= tools.spec tools.spec.win + +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/tools_test + +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_MAKE_FLAGS += +ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/test_server/include + +EBIN = . + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- +.PHONY: make_emakefile + +make_emakefile: + $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES)\ + > $(EMAKEFILE) + +tests debug opt: make_emakefile + erl $(ERL_MAKE_FLAGS) -make + +clean: + rm -f $(EMAKEFILE) + rm -f $(TARGET_FILES) + rm -f core + +docs: + +# ---------------------------------------------------- +# Release Target +# ---------------------------------------------------- +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: opt + +release_tests_spec: make_emakefile + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(SPEC_FILES) $(EMAKEFILE) $(ERL_FILES) $(RELSYSDIR) + chmod -f -R u+w $(RELSYSDIR) + @tar cf - *_SUITE_data | (cd $(RELSYSDIR); tar xf -) + +release_docs_spec: + + diff --git a/lib/tools/test/cover_SUITE.erl b/lib/tools/test/cover_SUITE.erl new file mode 100644 index 0000000000..b9ccd62d0b --- /dev/null +++ b/lib/tools/test/cover_SUITE.erl @@ -0,0 +1,1198 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(cover_SUITE). + +-export([all/1]). +-export([start/1, compile/1, analyse/1, misc/1, stop/1, + distribution/1, export_import/1, + otp_5031/1, eif/1, otp_5305/1, otp_5418/1, otp_6115/1, otp_7095/1, + otp_8188/1, otp_8270/1, otp_8273/1, otp_8340/1]). + +-include("test_server.hrl"). + +%%---------------------------------------------------------------------- +%% The following directory structure is assumed: +%% cwd __________________________________________ +%% | \ \ \ \ \ \ \ +%% a b cc d f d1 compile_beam_____ otp_6115 +%% | \ \ \ \ \ \ \ +%% e crypt v w x d f1 f2 +%% | +%% y +%%---------------------------------------------------------------------- + +all(suite) -> + case whereis(cover_server) of + undefined -> + [start, compile, analyse, misc, stop, distribution, + export_import, + otp_5031, eif, otp_5305, otp_5418, otp_6115, otp_7095, + otp_8188, otp_8270, otp_8273, otp_8340]; + _pid -> + {skip,"It looks like the test server is running cover. " + "Can't run cover test."} + end. + +start(suite) -> []; +start(Config) when is_list(Config) -> + ?line ok = file:set_cwd(?config(data_dir, Config)), + + ?line Files = lsfiles(), + ?line remove(files(Files, ".out")), + + ?line {ok, Pid} = cover:start(), + ?line {error, {already_started, Pid}} = cover:start(). + +compile(suite) -> []; +compile(Config) when is_list(Config) -> + ?line ok = file:set_cwd(?config(data_dir, Config)), + + ?line Result1 = cover:compile_directory(), + ?line SortedResult = lists:sort(Result1), + ?line {ok, CWD} = file:get_cwd(), + ?line Result2 = cover:compile_directory(CWD), + ?line SortedResult = lists:sort(Result2), + ?line [{error,_DFile},{ok,a},{ok,b},{ok,cc},{ok,f}] = SortedResult, + ?line [{ok,e}] = cover:compile_directory("d1"), + ?line {error,enoent} = cover:compile_directory("d2"), + + ?line {ok,a} = cover:compile(a), + ?line {ok,b} = compile:file(b), + ?line code:purge(b), + ?line {module,b} = code:load_file(b), + ?line {ok,d} = cover:compile("d.erl", [{d,'AGE',42}]), + ?line {error,_BBFile} = cover:compile(bb), + + ?line StdlibDir = code:lib_dir(stdlib), + ?line Lists = filename:join([StdlibDir, "src", "lists.erl"]), + ?line {error, Lists} = cover:compile(Lists), + + %% For compiling beam: using dummy files v,w,x,y and z + ?line file:set_cwd("compile_beam"), + ?line {ok,_} = compile:file(v,[debug_info,report]), + ?line {ok,_} = compile:file(w,[debug_info,report]), + ?line {ok,_} = compile:file(x), + ?line {ok,_} = compile:file("d/y",[debug_info,{outdir,"d"},report]), + ?line Key = "A Krypto Key", + ?line {ok,_} = compile:file(crypt, [debug_info,{debug_info_key,Key},report]), + ?line {ok,v} = cover:compile_beam(v), + ?line {ok,w} = cover:compile_beam("w.beam"), + ?line {error,{encrypted_abstract_code,_}} = + cover:compile_beam("crypt.beam"), + ?line ok = beam_lib:crypto_key_fun(simple_crypto_fun(Key)), + ?line {ok,crypt} = cover:compile_beam("crypt.beam"), + ?line {error,{no_abstract_code,"./x.beam"}} = cover:compile_beam(x), + ?line {error,{already_cover_compiled,no_beam_found,a}}=cover:compile_beam(a), + ?line {error,non_existing} = cover:compile_beam(z), + ?line [{ok,y}] = cover:compile_beam_directory("d"), + ?line Result3 = lists:sort(cover:compile_beam_directory()), + ?line [{error,{no_abstract_code,_XBeam}},{ok,crypt},{ok,v},{ok,w}] = Result3, + ?line {error,enoent} = cover:compile_beam_directory("d2"), + ?line decompile([v,w,y]), + ?line Files = lsfiles(), + ?line remove(files(Files, ".beam")). + +simple_crypto_fun(Key) -> + fun(init) -> ok; + ({debug_info, des3_cbc, crypt, _}) -> Key + end. + +analyse(suite) -> []; +analyse(Config) when is_list(Config) -> + ?line ok = file:set_cwd(?config(data_dir, Config)), + + ?line done = a:start(5), + + ?line {ok, {a,{17,2}}} = cover:analyse(a, coverage, module), + ?line {ok, [{{a,start,1},{6,0}}, + {{a,stop,1},{0,1}}, + {{a,pong,1},{1,0}}, + {{a,loop,3},{5,1}}, + {{a,trycatch,1},{4,0}}, + {{a,exit_kalle,0},{1,0}}]} = cover:analyse(a, coverage, function), + ?line {ok, [{{a,start,1,1},{6,0}}, + {{a,stop,1,1},{0,1}}, + {{a,pong,1,1},{1,0}}, + {{a,loop,3,1},{3,1}}, + {{a,loop,3,2},{2,0}}, + {{a,trycatch,1,1},{4,0}}, + {{a,exit_kalle,0,1},{1,0}}]} = cover:analyse(a, coverage, clause), + ?line {ok, [{{a,9},{1,0}}, + {{a,10},{1,0}}, + {{a,11},{1,0}}, + {{a,13},{1,0}}, + {{a,14},{1,0}}, + {{a,15},{1,0}}, + {{a,21},{0,1}}, + {{a,26},{1,0}}, + {{a,31},{1,0}}, + {{a,32},{1,0}}, + {{a,34},{1,0}}, + {{a,36},{0,1}}, + {{a,39},{1,0}}, + {{a,40},{1,0}}, + {{a,44},{1,0}}, + {{a,47},{1,0}}, + {{a,49},{1,0}}, + {{a,51},{1,0}}, + {{a,55},{1,0}}]} = cover:analyse(a, coverage, line), + + ?line {ok, {a,15}} = cover:analyse(a, calls, module), + ?line {ok, [{{a,start,1},1}, + {{a,stop,1},0}, + {{a,pong,1},5}, + {{a,loop,3},6}, + {{a,trycatch,1},2}, + {{a,exit_kalle,0},1}]} = cover:analyse(a, calls, function), + ?line {ok, [{{a,start,1,1},1}, + {{a,stop,1,1},0}, + {{a,pong,1,1},5}, + {{a,loop,3,1},5}, + {{a,loop,3,2},1}, + {{a,trycatch,1,1},2}, + {{a,exit_kalle,0,1},1}]} = cover:analyse(a, calls, clause), + ?line {ok, [{{a,9},1}, + {{a,10},1}, + {{a,11},1}, + {{a,13},1}, + {{a,14},1}, + {{a,15},1}, + {{a,21},0}, + {{a,26},5}, + {{a,31},5}, + {{a,32},5}, + {{a,34},5}, + {{a,36},0}, + {{a,39},1}, + {{a,40},1}, + {{a,44},2}, + {{a,47},1}, + {{a,49},1}, + {{a,51},2}, + {{a,55},1}]} = cover:analyse(a, calls, line), + + ?line {ok, [{{a,start,1},{6,0}}, + {{a,stop,1},{0,1}}, + {{a,pong,1},{1,0}}, + {{a,loop,3},{5,1}}, + {{a,trycatch,1},{4,0}}, + {{a,exit_kalle,0},{1,0}}]} = cover:analyse(a), + ?line {ok, {a,{17,2}}} = cover:analyse(a, module), + ?line {ok, [{{a,start,1},1}, + {{a,stop,1},0}, + {{a,pong,1},5}, + {{a,loop,3},6}, + {{a,trycatch,1},2}, + {{a,exit_kalle,0},1}]} = cover:analyse(a, calls), + + ?line {ok, "a.COVER.out"} = cover:analyse_to_file(a), + ?line {ok, "e.COVER.out"} = cover:analyse_to_file(e), + ?line {ok, "a.COVER.html"} = cover:analyse_to_file(a,[html]), + ?line {ok, "e.COVER.html"} = cover:analyse_to_file(e,[html]), + + %% analyse_to_file of file which is compiled from beam + ?line {ok,f} = compile:file(f,[debug_info]), + ?line code:purge(f), + ?line {module,f} = code:load_file(f), + ?line {ok,f} = cover:compile_beam(f), + ?line f:f2(), + ?line {ok, "f.COVER.out"} = cover:analyse_to_file(f), + + %% Source code cannot be found by analyse_to_file + ?line {ok,v} = compile:file("compile_beam/v",[debug_info]), + ?line code:purge(v), + ?line {module,v} = code:load_file(v), + ?line {ok,v} = cover:compile_beam(v), + ?line {error,no_source_code_found} = cover:analyse_to_file(v), + + ?line {error,{not_cover_compiled,b}} = cover:analyse(b), + ?line {error,{not_cover_compiled,g}} = cover:analyse(g), + ?line {error,{not_cover_compiled,b}} = cover:analyse_to_file(b), + ?line {error,{not_cover_compiled,g}} = cover:analyse_to_file(g). + +misc(suite) -> []; +misc(Config) when is_list(Config) -> + ?line ok = file:set_cwd(?config(data_dir, Config)), + + ?line [a,cc,crypt,d,e,f,v] = lists:sort(cover:modules()), + + ?line {ok,cc} = compile:file(cc), + ?line code:purge(cc), + ?line {module,cc} = code:load_file(cc), + ?line [a,crypt,d,e,f,v] = lists:sort(cover:modules()), + + ?line {file, _File} = cover:is_compiled(a), + ?line false = cover:is_compiled(b), + ?line false = cover:is_compiled(g), + + ?line ok = cover:reset(a), + ?line {ok, {a,{0,19}}} = cover:analyse(a, module), + ?line ok = cover:reset(). + +stop(suite) -> []; +stop(Config) when is_list(Config) -> + ?line ok = file:set_cwd(?config(data_dir, Config)), + + ?line cover_compiled = code:which(a), + ?line {ok,d} = compile:file(d, [{d,'AGE',42}]), + ?line code:purge(d), + ?line {module,d} = code:load_file(d), + ?line ok = cover:stop(), + ?line Beam = code:which(a), + ?line true = is_unloaded(Beam), + + ?line Files = lsfiles(), + ?line remove(files(Files, ".out")), + ?line remove(files(Files, ".html")), + ?line remove(files(Files, ".beam")). + +distribution(suite) -> []; +distribution(Config) when is_list(Config) -> + ?line DataDir = ?config(data_dir, Config), + ?line ok = file:set_cwd(DataDir), + + ?line {ok,N1} = ?t:start_node(cover_SUITE_distribution1,slave,[]), + ?line {ok,N2} = ?t:start_node(cover_SUITE_distribution2,slave,[]), + ?line {ok,N3} = ?t:start_node(cover_SUITE_distribution3,slave,[]), + + %% Check that an already compiled module is loaded on new nodes + ?line {ok,f} = cover:compile(f), + ?line {ok,[_,_,_]} = cover:start(nodes()), + ?line cover_compiled = code:which(f), + ?line cover_compiled = rpc:call(N1,code,which,[f]), + ?line cover_compiled = rpc:call(N2,code,which,[f]), + ?line cover_compiled = rpc:call(N3,code,which,[f]), + + %% Check that a node cannot be started twice + ?line {ok,[]} = cover:start(N2), + + %% Check that the current node (i.e. the main node) is not started with + %% start/1 and not stopped with stop/1 + ?line {ok,[]} = cover:start(node()), + ?line ok = cover:stop(node()), + ?line true = is_pid(whereis(cover_server)), + + %% Check that a new compiled module is loaded on all existing nodes + ?line compile:file("compile_beam/v",[debug_info]), + ?line {ok,v} = cover:compile_beam(v), + ?line cover_compiled = code:which(v), + ?line cover_compiled = rpc:call(N1,code,which,[v]), + ?line cover_compiled = rpc:call(N2,code,which,[v]), + ?line cover_compiled = rpc:call(N3,code,which,[v]), + + %% this is lost when the node is killed + ?line rpc:call(N3,f,f2,[]), + ?line rpc:call(N3,erlang,halt,[]), + + %% this should be visible in analyse + ?line rpc:call(N1,f,f1,[]), + + %% Check that data is collected from remote node when stopped + ?line ok = cover:stop(N1), + ?line N1Beam = rpc:call(N1,code,which,[f]), + ?line true = is_unloaded(N1Beam), + ?line check_f_calls(1,0), + + %% Call f:f1() again on another node and check that number of calls is + %% accumulated. + ?line f:f1(), + ?line check_f_calls(2,0), + + %% Check that reset works on all nodes + ?line f:f1(), + ?line rpc:call(N2,f,f1,[]), + ?line ok = cover:reset(f), + ?line check_f_calls(0,0), + + %% Check that data is collected from all nodes + ?line rpc:call(N2,f,f1,[]), + ?line f:f2(), + ?line check_f_calls(1,1), + + %% Check that same data is not fetched again (i.e. that analyse does + %% reset on the remote node(s)) + ?line check_f_calls(1,1), + + %% Check that stop() unloads on all nodes + ?line ok = cover:stop(), + ?line LocalBeam = code:which(f), + ?line N2Beam = rpc:call(N2,code,which,[f]), + ?line true = is_unloaded(LocalBeam), + ?line true = is_unloaded(N2Beam), + + %% Check that cover_server on remote node dies if main node dies + ?line {ok,[N1]} = cover:start(N1), + ?line true = is_pid(rpc:call(N1,erlang,whereis,[cover_server])), + ?line exit(whereis(cover_server),kill), + ?line timer:sleep(10), + ?line undefined = rpc:call(N1,erlang,whereis,[cover_server]), + + %% Cleanup + ?line Files = lsfiles(), + ?line remove(files(Files, ".beam")), + ?line ?t:stop_node(N1), + ?line ?t:stop_node(N2). + + +export_import(suite) -> []; +export_import(Config) when is_list(Config) -> + ?line DataDir = ?config(data_dir, Config), + ?line ok = file:set_cwd(DataDir), + + %% Export one module + ?line {ok,f} = cover:compile(f), + ?line f:f1(), + %% check that no info is written about where data comes from when no + %% files are imported + ?line ?t:capture_start(), + ?line check_f_calls(1,0), + ?line [] = ?t:capture_get(), + ?line ?t:capture_stop(), + ?line ok = cover:export("f_exported",f), + ?line check_f_calls(1,0), + ?line ok = cover:stop(), + + %% Check that same data exists after import and that info is written about + %% data comming from imported file + ?line ok = cover:import("f_exported"), + ?line ?t:capture_start(), + ?line check_f_calls(1,0), + ?line [Text1] = ?t:capture_get(), + ?line "Analysis includes data from imported files"++_ = lists:flatten(Text1), + ?line ?t:capture_stop(), + + %% Export all modules + ?line {ok,a} = cover:compile(a), + ?line ?t:capture_start(), + ?line ok = cover:export("all_exported"), + ?line [Text2] = ?t:capture_get(), + ?line "Export includes data from imported files"++_ = lists:flatten(Text2), + ?line ?t:capture_stop(), + ?line ok = cover:stop(), + ?line ok = cover:import("all_exported"), + ?line check_f_calls(1,0), + + %% Check that data is reset when module is compiled again, and that + %% warning is written when data is deleted for imported module. + ?line ?t:capture_start(), + ?line {ok,f} = cover:compile(f), + ?line timer:sleep(10), % capture needs some time + ?line [Text3] = ?t:capture_get(), + ?line "WARNING: Deleting data for module f imported from" ++ _ = + lists:flatten(Text3), + ?line ?t:capture_stop(), + ?line check_f_calls(0,0), + + %% Check that data is summed up when first compiled and then imported + %% The module which has been compiled (f) is loaded from the file + %% all_exported again (since it has been reset during cover compiling), + %% but the other module (a) is not loaded since it is already loaded + ?line f:f1(), + ?line f:f2(), + ?line ok = cover:import("f_exported"), + ?line ?t:capture_start(), + ?line ok = cover:import("all_exported"), + ?line [Text4] = ?t:capture_get(), % a is not loaded again + ?line "WARNING: Module a already imported from " ++ _ = lists:flatten(Text4), + ?line ?t:capture_stop(), + ?line check_f_calls(3,1), + + %% Check that warning is written when same file is imported twice, + %% and that data is not imported again + ?line ?t:capture_start(), + ?line ok = cover:import("all_exported"), + ?line [Text5,Text6] = ?t:capture_get(), + ?line "WARNING: Module f already imported from " ++ _ = lists:flatten(Text5), + ?line "WARNING: Module a already imported from " ++ _ = lists:flatten(Text6), + ?line ?t:capture_stop(), + ?line check_f_calls(3,1), + + %% Check that reset removes all data and that the file which has been + %% reset can be imported again with no warning + ?line cover:reset(f), + ?line check_f_calls(0,0), + ?line ?t:capture_start(), + ?line ok = cover:import("all_exported"), + ?line [Text7] = ?t:capture_get(), % warning only on mod a + ?line "WARNING: Module a already imported from " ++ _ = lists:flatten(Text7), + ?line ?t:capture_stop(), + ?line check_f_calls(1,0), + + %% same as above - only reset all + ?line cover:reset(), + ?line check_f_calls(0,0), + ?line ?t:capture_start(), + ?line ok = cover:import("all_exported"), + ?line [] = ?t:capture_get(), % no warnings + ?line ?t:capture_stop(), + ?line check_f_calls(1,0), + + %% Cleanup + ?line ok = cover:stop(), + ?line Files = lsfiles(), + ?line remove(["f_exported","all_exported"|files(Files, ".beam")]). + + +otp_5031(suite) -> []; +otp_5031(Config) when is_list(Config) -> + + Dog = ?t:timetrap(?t:seconds(10)), + + ?line {ok,N1} = ?t:start_node(cover_SUITE_distribution1,slave,[]), + ?line {ok,[N1]} = cover:start(N1), + ?line {error,not_main_node} = rpc:call(N1,cover,modules,[]), + ?line cover:stop(), + + ?t:timetrap_cancel(Dog), + ok. + +eif(doc) -> + ["Test the \'Exclude Included Functions\' functionality"]; +eif(suite) -> + []; +eif(Config) when is_list(Config) -> + ?line ok = file:set_cwd(filename:join(?config(data_dir, Config), + "included_functions")), + ?line {ok, cover_inc} = compile:file(cover_inc,[debug_info]), + ?line {ok, cover_inc} = cover:compile_beam(cover_inc), + + %% This function will cause an included function to be executed. + %% The analysis should only show the lines that actually exist + %% in cover_inc.beam - not the ones from the included file. + ?line cover_inc:func(), + ?line {ok, [_, _]} = cover:analyse(cover_inc, line), + ?line cover:stop(), + ok. + +otp_5305(suite) -> []; +otp_5305(Config) when is_list(Config) -> + ?line ok = file:set_cwd(?config(priv_dir, Config)), + + File = "t.erl", + Test = <<"-module(t). + -export([t/0]). + -include_lib(\"stdlib/include/ms_transform.hrl\"). + t() -> + ets:fun2ms(fun(X) -> X end). + ">>, + ?line ok = file:write_file(File, Test), + ?line {ok, t} = cover:compile(File), + ?line cover:stop(), + ?line ok = file:delete(File), + + ok. + +otp_5418(suite) -> []; +otp_5418(Config) when is_list(Config) -> + ?line ok = file:set_cwd(?config(priv_dir, Config)), + + File = "t.erl", + Test = <<"-module(t). + ">>, + ?line ok = file:write_file(File, Test), + ?line {ok, t} = cover:compile(File), + ?line {ok,{t,{0,0}}} = cover:analyse(t, module), + ?line cover:stop(), + ?line ok = file:delete(File), + + ok. + +otp_6115(suite) -> []; +otp_6115(Config) when is_list(Config) -> + case erlang:system_info(heap_type) of + hybrid -> {skip,"Hybrid-heap emulator doesn't keep track of funs"}; + _ -> otp_6115_1(Config) + end. + +otp_6115_1(Config) -> + ?line {ok, CWD} = file:get_cwd(), + ?line Dir = filename:join(?config(data_dir, Config), otp_6115), + ?line ok = file:set_cwd(Dir), + ?line {ok, f1} = compile:file(f1, [debug_info]), + ?line {ok, f2} = compile:file(f2, [debug_info]), + + %% Cover compile f1, but not f2 + ?line {ok, f1} = cover:compile(f1), + + %% If f1 is cover compiled, a process P is started with a + %% reference to the fun created in start_fail/0, and cover:stop() is + %% called, then P should be killed. + %% This is because (the fun held by P) references the cover + %% compiled code which should be *unloaded* when cover:stop() is + %% called -- running cover compiled code when there is no cover + %% server and thus no ets tables to bump counters in, makes no + %% sense. + ?line Pid1 = f1:start_fail(), + + %% If f1 is cover compiled, a process P is started with a + %% reference to the fun created in start_ok/0, and + %% cover:stop() is called, then P should survive. + %% This is because (the fun held by) P always references the current + %% version of the module, and is thus not affected by the cover + %% compiled version being unloaded. + ?line Pid2 = f1:start_ok(), + + %% Now stop cover + ?line cover:stop(), + + %% Ensure that f1 is loaded (and not cover compiled), that Pid1 + %% is dead and Pid2 is alive, but with no reference to old code + case code:which(f1) of + Beam when is_list(Beam) -> + ok; + Other -> + ?line ?t:fail({"f1 is not reloaded", Other}) + end, + case process_info(Pid1) of + undefined -> + ok; + _PI1 -> + RefToOldP = erlang:check_process_code(Pid1, f1), + ?line ?t:fail({"Pid1 still alive", RefToOldP}) + end, + case process_info(Pid2) of + PI2 when is_list(PI2) -> + case erlang:check_process_code(Pid2, f2) of + false -> + ok; + true -> + ?line ?t:fail("Pid2 has ref to old code") + end; + undefined -> + ?line ?t:fail("Pid2 has died") + end, + + ?line file:set_cwd(CWD), + ok. + +otp_7095(doc) -> + ["andalso/orelse"]; +otp_7095(suite) -> []; +otp_7095(Config) when is_list(Config) -> + ?line ok = file:set_cwd(?config(priv_dir, Config)), + + File = "t.erl", + Test = <<"-module(t). + -export([t/0]). + t() -> + t1(), + t2(), + t3(), + t4(), + t5(), + put(t6, 0), + 0 = t6(), + 1 = erase(t6), + t7(), + put(t8, 0), + {'EXIT',{{badarg,0},_}} = (catch t8()), + 1 = erase(t8), + t9(), + ok. + + t1() -> + false % 20 + andalso + true. % 22 + + t2() -> + true % 25 + andalso + true. % 27 + + t3() -> + false % 30 + orelse + true. % 32 + + t4() -> + true % 35 + orelse + true. % 37 + + t5() -> + true % 40 + andalso + true % 42 + andalso + false. % 44 + + t6() -> + true andalso % 47 + add_one(t6). % 48 + + t7() -> + true % 51 + andalso + false % 53 + andalso + not_ok. % 55 + + t8() -> + true % 58 + andalso + true % 60 + andalso + add_one(t8) % 62 + andalso + false. % 64 + + t9() -> + if % 67 + true -> + true % 69 + andalso + false % 71 + end + orelse + case ok of % 74 + true -> + a; % 76 + _ -> + true % 78 + end. + + add_one(T) -> + put(T, get(T) + 1). % 82 + ">>, + ?line ok = file:write_file(File, Test), + ?line {ok, t} = cover:compile(File), + ?line ok = t:t(), + ?line {ok,[{{t,4},1},{{t,5},1},{{t,6},1},{{t,7},1},{{t,8},1},{{t,9},1}, + {{t,10},1},{{t,11},1},{{t,12},1},{{t,13},1},{{t,14},1}, + {{t,15},1},{{t,16},1},{{t,17},1}, + {{t,20},1},{{t,22},0}, + {{t,25},1},{{t,27},1}, + {{t,30},1},{{t,32},1}, + {{t,35},1},{{t,37},0}, + {{t,40},1},{{t,42},1},{{t,44},1}, + {{t,47},1},{{t,48},1}, + {{t,51},1},{{t,53},1},{{t,55},0}, + {{t,58},1},{{t,60},1},{{t,62},1},{{t,64},0}, + {{t,67},1},{{t,69},1},{{t,71},1},{{t,74},1}, + {{t,76},0},{{t,78},1}, + {{t,82},2}]} = cover:analyse(t, calls, line), + ?line cover:stop(), + ?line ok = file:delete(File), + + ok. + +otp_8270(doc) -> + ["OTP-8270. Bug."]; +otp_8270(suite) -> []; +otp_8270(Config) when is_list(Config) -> + ?line DataDir = ?config(data_dir, Config), + ?line ok = file:set_cwd(DataDir), + + ?line PrivDir = ?config(priv_dir, Config), + + As = [{args," -pa " ++ PrivDir}], + ?line {ok,N1} = ?t:start_node(cover_n1,slave,As), + ?line {ok,N2} = ?t:start_node(cover_n2,slave,As), + ?line {ok,N3} = ?t:start_node(cover_n3,slave,As), + + timer:sleep(500), + cover:start(nodes()), + + Test = << + "-module(m).\n" + "-compile(export_all).\n" + "t() -> t(0).\n" + "l() ->\n" + " catch ets:tab2list(cover_internal_data_table).\n" + "t(Sz) ->\n" + " case ets:info(cover_internal_data_table, size) of\n" + " Sz ->\n" + " m:t(Sz); % Not a local call! Newly loaded code is entered.\n" + " NSz ->\n" + " % error_logger:info_msg(\"~p: ~p ~p change~n L1 ~p~n\", \n" + " % [node(), Sz, NSz, l()]),\n" + " m:t(NSz)\n" + " end.\n">>, + ?line _File = c_mod(m, Test, Config), + Fun = fun m:t/0, + ?line Pid1 = spawn(Fun), + ?line Pid2 = spawn(N1, Fun), + ?line Pid3 = spawn(N2, Fun), + ?line Pid4 = spawn(N3, Fun), + + ?line {ok, m} = cover:compile_beam(m), + + timer:sleep(1000), + + ?line Info = erlang:process_info(Pid1), + ?line N1_info = rpc:call(N1, erlang, process_info, [Pid2]), + ?line N2_info = rpc:call(N2, erlang, process_info, [Pid3]), + ?line N3_info = rpc:call(N3, erlang, process_info, [Pid4]), + + ?line true = is_list(Info), + ?line {N1,true} = {N1,is_list(N1_info)}, + ?line {N2,true} = {N2,is_list(N2_info)}, + ?line {N3,true} = {N3,is_list(N3_info)}, + + ?line ?t:stop_node(N1), + ?line ?t:stop_node(N2), + ?line ?t:stop_node(N3), + ok. + +otp_8273(doc) -> + ["OTP-8270. Bug."]; +otp_8273(suite) -> []; +otp_8273(Config) when is_list(Config) -> + Test = <<"-module(t). + -export([t/0]). + t() -> + foo = true andalso foo, + bar = false orelse bar, + ok. + ">>, + ?line File = cc_mod(t, Test, Config), + ?line ok = t:t(), + ?line cover:stop(), + ?line ok = file:delete(File), + + ok. + +otp_8340(doc) -> + ["OTP-8340. Bug."]; +otp_8340(suite) -> []; +otp_8340(Config) when is_list(Config) -> + ?line [{{t,1},1},{{t,2},1},{{t,4},1}] = + analyse_expr(<<"<< \n" + " <<3:2, \n" + " SeqId:62>> \n" + " || SeqId <- [64] >>">>, Config), + + ok. + +otp_8188(doc) -> + ["Clauses on the same line."]; +otp_8188(suite) -> []; +otp_8188(Config) when is_list(Config) -> + %% This example covers the bug report: + Test = <<"-module(t). + -export([test/1]). + + -define(FOOBAR(X), + case X of + ok -> true; + _ -> false + end). + + test(X)-> + _Res = + ?FOOBAR(X). + ">>, + ?line File = cc_mod(t, Test, Config), + ?line false = t:test(nok), + ?line {ok,[{{t,11},1},{{t,12},1}]} = cover:analyse(t, calls, line), + ?line cover:stop(), + ?line ok = file:delete(File), + + %% Bit string comprehensions are now traversed; + %% the handling of list comprehensions has been improved: + comprehension_8188(Config), + + %% Variants of the reported bug: + bug_8188(Config), + ok. + +bug_8188(Cf) -> + ?line [{{t,1},1},{{t,2},1},{{t,3},1}] = + analyse_expr(<<"A = 3,\n" % 1 + " case A of\n" % 1 + " 2 -> two; 3 -> three end, A + 2">>, % 1 + Cf), + + ?line [{{t,1},1}, + {{t,2},0}, + {{t,3},1}, + {{t,4},1}, + {{t,5},1}, + {{t,6},0}, + {{t,7},1}, + {{t,9},2}] = + analyse_expr(<<"case two() of\n" % 1 + " 1 -> 2;\n" % 0 + " _ -> begin 3 end\n" % 1 + " +\n" % 1 + " begin 4 end end, case two() of\n" % 1 + " 1 -> a;\n" % 0 + " 2 -> b; 3 -> c\n" % 1 + " end.\n" + "two() -> 2">>, Cf), % 2 + + ?line [{{t,1},1}, {{t,2},1}, {{t,3},1}, + {{t,4},1}, {{t,5},1}, {{t,6},0}] = + analyse_expr(<<" self() ! 1,\n" + " receive \n" + " X=1 -> a;\n" + " X=2 -> b end, case X of \n" + " 1 -> a;\n" + " 2 -> b\n" + " end">>, Cf), + + T0 = <<"t1(X) ->\n " + "case X of\n" + " 1 -> A=a,B=A,B; % bump Li\n" + " 2 -> b; 3 -> case X of % 2 -> b shall bump Li\n" + " 3 -> a; % bump Li\n" + " 2 -> b end; 4 -> d end, case X of % Li\n" + " 1 -> a;\n" + " 2 -> b; 3 -> c;\n" + " 4 -> d\n" + " end">>, + + T1 = [<<"a = t1(1). ">>,T0], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},1}, {{t,4},0}, + {{t,5},0}, {{t,6},1}, {{t,7},1}, {{t,8},0}, {{t,9},0}] = + analyse_expr(T1, Cf), + + T2 = [<<"b = t1(2). ">>,T0], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, {{t,4},1}, + {{t,5},0}, {{t,6},1}, {{t,7},0}, {{t,8},1}, {{t,9},0}] = + analyse_expr(T2, Cf), + + T3 = [<<"c = t1(3). ">>,T0], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, {{t,4},1}, + {{t,5},1}, {{t,6},1}, {{t,7},0}, {{t,8},1}, {{t,9},0}] = + analyse_expr(T3, Cf), + + T4 = [<<"d = t1(4). ">>,T0], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, {{t,4},0}, + {{t,5},0}, {{t,6},1}, {{t,7},0}, {{t,8},0}, {{t,9},1}] = + analyse_expr(T4, Cf), + + ?line [{{t,1},1},{{t,2},1},{{t,3},1},{{t,4},1},{{t,5},1}] = + analyse_expr( + <<"2 = x3(1). " + "x3(X) ->\n" + " case X of \n" + " 1 -> case X of\n" + " 1 -> a, Y = 2;\n" + " 2 -> b, Y = 3 end, Y; 2 -> Y = 4 end, Y">>, Cf), + + ?line [{{t,1},1},{{t,2},1},{{t,3},1},{{t,4},1}] = + analyse_expr( + <<"1 = x4(1). " + "x4(X) ->\n" + " case X of\n" + " 1 -> case X of\n" + " 1 -> Y = 1 end, case X of 1 -> Y = 1 end, Y end">>, + Cf), + + T10 = <<"t1(X) ->\n" + "if\n" + " X =:= 1 -> a;\n" + " X =:= 2 -> b; X =:= 3 -> c end, case X of \n" + " 1 -> a;\n" + " 2 -> b; 3 -> c end, case X of\n" + " 1 -> a;\n" + " 2 -> b; 3 -> c\n" + " end">>, + T11 = [<<"a = t1(1). ">>,T10], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},1}, {{t,4},1}, + {{t,5},1}, {{t,6},1}, {{t,7},1}, {{t,8},0}] = + analyse_expr(T11, Cf), + + T12 = [<<"b = t1(2). ">>,T10], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, {{t,4},1}, + {{t,5},0}, {{t,6},1}, {{t,7},0}, {{t,8},1}] = + analyse_expr(T12, Cf), + + T13 = [<<"c = t1(3). ">>,T10], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, {{t,4},1}, + {{t,5},0}, {{t,6},1}, {{t,7},0}, {{t,8},1}] = + analyse_expr(T13, Cf), + + T20 = <<"t1(X) ->\n" + "case X of\n" + " 1 -> a;\n" + " 2 -> b; 3 -> case X of\n" + " 1 -> a;\n" + " 2 -> b; 3 -> c end end, case X of\n" + " 1 -> a;\n" + " 2 -> b; 3 -> c\n" + " end">>, + + T21 = [<<"a = t1(1). ">>,T20], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},1}, {{t,4},0}, + {{t,5},0}, {{t,6},1}, {{t,7},1}, {{t,8},0}] = + analyse_expr(T21, Cf), + + T22 = [<<"b = t1(2). ">>,T20], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, {{t,4},1}, + {{t,5},0}, {{t,6},1}, {{t,7},0}, {{t,8},1}] = + analyse_expr(T22, Cf), + + T23 = [<<"c = t1(3). ">>,T20], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, {{t,4},1}, + {{t,5},0}, {{t,6},1}, {{t,7},0}, {{t,8},1}] = + analyse_expr(T23, Cf), + + T30 = << + "t1(X) ->\n" + "case X of\n" + " 1 -> a;\n" + " 2 -> b; 3 -> case X of 1 -> a; 2 -> b; 3 -> c end end, case X of\n" + " 1 -> a;\n" + " 2 -> b; 3 -> c\n" + " end\n">>, + + T31 = [<<"a = t1(1). ">>,T30], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},1}, + {{t,4},1}, {{t,5},1}, {{t,6},0}] = + analyse_expr(T31, Cf), + + T32 = [<<"b = t1(2). ">>,T30], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, + {{t,4},1}, {{t,5},0}, {{t,6},1}] = + analyse_expr(T32, Cf), + + T33 = [<<"c = t1(3). ">>,T30], + ?line [{{t,1},1}, {{t,2},1}, {{t,3},0}, + {{t,4},1}, {{t,5},0}, {{t,6},1}] = + analyse_expr(T33, Cf), + + %% 'try' now traverses the body as a body... + ?line [{{t,1},1},{{t,2},1},{{t,3},1},{{t,4},0},{{t,6},1}] = + analyse_expr(<<"try \n" + " B = 2, \n" + " C = erlang:error(foo), \n" + " {B,C} \n" + "catch _:_ -> \n" + " foo \n" + "end">>, Cf), + + %% receive after: + ?line [{{t,1},1},{{t,2},0},{{t,3},1}] = + analyse_expr(<<"receive \n" + " X=1 -> a; \n" + " X=2 -> b after begin 10 end -> X=3 end">>, Cf), + ?line [{{t,1},1},{{t,2},0},{{t,3},1}] = + analyse_expr(<<"receive \n" + " X=1 -> a; \n" + " X=2 -> b after 10 -> begin X=3 end end">>, Cf), + ok. + +comprehension_8188(Cf) -> + ?line [{{t,1},1}] = + analyse_expr(<<"[begin X end || X <- [1,2,3], X > 1]">>, Cf), + ?line [{{t,1},1},{{t,2},1}] = + analyse_expr(<<"[begin X end || \n" + " X <- [1,2,3], X > 1]">>, Cf), + ?line [{{t,1},1},{{t,2},1},{{t,3},3}] = + analyse_expr(<<"[begin X end || \n " + " X <- [1,2,3], \n " + " X > 1]">>, Cf), + ?line [{{t,1},1},{{t,3},1},{{t,4},3}] = + analyse_expr(<<"[begin X end || \n " + " X <- \n " + " [1,2,3], \n " + " X > 1]">>, Cf), + ?line [{{t,1},1},{{t,2},2}] = + analyse_expr(<<"[ \n " + " X || X <- [1,2,3], X > 1]">>, Cf), + ?line [{{t,1},1},{{t,2},2},{{t,3},3}] = + analyse_expr(<<"[ \n" + " X || X <- [1,2,3], \n" + " X > 1]">>, Cf), + ?line [{{t,1},1},{{t,2},1},{{t,3},2}] = + analyse_expr(<<"[ \n " + " X || X <- [1,2,3], X > 1, \n" + " X > 2]">>, Cf), + + ?line [{{t,1},1}, + {{t,3},2}, + {{t,5},1}, + {{t,7},1}, + {{t,8},0}, + {{t,12},3}, + {{t,15},2}, + {{t,17},2}, + {{t,18},1}] = + analyse_expr(<<"[ \n" % 1 + " begin\n" + " X * 2\n" % 2 + " end ||\n" + " X <- [1,\n" % 1 + " case two() of\n" + " 2 -> 2;\n" % 1 + " _ -> two\n" % 0 + " end,\n" + " 3],\n" + " begin\n" + " math:sqrt(X) > 1.0\n" % 3 + " end,\n" + " begin\n" + " true\n" % 2 + " end,\n" + " true]. \n" % 2 + " two() -> 2">>, Cf), % 1 + + ?line [{{t,1},1}, + {{t,2},2}, + {{t,3},1}, + {{t,5},1}, + {{t,6},0}, + {{t,9},3}, + {{t,10},2}, + {{t,11},2}, + {{t,12},1}] = + analyse_expr(<<"[ \n" + " X * 2 || \n" % 2 + " X <- [1,\n" % 1 + " case two() of\n" + " 2 -> 2;\n" % 1 + " _ -> two\n" % 0 + " end,\n" + " 3],\n" + " math:sqrt(X) > 1.0,\n" % 3 + " true,\n" % 2 + " true]. \n" % 2 + " two() -> 2">>, Cf), % 1 + + ?line [{{t,1},1}, + {{t,2},2}, + {{t,3},1}, + {{t,4},1}, + {{t,5},0}, + {{t,8},1}, + {{t,9},0}, + {{t,12},3}, + {{t,13},2}, + {{t,14},2}] = + analyse_expr(<<"<< \n" % 1 + " << (X*2) >> || \n" % 2 + " <<X>> <= << (case two() of\n" + " 2 -> 1;\n" % 1 + " _ -> 2\n" % 0 + " end)/integer,\n" + " (case two() of \n" + " 2 -> 2;\n" % 1 + " _ -> two\n" % 0 + " end)/integer,\n" + " 3 >>, \n" + " math:sqrt(X) > 1.0,\n" % 3 + " true >>.\n" % 2 + "two() -> 2">>, Cf), + + ?line [{{t,1},1}, + {{t,2},4}, + {{t,4},1}, + {{t,6},1}, + {{t,7},0}, + {{t,10},3}, + {{t,11},2}, + {{t,12},4}, + {{t,13},1}] = + analyse_expr(<<"<< \n" % 1 + " << (2)\n" % 4 + " :(8) >> || \n" + " <<X>> <= << 1,\n" % 1 + " (case two() of \n" + " 2 -> 2;\n" % 1 + " _ -> two\n" % 0 + " end)/integer,\n" + " 3 >>, \n" + " math:sqrt(X) > 1.0,\n" % 3 + " <<_>> <= << 1, 2 >>,\n" % 2 + " true >>.\n" % 4 + "two() -> 2">>, Cf), % 1 + + ok. + +%%--Auxiliary------------------------------------------------------------ + +analyse_expr(Expr, Config) -> + Binary = [<<"-module(t). " + "-export([t/0]). " + "t() -> ">>, Expr, <<".\n">>], + File = cc_mod(t, Binary, Config), + t:t(), + {ok, Result} = cover:analyse(t, calls, line), + ok = file:delete(File), + Result. + +cc_mod(M, Binary, Config) -> + {ok, Dir} = file:get_cwd(), + PrivDir = ?config(priv_dir, Config), + ok = file:set_cwd(PrivDir), + File = atom_to_list(M) ++ ".erl", + try + ok = file:write_file(File, Binary), + {ok, M} = cover:compile(File), + filename:join(PrivDir, File) + after file:set_cwd(Dir) + end. + +c_mod(M, Binary, Config) -> + {ok, Dir} = file:get_cwd(), + PrivDir = ?config(priv_dir, Config), + ok = file:set_cwd(PrivDir), + File = atom_to_list(M) ++ ".erl", + try + ok = file:write_file(File, Binary), + {ok, M} = compile:file(File, [debug_info]), + code:purge(M), + AbsFile = filename:rootname(File, ".erl"), + code:load_abs(AbsFile, M), + filename:join(PrivDir, File) + after file:set_cwd(Dir) + end. + +lsfiles() -> + {ok, CWD} = file:get_cwd(), + lsfiles(CWD). + +lsfiles(Dir) -> + {ok, Files} = file:list_dir(Dir), + Files. + +files(Files, Ext) -> + lists:filter(fun(File) -> + case filename:extension(File) of + Ext -> true; + _ -> false + end + end, + Files). + +remove([File|Files]) -> + ok = file:delete(File), + remove(Files); +remove([]) -> + ok. + +decompile([Mod|Mods]) -> + code:purge(Mod), + code:delete(Mod), + decompile(Mods); +decompile([]) -> + ok. + +is_unloaded(What) -> + if + is_list(What) -> true; + What==non_existing -> true; + true -> false + end. + +check_f_calls(F1,F2) -> + {ok,[{{f,f1,0},F1},{{f,f2,0},F2}]} = cover:analyse(f,calls,function). diff --git a/lib/tools/test/cover_SUITE_data/a.erl b/lib/tools/test/cover_SUITE_data/a.erl new file mode 100644 index 0000000000..31119821cd --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/a.erl @@ -0,0 +1,55 @@ +-module(a). +-export([start/1, stop/1]). +-export([pong/1]). +-export([loop/3,exit_kalle/0]). + +%% start(N) -> pid() +%% N = integer() +start(N) -> + Pong = b:start(), + spawn(?MODULE, loop, [self(), N, Pong]), + receive + done -> + {exit,kalle} = trycatch(fun ?MODULE:exit_kalle/0), + {throw,kalle} = trycatch(fun() -> throw(kalle) end), + done + end. + +%% stop(Ping) -> stop +%% Ping = pid() +stop(Ping) -> + Ping ! stop. + +%% pong(Ping) -> pong +%% Ping = pid() +pong(Ping) -> + Ping ! pong. + +%%--Internal functions------------------------------------------------ + +loop(Starter, N, Pong) when N>0 -> + Pong ! {ping, self()}, + receive + pong -> + loop(Starter, N-1, Pong); + stop -> + done + end; +loop(Starter, 0, Pong) -> + Pong ! stop, + Starter ! done. + + +trycatch(Fun) -> + try Fun() + catch + Throw -> + {throw,Throw}; + exit:Reason -> + {exit,Reason} + after + cleanup + end. + +exit_kalle() -> + exit(kalle). diff --git a/lib/tools/test/cover_SUITE_data/b.erl b/lib/tools/test/cover_SUITE_data/b.erl new file mode 100644 index 0000000000..13f39b8cb9 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/b.erl @@ -0,0 +1,14 @@ +-module(b). +-export([start/0, loop/0]). + +start() -> + spawn(?MODULE, loop, []). + +loop() -> + receive + {ping, Ping} -> + a:pong(Ping), + loop(); + stop -> + done + end. diff --git a/lib/tools/test/cover_SUITE_data/cc.erl b/lib/tools/test/cover_SUITE_data/cc.erl new file mode 100644 index 0000000000..587bdbe493 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/cc.erl @@ -0,0 +1,88 @@ +-module(cc). +-export([epp/1, epp/2, dbg/1, dbg/2, cvr/1, cvr/2]). +-export([p/2, pp/2]). + +%% epp(Module) - Creates Module.epp which contains all forms of Module +%% as obtained by using epp. +%% +%% dbg(Module) - Creates Module.dbg which contains all forms of Module +%% as obtained by using beam_lib:chunks/2. +%% +%% cvr(Module) - Creates Module.cvr which contains all forms of Module +%% as obtained by using cover:transform/3. +%% + +epp(Module) -> + epp(Module, p). +epp(Module, P) -> + File = atom_to_list(Module)++".erl", + {ok,Cwd} = file:get_cwd(), + {ok, Fd1} = epp:open(File, [Cwd], []), + {ok, Fd2} = file:open(atom_to_list(Module)++".epp", write), + + epp(Fd1, Fd2, P), + + epp:close(Fd1), + file:close(Fd2), + ok. + +epp(Fd1, Fd2, P) -> + case epp:parse_erl_form(Fd1) of + {ok, {attribute,Line,Attr,Data}} -> + epp(Fd1, Fd2, P); + {ok, Form} when P==p -> + io:format(Fd2, "~p.~n", [Form]), + epp(Fd1, Fd2, P); + {ok, Form} when P==pp -> + io:format(Fd2, "~p.~n", [erl_pp:form(Form)]), + epp(Fd1, Fd2, P); + {eof, Line} -> + ok + end. + +cvr(Module) -> + cvr(Module, p). +cvr(Module, P) -> + case beam_lib:chunks(Module, [abstract_code]) of + {ok, {Module, [{abstract_code, no_abstract_code}]}} -> + {error, {no_debug_info,Module}}; + {ok, {Module, [{abstract_code, {Vsn, Forms}}]}} -> + Vars = {vars,Module,Vsn, [], + undefined, undefined, undefined, undefined, undefined, + undefined, + false}, + {ok, TForms, _Vars2} = cover:transform(Forms, [], Vars), + File = atom_to_list(Module)++".cvr", + apply(?MODULE, P, [File, TForms]); + Error -> + Error + end. + +dbg(Module) -> + dbg(Module, p). +dbg(Module, P) -> + case beam_lib:chunks(Module, [abstract_code]) of + {ok, {Module, [{abstract_code, no_abstract_code}]}} -> + {error, {no_debug_info,Module}}; + {ok, {Module, [{abstract_code, {Vsn, Forms}}]}} -> + File = atom_to_list(Module)++".dbg", + apply(?MODULE, P, [File, Forms]); + Error -> + Error + end. + +p(File, Forms) -> + {ok, Fd} = file:open(File, write), + lists:foreach(fun(Form) -> + io:format(Fd, "~p.~n", [Form]) + end, + Forms), + file:close(Fd). + +pp(File, Forms) -> + {ok, Fd} = file:open(File, write), + lists:foreach(fun(Form) -> + io:format(Fd, "~s", [erl_pp:form(Form)]) + end, + Forms), + file:close(Fd). diff --git a/lib/tools/test/cover_SUITE_data/compile_beam/crypt.erl b/lib/tools/test/cover_SUITE_data/compile_beam/crypt.erl new file mode 100644 index 0000000000..1596777edf --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/compile_beam/crypt.erl @@ -0,0 +1,6 @@ +-module(crypt). + +-export([f/0]). + +f() -> + ok. diff --git a/lib/tools/test/cover_SUITE_data/compile_beam/d/y.erl b/lib/tools/test/cover_SUITE_data/compile_beam/d/y.erl new file mode 100644 index 0000000000..14b9461410 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/compile_beam/d/y.erl @@ -0,0 +1,6 @@ +-module(y). + +-export([f/0]). + +f() -> + ok. diff --git a/lib/tools/test/cover_SUITE_data/compile_beam/v.erl b/lib/tools/test/cover_SUITE_data/compile_beam/v.erl new file mode 100644 index 0000000000..007957297a --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/compile_beam/v.erl @@ -0,0 +1,6 @@ +-module(v). + +-export([f/0]). + +f() -> + ok. diff --git a/lib/tools/test/cover_SUITE_data/compile_beam/w.erl b/lib/tools/test/cover_SUITE_data/compile_beam/w.erl new file mode 100644 index 0000000000..88ad606db8 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/compile_beam/w.erl @@ -0,0 +1,6 @@ +-module(w). + +-export([f/0]). + +f() -> + ok. diff --git a/lib/tools/test/cover_SUITE_data/compile_beam/x.erl b/lib/tools/test/cover_SUITE_data/compile_beam/x.erl new file mode 100644 index 0000000000..8953f6d05d --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/compile_beam/x.erl @@ -0,0 +1,6 @@ +-module(x). + +-export([f/0]). + +f() -> + ok. diff --git a/lib/tools/test/cover_SUITE_data/d.erl b/lib/tools/test/cover_SUITE_data/d.erl new file mode 100644 index 0000000000..696e27e49b --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/d.erl @@ -0,0 +1,156 @@ +-module(d). + +-export([start/0, stop/0]). +-export([store/2, store/3, move/2, + location/1, who_are_at/1, who_are_older/1, + size/0]). +-export([init/0]). % spawn + +-record(person, {name, age, location, moved=false}). + +%%%---------------------------------------------------------------------- +%%% User interface functions +%%%---------------------------------------------------------------------- + +%%% start() -> pid() +start() -> + spawn(?MODULE, init, []). + +%%% stop() +stop() -> + arne ! stop. + +%%% store(Name, Location) -> +%%% store(Name, Age, Location) -> ok | {error,Reason} +%%% Name = Location = atom() +%%% Age = integer() +%%% Reason = not_started | no_response | {internal_error,term()} +store(Name, Location) -> + store(Name, ?AGE, Location). +store(Name, Age, Location) when atom(Name), integer(Age), atom(Location) -> + send({store, Name, Age, Location}). + +%%% move(OldLocation, NewLocation) -> Names | {error,Reason} +%%% OldLocation = NewLocation = atom() +%%% Names = [Name] +%%% Name = atom() +%%% Reason = not_started | no_response | {internal_error,term()} +move(OldLocation, NewLocation) -> + send({move, OldLocation, NewLocation}). + +%%% location(Name) -> Location | no_such_person | {error,Reason} +%%% Name = atom() +%%% Reason = not_started | no_response | {internal_error,term()} +location(Name) when atom(Name) -> + send({location, Name}). + +%%% who_are_at(Location) -> Names | {error,Reason} +%%% Location = atom() +%%% Names = [Name] +%%% Name = atom() +%%% Reason = not_started | no_response | {internal_error,term()} +who_are_at(Location) when atom(Location) -> + send({who_are_at, Location}). + +%%% who_are_older(Age) -> Names | {error,Reason} +%%% Age = integer() +%%% Names = [Name] +%%% Name = atom() +%%% Reason = not_started | no_response | {internal_error,term()} +who_are_older(Age) when integer(Age) -> + send({who_are_older, Age}). + +%%% size() -> N | {error,Reason} +%%% N = integer() +%%% Reason = not_started | no_response | {internal_error,term()} +size() -> + send(size). + +%%%---------------------------------------------------------------------- +%%% Main loop +%%%---------------------------------------------------------------------- +send(Request) -> + Pid = whereis(arne), + if + Pid==undefined -> + {error, not_started}; + true -> + send(Pid, Request) + end. +send(Pid, Request) -> + Pid ! {request, self(), Request}, + receive + {reply, Reply} -> + Reply + after + 1000 -> + {error, no_response} + end. + +init() -> + register(arne, self()), + loop([]). + +loop(Db) -> + receive + stop -> + true; + {request, From, Request} -> + case catch handle(Request, Db) of + {reply, Reply, NewDb} -> + From ! {reply, Reply}, + loop(NewDb); + {'EXIT', Reason} -> + From ! {reply, {error, {internal_error, Reason}}}, + loop(Db) + end + end. + +%%%---------------------------------------------------------------------- +%%% DB functionality +%%%---------------------------------------------------------------------- +handle({store, Name, Age, Location}, Db) -> + {reply, ok, [#person{name=Name, age=Age, location=Location} | Db]}; +handle({move, OldLocation, NewLocation}, Db) -> + {Names, NewDb} = move(OldLocation, NewLocation, Db, [], []), + {reply, Names, NewDb}; +handle({location, Name}, Db) -> + case lists:keysearch(Name, #person.name, Db) of + {value, #person{location=Location}} when atom(Location) -> + {reply, Location, Db}; + false -> + {reply, no_such_name, Db} + end; +handle({who_are_at, Location}, Db) -> + Result = lists:foldl(fun(Person, Names) -> + case Person#person.location of + Location -> + [Person#person.name | Names]; + _OtherLocation -> + Names + end + end, + [], + Db), + {reply, Result, Db}; +handle({who_are_older, Old}, Db) -> + Result = [Name || {person,Name,Age,Location} <- Db, + Age>Old], + {reply, Result, Db}; +handle(size, Db) -> + Result = count(Db, 0), {reply, Result, Db}. + +count([H|T], N) -> + count(T, N+1); +count([], N) -> + N. + +move(OldLoc, NewLoc, [#person{location=OldLoc} = Person|T], Db, Names) -> + NewPerson = Person#person{location=NewLoc, + moved=true}, + NewNames = [Person#person.name|Names], + move(OldLoc, NewLoc, T, [NewPerson|Db], NewNames); +move(OldLoc, NewLoc, [Person|T], Db, Names) -> + move(OldLoc, NewLoc, T, [Person|Db], Names); +move(OldLoc, NewLoc, [], Db, Names) -> + {lists:reverse(Names), lists:reverse(Db)}. diff --git a/lib/tools/test/cover_SUITE_data/d1/e.erl b/lib/tools/test/cover_SUITE_data/d1/e.erl new file mode 100644 index 0000000000..b4041d48e6 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/d1/e.erl @@ -0,0 +1,127 @@ +-module(e). +-behaviour(gen_server). + +%% External exports +-export([start_link/0]). +-export([hello/0]). + +%% gen_server callbacks +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). + +-record(state, {}). + +%%%---------------------------------------------------------------------- +%%% API +%%%---------------------------------------------------------------------- +start_link() -> + gen_server:start_link({local, myserver}, myserver, [], []). + +hello() -> + gen_server:call(myserver, hello). + +%%%---------------------------------------------------------------------- +%%% Callback functions from gen_server +%%%---------------------------------------------------------------------- + +%%---------------------------------------------------------------------- +%% Func: init/1 +%% Returns: {ok, State} | +%% {ok, State, Timeout} | +%% ignore | +%% {stop, Reason} +%%---------------------------------------------------------------------- +init([]) -> + {ok, #state{}}. + +%%---------------------------------------------------------------------- +%% Func: handle_call/3 +%% Returns: {reply, Reply, State} | +%% {reply, Reply, State, Timeout} | +%% {noreply, State} | +%% {noreply, State, Timeout} | +%% {stop, Reason, Reply, State} | (terminate/2 is called) +%% {stop, Reason, State} (terminate/2 is called) +%%---------------------------------------------------------------------- +handle_call(Request, From, State) -> + Reply = case Request of + char -> + $B; + integer -> + 17; + float -> + 32.76; + string -> + "hi there"; + atom -> + hello; + block -> + begin + a, + b + end; + binary -> + <<1, 2, 3>> + end, + {reply, Reply, State}. + +%%---------------------------------------------------------------------- +%% Func: handle_cast/2 +%% Returns: {noreply, State} | +%% {noreply, State, Timeout} | +%% {stop, Reason, State} (terminate/2 is called) +%%---------------------------------------------------------------------- +handle_cast(Msg, State) when atom(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when binary(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when not is_tuple(Msg), not is_list(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when float(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when function(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when integer(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when list(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when number(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when pid(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when port(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when reference(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when tuple(Msg) -> + {noreply, State}. + +%%---------------------------------------------------------------------- +%% Func: handle_info/2 +%% Returns: {noreply, State} | +%% {noreply, State, Timeout} | +%% {stop, Reason, State} (terminate/2 is called) +%%---------------------------------------------------------------------- +handle_info(Info, State) -> + {noreply, State}. + +%%---------------------------------------------------------------------- +%% Func: terminate/2 +%% Purpose: Shutdown the server +%% Returns: any (ignored by gen_server) +%%---------------------------------------------------------------------- +terminate(Reason, State) -> + ok. + +%%---------------------------------------------------------------------- +%% Func: code_change/3 +%% Purpose: Convert process state when code is changed +%% Returns: {ok, NewState} +%%---------------------------------------------------------------------- +code_change(OldVsn, State, Extra) -> + {ok, State}. + +%%%---------------------------------------------------------------------- +%%% Internal functions +%%%---------------------------------------------------------------------- + diff --git a/lib/tools/test/cover_SUITE_data/f.erl b/lib/tools/test/cover_SUITE_data/f.erl new file mode 100644 index 0000000000..1ef8bbdb49 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/f.erl @@ -0,0 +1,10 @@ +-module(f). +-export([f1/0,f2/0]). + +f1() -> + f1_line1, + f1_line2. + +f2() -> + f2_line1, + f2_line2. diff --git a/lib/tools/test/cover_SUITE_data/included_functions/cover_inc.erl b/lib/tools/test/cover_SUITE_data/included_functions/cover_inc.erl new file mode 100644 index 0000000000..fa8eebfd00 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/included_functions/cover_inc.erl @@ -0,0 +1,8 @@ +-module(cover_inc). +-compile(export_all). +-include("cover_inc.hrl"). + +func() -> + func1(), + ok. + diff --git a/lib/tools/test/cover_SUITE_data/included_functions/cover_inc.hrl b/lib/tools/test/cover_SUITE_data/included_functions/cover_inc.hrl new file mode 100644 index 0000000000..cbdfe601d1 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/included_functions/cover_inc.hrl @@ -0,0 +1,7 @@ +func1() -> + A = line_2_in_include_file, + erlang:display(A), + line_4_in_include_file. + + + diff --git a/lib/tools/test/cover_SUITE_data/otp_6115/f1.erl b/lib/tools/test/cover_SUITE_data/otp_6115/f1.erl new file mode 100644 index 0000000000..b659e5d818 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/otp_6115/f1.erl @@ -0,0 +1,12 @@ +-module(f1). +-export([start_fail/0, start_ok/0]). + +start_fail() -> + f2:start(fun() -> + io:format("this does not work\n",[]) + end). + +start_ok() -> + f2:start(fun fun1/0). +fun1() -> + io:format("this works\n",[]). diff --git a/lib/tools/test/cover_SUITE_data/otp_6115/f2.erl b/lib/tools/test/cover_SUITE_data/otp_6115/f2.erl new file mode 100644 index 0000000000..72a6a64c4d --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/otp_6115/f2.erl @@ -0,0 +1,13 @@ +-module(f2). +-export([start/1]). + +start(Fun) -> + spawn(fun() -> + wait(Fun) + end). + +wait(Fun) -> + receive + go -> + Fun() + end. diff --git a/lib/tools/test/cprof_SUITE.erl b/lib/tools/test/cprof_SUITE.erl new file mode 100644 index 0000000000..e697cc1571 --- /dev/null +++ b/lib/tools/test/cprof_SUITE.erl @@ -0,0 +1,309 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2002-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% +%%% Define to run outside of test server +%%% +%%% -define(STANDALONE,1). +%%% +%%% +%%% Define for debug output +%%% +%%% -define(debug,1). + +-module(cprof_SUITE). + +%% Exported end user tests +-export([basic_test/0, on_load_test/1, modules_test/1]). + +%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Test server related stuff +%% + +-ifdef(STANDALONE). +-define(config(A,B),config(A,B)). +-export([config/2]). +-else. +-include("test_server.hrl"). +-endif. + +-ifdef(debug). +-ifdef(STANDALONE). +-define(line, erlang:display({?MODULE,?LINE}), ). +-endif. +-define(dbgformat(A,B),io:format(A,B)). +-else. +-ifdef(STANDALONE). +-define(line, noop, ). +-endif. +-define(dbgformat(A,B),noop). +-endif. + +-ifdef(STANDALONE). +config(priv_dir, _) -> + "."; +config(data_dir, _) -> + "cprof_SUITE_data". +-else. +%% When run in test server. +-export([all/1, init_per_testcase/2, fin_per_testcase/2, not_run/1]). +-export([basic/1, on_load/1, modules/1]). + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(test_server:seconds(30)), + [{watchdog, Dog}|Config]. + +fin_per_testcase(_Case, Config) -> + erlang:trace_pattern({'_','_','_'}, false, [local,meta,call_count]), + erlang:trace_pattern(on_load, false, [local,meta,call_count]), + erlang:trace(all, false, [all]), + Dog=?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +all(doc) -> + ["Test the cprof profiling tool."]; +all(suite) -> + case test_server:is_native(?MODULE) of + true -> [not_run]; + false -> [basic, on_load, modules] +%, on_and_off, info, +% pause_and_restart, combo] + end. + +not_run(Config) when is_list(Config) -> + {skipped,"Native code"}. + +basic(suite) -> + []; +basic(doc) -> + ["Tests basic profiling"]; +basic(Config) when is_list(Config) -> + basic_test(). + +on_load(suite) -> + []; +on_load(doc) -> + ["Tests profiling of unloaded module"]; +on_load(Config) when is_list(Config) -> + on_load_test(Config). + +modules(suite) -> + []; +modules(doc) -> + ["Tests profiling of several modules"]; +modules(Config) when is_list(Config) -> + modules_test(Config). + +-endif. %-ifdef(STANDALONE). ... -else. + +%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% The Tests +%%% + +basic_test() -> + ?line M = 1000, + %% + ?line M2 = M*2, + ?line M3 = M*3, + ?line M2__1 = M2 + 1, + ?line M3__1 = M3 + 1, + ?line N = cprof:stop(), + %% + ?line 2 = cprof:start(?MODULE, seq_r), + ?line 1 = cprof:start(?MODULE, seq, 3), + ?line L = seq(1, M, fun succ/1), + ?line Lr = seq_r(1, M, fun succ/1), + ?line L = lists:reverse(Lr), + %% + ?line io:format("~p~n~p~n~p~n", + [erlang:trace_info({?MODULE,sec_r,3}, all), + erlang:trace_info({?MODULE,sec_r,4}, all), + erlang:trace_info({?MODULE,sec,3}, all)]), + %% + ?line ModAna1 = {?MODULE,M2__1,[{{?MODULE,seq_r,4},M}, + {{?MODULE,seq,3},M}, + {{?MODULE,seq_r,3},1}]}, + ?line ModAna1 = cprof:analyse(?MODULE,0), + ?line {M2__1, [ModAna1]} = cprof:analyse(), + ?line ModAna1 = cprof:analyse(?MODULE, 1), + ?line {M2__1, [ModAna1]} = cprof:analyse(1), + %% + ?line ModAna2 = {?MODULE,M2__1,[{{?MODULE,seq_r,4},M}, + {{?MODULE,seq,3},M}]}, + ?line ModAna2 = cprof:analyse(?MODULE, 2), + ?line {M2__1, [ModAna2]} = cprof:analyse(2), + %% + 2 = cprof:pause(?MODULE, seq_r), + ?line L = seq(1, M, fun succ/1), + ?line Lr = seq_r(1, M, fun succ/1), + %% + ?line ModAna3 = {?MODULE,M3__1,[{{?MODULE,seq,3},M2}, + {{?MODULE,seq_r,4},M}, + {{?MODULE,seq_r,3},1}]}, + ?line ModAna3 = cprof:analyse(?MODULE), + %% + ?line N = cprof:pause(), + ?line L = seq(1, M, fun succ/1), + ?line Lr = seq_r(1, M, fun succ/1), + %% + ?line {M3__1, [ModAna3]} = cprof:analyse(), + %% + ?line N = cprof:restart(), + ?line L = seq(1, M, fun succ/1), + ?line Lr = seq_r(1, M, fun succ/1), + %% + ?line ModAna1 = cprof:analyse(?MODULE), + %% + ?line N = cprof:stop(), + ?line {?MODULE,0,[]} = cprof:analyse(?MODULE), + ?line {0,[]} = cprof:analyse(), + ok. + +%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +on_load_test(Config) -> + ?line Priv = ?config(priv_dir, Config), + ?line Data = ?config(data_dir, Config), + ?line File = filename:join(Data, "cprof_SUITE_test"), + ?line Module = cprof_SUITE_test, + ?line M = 1000, + %% + ?line M2 = M*2, + ?line M2__1 = M2 + 1, + ?line N1 = cprof:start(), + + ?line {ok,Module} = c:c(File, [{outdir,Priv}]), + + %% If this system is hipe-enabled, the loader may have called module_info/1 + %% when Module was loaded above. Reset the call count to avoid seeing + %% the call in the analysis below. + + ?line 1 = cprof:restart(Module, module_info, 1), + + ?line L = Module:seq(1, M, fun succ/1), + ?line Lr = Module:seq_r(1, M, fun succ/1), + ?line Lr = lists:reverse(L), + ?line N2 = cprof:pause(), + ?line N3 = cprof:pause(Module), + ?line {Module,M2__1,[{{Module,seq_r,4},M}, + {{Module,seq,3},M}, + {{Module,seq_r,3},1}]} = cprof:analyse(Module), + ?line io:format("~p ~p ~p~n", [N1, N2, N3]), + ?line code:purge(Module), + ?line code:delete(Module), + ?line N4 = N2 - N3, + %% + ?line N4 = cprof:restart(), + ?line {ok,Module} = c:c(File, [{outdir,Priv}]), + ?line L = Module:seq(1, M, fun succ/1), + ?line Lr = Module:seq_r(1, M, fun succ/1), + ?line L = seq(1, M, fun succ/1), + ?line Lr = seq_r(1, M, fun succ/1), + ?line N2 = cprof:pause(), + ?line {Module,0,[]} = cprof:analyse(Module), + ?line M_1 = M - 1, + ?line M4__4 = M*4 - 4, + ?line M10_7 = M*10 - 7, + ?line {?MODULE,M10_7,[{{?MODULE,succ,1},M4__4}, + {{?MODULE,seq_r,4},M}, + {{?MODULE,seq,3},M}, + {{?MODULE,'-on_load_test/1-fun-5-',1},M_1}, + {{?MODULE,'-on_load_test/1-fun-4-',1},M_1}, + {{?MODULE,'-on_load_test/1-fun-3-',1},M_1}, + {{?MODULE,'-on_load_test/1-fun-2-',1},M_1}, + {{?MODULE,seq_r,3},1}]} + = cprof:analyse(?MODULE), + ?line N2 = cprof:stop(), + ok. + +%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +modules_test(Config) -> + ?line Priv = ?config(priv_dir, Config), + ?line Data = ?config(data_dir, Config), + ?line File = filename:join(Data, "cprof_SUITE_test"), + ?line Module = cprof_SUITE_test, + ?line {ok,Module} = c:c(File, [{outdir,Priv}]), + ?line M = 10, + %% + ?line M2 = M*2, + ?line M2__1 = M2 + 1, + ?line erlang:yield(), + ?line N = cprof:start(), + ?line L = Module:seq(1, M, fun succ/1), + ?line Lr = Module:seq_r(1, M, fun succ/1), + ?line L = seq(1, M, fun succ/1), + ?line Lr = seq_r(1, M, fun succ/1), + ?line N = cprof:pause(), + ?line Lr = lists:reverse(L), + ?line M_1 = M - 1, + ?line M4_4 = M*4 - 4, + ?line M10_7 = M*10 - 7, + ?line M2__1 = M*2 + 1, + ?line {Tot,ModList} = cprof:analyse(), + ?line {value,{?MODULE,M10_7,[{{?MODULE,succ,1},M4_4}, + {{?MODULE,seq_r,4},M}, + {{?MODULE,seq,3},M}, + {{?MODULE,'-modules_test/1-fun-3-',1},M_1}, + {{?MODULE,'-modules_test/1-fun-2-',1},M_1}, + {{?MODULE,'-modules_test/1-fun-1-',1},M_1}, + {{?MODULE,'-modules_test/1-fun-0-',1},M_1}, + {{?MODULE,seq_r,3},1}]}} = + lists:keysearch(?MODULE, 1, ModList), + ?line {value,{Module,M2__1,[{{Module,seq_r,4},M}, + {{Module,seq,3},M}, + {{Module,seq_r,3},1}]}} = + lists:keysearch(Module, 1, ModList), + ?line Tot = lists:foldl(fun ({_,C,_}, A) -> C+A end, 0, ModList), + ?line {cprof,_,Prof} = cprof:analyse(cprof), + ?line {value,{{cprof,pause,0},1}} = + lists:keysearch({cprof,pause,0}, 1, Prof), + ?line N = cprof:stop(), + ok. + + + +%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Local helpers + + + +%% Stack recursive seq +seq(Stop, Stop, Succ) when is_function(Succ) -> + [Stop]; +seq(Start, Stop, Succ) when is_function(Succ) -> + [Start | seq(Succ(Start), Stop, Succ)]. + + + +%% Tail recursive seq, result list is reversed +seq_r(Start, Stop, Succ) when is_function(Succ) -> + seq_r(Start, Stop, Succ, []). + +seq_r(Stop, Stop, _, R) -> + [Stop | R]; +seq_r(Start, Stop, Succ, R) -> + seq_r(Succ(Start), Stop, Succ, [Start | R]). + + + +%% Successor +succ(X) -> X+1. diff --git a/lib/tools/test/cprof_SUITE_data/cprof_SUITE_test.erl b/lib/tools/test/cprof_SUITE_data/cprof_SUITE_test.erl new file mode 100644 index 0000000000..02d8b027e5 --- /dev/null +++ b/lib/tools/test/cprof_SUITE_data/cprof_SUITE_test.erl @@ -0,0 +1,25 @@ +-module(cprof_SUITE_test). + +-export([seq/3, seq_r/3]). + + + +%% Stack recursive seq +seq(Stop, Stop, Succ) when function(Succ) -> + [Stop]; +seq(Start, Stop, Succ) when function(Succ) -> + [Start | seq(Succ(Start), Stop, Succ)]. + + + +%% Tail recursive seq, result list is reversed +seq_r(Start, Stop, Succ) when function(Succ) -> + seq_r(Start, Stop, Succ, []). + +seq_r(Stop, Stop, _, R) -> + [Stop | R]; +seq_r(Start, Stop, Succ, R) -> + seq_r(Succ(Start), Stop, Succ, [Start | R]). + + + diff --git a/lib/tools/test/emem_SUITE.erl b/lib/tools/test/emem_SUITE.erl new file mode 100644 index 0000000000..430fa86c6c --- /dev/null +++ b/lib/tools/test/emem_SUITE.erl @@ -0,0 +1,713 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(emem_SUITE). + +%%-define(line_trace, 1). + +-export([init_per_suite/1, end_per_suite/1, + receive_and_save_trace/2, send_trace/2]). + + +-export([all/1, init_per_testcase/2, fin_per_testcase/2]). + +-export([live_node/1, + 'sparc_sunos5.8_32b_emt2.0'/1, + 'pc_win2000_32b_emt2.0'/1, + 'pc.smp_linux2.2.19pre17_32b_emt2.0'/1, + 'powerpc_darwin7.7.0_32b_emt2.0'/1, + 'alpha_osf1v5.1_64b_emt2.0'/1, + 'sparc_sunos5.8_64b_emt2.0'/1, + 'sparc_sunos5.8_32b_emt1.0'/1, + 'pc_win2000_32b_emt1.0'/1, + 'powerpc_darwin7.7.0_32b_emt1.0'/1, + 'alpha_osf1v5.1_64b_emt1.0'/1, + 'sparc_sunos5.8_64b_emt1.0'/1]). + +-include_lib("kernel/include/file.hrl"). + +-include("test_server.hrl"). + +-define(DEFAULT_TIMEOUT, ?t:minutes(5)). + +-define(EMEM_64_32_COMMENT, + "64 bit trace; this build of emem can only handle 32 bit traces"). + +-record(emem_res, {nodename, + hostname, + pid, + start_time, + trace_version, + max_word_size, + word_size, + last_values, + maximum, + exit_code}). + +%% +%% +%% Exported suite functions +%% +%% + +all(doc) -> []; +all(suite) -> + case is_debug_compiled() of + true -> {skipped, "Not run when debug compiled"}; + false -> test_cases() + end. + +test_cases() -> + [live_node, + 'sparc_sunos5.8_32b_emt2.0', + 'pc_win2000_32b_emt2.0', + 'pc.smp_linux2.2.19pre17_32b_emt2.0', + 'powerpc_darwin7.7.0_32b_emt2.0', + 'alpha_osf1v5.1_64b_emt2.0', + 'sparc_sunos5.8_64b_emt2.0', + 'sparc_sunos5.8_32b_emt1.0', + 'pc_win2000_32b_emt1.0', + 'powerpc_darwin7.7.0_32b_emt1.0', + 'alpha_osf1v5.1_64b_emt1.0', + 'sparc_sunos5.8_64b_emt1.0']. + +init_per_testcase(Case, Config) when is_list(Config) -> + case maybe_skip(Config) of + {skip, _}=Skip -> Skip; + ok -> + Dog = ?t:timetrap(?DEFAULT_TIMEOUT), + + %% Until emem is completely stable we run these tests in a working + %% directory with an ignore_core_files file which will make the + %% search for core files ignore cores generated by this suite. + ignore_cores:setup(?MODULE, + Case, + [{watchdog, Dog}, {testcase, Case} | Config]) + end. + +fin_per_testcase(_Case, Config) when is_list(Config) -> + ignore_cores:restore(Config), + Dog = ?config(watchdog, Config), + ?t:timetrap_cancel(Dog), + ok. + +maybe_skip(Config) -> + DataDir = ?config(data_dir, Config), + case filelib:is_dir(DataDir) of + false -> + {skip, "No data directory"}; + true -> + case ?config(emem, Config) of + undefined -> + {skip, "emem not found"}; + _ -> + ok + end + end. + +init_per_suite(Config) when is_list(Config) -> + BinDir = filename:join([code:lib_dir(tools), "bin"]), + Target = erlang:system_info(system_architecture), + Res = (catch begin + case check_dir(filename:join([BinDir, Target])) of + not_found -> ok; + TDir -> + check_emem(TDir, purecov), + check_emem(TDir, purify), + check_emem(TDir, debug), + check_emem(TDir, opt) + end, + check_emem(BinDir, opt), + "" + end), + Res ++ ignore_cores:init(Config). + +end_per_suite(Config) when is_list(Config) -> + Config1 = lists:keydelete(emem, 1, Config), + Config2 = lists:keydelete(emem_comment, 1, Config1), + ignore_cores:fini(Config2). + +%% +%% +%% Test cases +%% +%% + +live_node(doc) -> []; +live_node(suite) -> []; +live_node(Config) when is_list(Config) -> + ?line {ok, EmuFlag, Port} = start_emem(Config), + ?line Nodename = mk_nodename(Config), + ?line {ok, Node} = start_node(Nodename, EmuFlag), + ?line NP = spawn(Node, + fun () -> + receive go -> ok end, + I = spawn(fun () -> ignorer end), + GC = fun () -> + GCP = fun (P) -> + garbage_collect(P) + end, + lists:foreach(GCP, processes()) + end, + Seq = fun () -> I ! lists:seq(1, 1000000) end, + spawn_link(Seq), + B1 = <<0:10000000>>, + spawn_link(Seq), + B2 = <<0:10000000>>, + spawn_link(Seq), + B3 = <<0:10000000>>, + I ! {B1, B2, B3}, + GC(), + GC(), + GC() + end), + ?line MRef = erlang:monitor(process, NP), + NP ! go, + ?line receive + {'DOWN', MRef, process, NP, Reason} -> + ?line spawn(Node, fun () -> halt(17) end), + ?line normal = Reason + end, + ?line Res = get_emem_result(Port), + ?line {ok, Hostname} = inet:gethostname(), + ?line ShortHostname = short_hostname(Hostname), + ?line {true, _} = has_prefix(Nodename, Res#emem_res.nodename), + ?line ShortHostname = short_hostname(Res#emem_res.hostname), + ?line Bits = case erlang:system_info(wordsize) of + 4 -> ?line "32 bits"; + 8 -> ?line "64 bits" + end, + ?line Bits = Res#emem_res.word_size, + ?line "17" = Res#emem_res.exit_code, + ?line emem_comment(Config). + +'sparc_sunos5.8_32b_emt2.0'(doc) -> []; +'sparc_sunos5.8_32b_emt2.0'(suite) -> []; +'sparc_sunos5.8_32b_emt2.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "test_server" = Res#emem_res.nodename, + ?line "gorbag" = Res#emem_res.hostname, + ?line "17074" = Res#emem_res.pid, + ?line "2005-01-14 17:28:37.881980" = Res#emem_res.start_time, + ?line "2.0" = Res#emem_res.trace_version, + ?line "32 bits" = Res#emem_res.word_size, + ?line ["15", + "2665739", "8992", "548986", "16131", "539994", + "4334192", "1", "99", "15", "98", + "0", "0", "49", "0", "49"] = Res#emem_res.last_values, + ?line ["5972061", "9662", + "7987824", "5", + "2375680", "3"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config). + +'pc_win2000_32b_emt2.0'(doc) -> []; +'pc_win2000_32b_emt2.0'(suite) -> []; +'pc_win2000_32b_emt2.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "test_server" = Res#emem_res.nodename, + ?line "E-788FCF5191B54" = Res#emem_res.hostname, + ?line "504" = Res#emem_res.pid, + ?line "2005-01-24 17:27:28.224000" = Res#emem_res.start_time, + ?line "2.0" = Res#emem_res.trace_version, + ?line "32 bits" = Res#emem_res.word_size, + ?line ["11", + "2932575", "8615", "641087", "68924", "632472"] + = Res#emem_res.last_values, + ?line ["5434206", "9285"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config). + +'pc.smp_linux2.2.19pre17_32b_emt2.0'(doc) -> []; +'pc.smp_linux2.2.19pre17_32b_emt2.0'(suite) -> []; +'pc.smp_linux2.2.19pre17_32b_emt2.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "test_server" = Res#emem_res.nodename, + ?line "four-roses" = Res#emem_res.hostname, + ?line "20689" = Res#emem_res.pid, + ?line "2005-01-20 13:11:26.143077" = Res#emem_res.start_time, + ?line "2.0" = Res#emem_res.trace_version, + ?line "32 bits" = Res#emem_res.word_size, + ?line ["49", + "2901817", "9011", "521610", "10875", "512599", + "5392096", "2", "120", "10", "118", + "0", "0", "59", "0", "59"] = Res#emem_res.last_values, + ?line ["6182918", "9681", + "9062112", "6", + "2322432", "3"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config). + + +'powerpc_darwin7.7.0_32b_emt2.0'(doc) -> []; +'powerpc_darwin7.7.0_32b_emt2.0'(suite) -> []; +'powerpc_darwin7.7.0_32b_emt2.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "test_server" = Res#emem_res.nodename, + ?line "grima" = Res#emem_res.hostname, + ?line "13021" = Res#emem_res.pid, + ?line "2005-01-20 15:08:17.568668" = Res#emem_res.start_time, + ?line "2.0" = Res#emem_res.trace_version, + ?line "32 bits" = Res#emem_res.word_size, + ?line ["9", + "2784323", "8641", "531105", "15893", "522464"] + = Res#emem_res.last_values, + ?line ["6150376", "9311"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config). + +'alpha_osf1v5.1_64b_emt2.0'(doc) -> []; +'alpha_osf1v5.1_64b_emt2.0'(suite) -> []; +'alpha_osf1v5.1_64b_emt2.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "test_server" = Res#emem_res.nodename, + ?line "thorin" = Res#emem_res.hostname, + ?line "224630" = Res#emem_res.pid, + ?line "2005-01-20 22:38:01.299632" = Res#emem_res.start_time, + ?line "2.0" = Res#emem_res.trace_version, + ?line "64 bits" = Res#emem_res.word_size, + ?line case Res#emem_res.max_word_size of + "32 bits" -> + ?line emem_comment(Config, ?EMEM_64_32_COMMENT); + "64 bits" -> + ?line ["22", + "6591992", "8625", "516785", "14805", "508160", + "11429184", "5", "127", "254", "122", + "0", "0", "61", "0", "61"] = Res#emem_res.last_values, + ?line ["7041775", "9295", + "11593024", "7", + "2097152", "3"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config) + end. + +'sparc_sunos5.8_64b_emt2.0'(doc) -> []; +'sparc_sunos5.8_64b_emt2.0'(suite) -> []; +'sparc_sunos5.8_64b_emt2.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "test_server" = Res#emem_res.nodename, + ?line "gorbag" = Res#emem_res.hostname, + ?line "10907" = Res#emem_res.pid, + ?line "2005-01-20 13:48:34.677068" = Res#emem_res.start_time, + ?line "2.0" = Res#emem_res.trace_version, + ?line "64 bits" = Res#emem_res.word_size, + ?line case Res#emem_res.max_word_size of + "32 bits" -> + ?line emem_comment(Config, ?EMEM_64_32_COMMENT); + "64 bits" -> + ?line ["16", + "5032887", "8657", "530635", "14316", "521978", + "8627140", "5", "139", "19", "134", + "0", "0", "67", "0", "67"] = Res#emem_res.last_values, + ?line ["11695070", "9324", + "16360388", "10", + "4136960", "3"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config) + end. + +'sparc_sunos5.8_32b_emt1.0'(doc) -> []; +'sparc_sunos5.8_32b_emt1.0'(suite) -> []; +'sparc_sunos5.8_32b_emt1.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "" = Res#emem_res.nodename, + ?line "" = Res#emem_res.hostname, + ?line "" = Res#emem_res.pid, + ?line "" = Res#emem_res.start_time, + ?line "1.0" = Res#emem_res.trace_version, + ?line "32 bits" = Res#emem_res.word_size, + ?line ["11", + "2558261", "8643", "560610", "15325", "551967"] + = Res#emem_res.last_values, + ?line ["2791121", "9317"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config). + +'pc_win2000_32b_emt1.0'(doc) -> []; +'pc_win2000_32b_emt1.0'(suite) -> []; +'pc_win2000_32b_emt1.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "" = Res#emem_res.nodename, + ?line "" = Res#emem_res.hostname, + ?line "" = Res#emem_res.pid, + ?line "" = Res#emem_res.start_time, + ?line "1.0" = Res#emem_res.trace_version, + ?line "32 bits" = Res#emem_res.word_size, + ?line ["6", + "2965248", "8614", "640897", "68903", "632283"] + = Res#emem_res.last_values, + ?line ["3147090", "9283"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config). + + +'powerpc_darwin7.7.0_32b_emt1.0'(doc) -> []; +'powerpc_darwin7.7.0_32b_emt1.0'(suite) -> []; +'powerpc_darwin7.7.0_32b_emt1.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "" = Res#emem_res.nodename, + ?line "" = Res#emem_res.hostname, + ?line "" = Res#emem_res.pid, + ?line "" = Res#emem_res.start_time, + ?line "1.0" = Res#emem_res.trace_version, + ?line "32 bits" = Res#emem_res.word_size, + ?line ["8", + "2852991", "8608", "529662", "15875", "521054"] + = Res#emem_res.last_values, + ?line ["3173335", "9278"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config). + +'alpha_osf1v5.1_64b_emt1.0'(doc) -> []; +'alpha_osf1v5.1_64b_emt1.0'(suite) -> []; +'alpha_osf1v5.1_64b_emt1.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "" = Res#emem_res.nodename, + ?line "" = Res#emem_res.hostname, + ?line "" = Res#emem_res.pid, + ?line "" = Res#emem_res.start_time, + ?line "1.0" = Res#emem_res.trace_version, + ?line "64 bits" = Res#emem_res.word_size, + ?line case Res#emem_res.max_word_size of + "32 bits" -> + ?line emem_comment(Config, ?EMEM_64_32_COMMENT); + "64 bits" -> + ?line ["22", + "6820094", "8612", "515518", "14812", "506906"] + = Res#emem_res.last_values, + ?line ["7292413", "9282"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config) + end. + +'sparc_sunos5.8_64b_emt1.0'(doc) -> []; +'sparc_sunos5.8_64b_emt1.0'(suite) -> []; +'sparc_sunos5.8_64b_emt1.0'(Config) when is_list(Config) -> + ?line Res = run_emem_on_casefile(Config), + ?line "" = Res#emem_res.nodename, + ?line "" = Res#emem_res.hostname, + ?line "" = Res#emem_res.pid, + ?line "" = Res#emem_res.start_time, + ?line "1.0" = Res#emem_res.trace_version, + ?line "64 bits" = Res#emem_res.word_size, + ?line case Res#emem_res.max_word_size of + "32 bits" -> + ?line emem_comment(Config, ?EMEM_64_32_COMMENT); + "64 bits" -> + ?line ["15", + "4965746", "8234", "543940", "14443", "535706"] + = Res#emem_res.last_values, + ?line ["11697645", "8908"] = Res#emem_res.maximum, + ?line "0" = Res#emem_res.exit_code, + ?line emem_comment(Config) + end. + +%% +%% +%% Auxiliary functions +%% +%% + +receive_and_save_trace(PortNumber, FileName) when is_integer(PortNumber), + is_list(FileName) -> + {ok, F} = file:open(FileName, [write, compressed]), + {ok, LS} = gen_tcp:listen(PortNumber, [inet, {reuseaddr,true}, binary]), + {ok, S} = gen_tcp:accept(LS), + gen_tcp:close(LS), + receive_loop(S,F). + +receive_loop(Socket, File) -> + receive + {tcp, Socket, Data} -> + ok = file:write(File, Data), + receive_loop(Socket, File); + {tcp_closed, Socket} -> + file:close(File), + ok; + {tcp_error, Socket, Reason} -> + file:close(File), + {error, Reason} + end. + +send_trace({Host, PortNumber}, FileName) when is_list(Host), + is_integer(PortNumber), + is_list(FileName) -> + ?line {ok, F} = file:open(FileName, [read, compressed]), + ?line {ok, S} = gen_tcp:connect(Host, PortNumber, [inet,{packet, 0}]), + ?line send_loop(S, F); +send_trace(EmuFlag, FileName) when is_list(EmuFlag), + is_list(FileName) -> + ?line ["+Mit", IpAddrStr, PortNoStr] = string:tokens(EmuFlag, " :"), + ?line send_trace({IpAddrStr, list_to_integer(PortNoStr)}, FileName). + +send_loop(Socket, File) -> + ?line case file:read(File, 128) of + {ok, Data} -> + ?line case gen_tcp:send(Socket, Data) of + ok -> ?line send_loop(Socket, File); + Error -> + ?line gen_tcp:close(Socket), + ?line file:close(File), + Error + end; + eof -> + ?line gen_tcp:close(Socket), + ?line file:close(File), + ?line ok; + Error -> + ?line gen_tcp:close(Socket), + ?line file:close(File), + ?line Error + end. + +check_emem(Dir, Type) when is_atom(Type) -> + ExeSuffix = case ?t:os_type() of + {win32, _} -> ".exe"; + _ -> "" + end, + TypeSuffix = case Type of + opt -> ""; + _ -> "." ++ atom_to_list(Type) + end, + Emem = "emem" ++ TypeSuffix ++ ExeSuffix, + case check_file(filename:join([Dir, Emem])) of + not_found -> ok; + File -> + Comment = case Type of + opt -> ""; + _ -> "[emem " ++ atom_to_list(Type) ++ " compiled]" + end, + throw([{emem, File}, {emem_comment, Comment}]) + end. + +check_dir(DirName) -> + case file:read_file_info(DirName) of + {ok, #file_info {type = directory, access = A}} when A == read; + A == read_write -> + DirName; + _ -> + not_found + end. + +check_file(FileName) -> + case file:read_file_info(FileName) of + {ok, #file_info {type = regular, access = A}} when A == read; + A == read_write -> + ?line FileName; + _ -> + ?line not_found + end. + +emem_comment(Config) when is_list(Config) -> + emem_comment(Config, ""). + +emem_comment(Config, ExtraComment) + when is_list(Config), is_list(ExtraComment) -> + case {?config(emem_comment, Config), ExtraComment} of + {"", ""} -> ?line ok; + {"", XC} -> ?line {comment, XC}; + {EmemC, ""} -> ?line {comment, EmemC}; + {EmemC, XC} -> ?line {comment, EmemC ++ " " ++ XC} + end. + +run_emem_on_casefile(Config) -> + CaseName = atom_to_list(?config(testcase, Config)), + ?line File = filename:join([?config(data_dir, Config), CaseName ++ ".gz"]), + ?line case check_file(File) of + not_found -> + ?line ?t:fail({error, {filenotfound, File}}); + _ -> + ?line ok + end, + ?line {ok, EmuFlag, Port} = start_emem(Config), + ?line Parent = self(), + ?line Ref = make_ref(), + ?line spawn_link(fun () -> + SRes = send_trace(EmuFlag, File), + Parent ! {Ref, SRes} + end), + ?line Res = get_emem_result(Port), + ?line receive + {Ref, ok} -> + ?line ok; + {Ref, SendError} -> + ?line ?t:format("Send result: ~p~n", [SendError]) + end, + ?line Res. + +get_emem_result(Port) -> + ?line {Res, LV} = get_emem_result(Port, {#emem_res{}, []}), + ?line Res#emem_res{last_values = string:tokens(LV, " ")}. + +get_emem_result(Port, {_EmemRes, _LastValues} = Res) -> + ?line case get_emem_line(Port) of + eof -> + ?line Res; + Line -> + ?line get_emem_result(Port, parse_emem_line(Line, Res)) + end. + +parse_emem_main_header_footer_line(Line, {ER, LV} = Res) -> + + %% Header + ?line case has_prefix("> Nodename:", Line) of + {true, NN} -> + ?line throw({ER#emem_res{nodename = strip(NN)}, LV}); + false -> ?line ok + end, + ?line case has_prefix("> Hostname:", Line) of + {true, HN} -> + ?line throw({ER#emem_res{hostname = strip(HN)}, LV}); + false -> ?line ok + end, + ?line case has_prefix("> Pid:", Line) of + {true, P} -> + ?line throw({ER#emem_res{pid = strip(P)}, LV}); + false -> ?line ok + end, + ?line case has_prefix("> Start time (UTC):", Line) of + {true, ST} -> + ?line throw({ER#emem_res{start_time = strip(ST)}, LV}); + false -> ?line ok + end, + ?line case has_prefix("> Actual trace version:", Line) of + {true, TV} -> + ?line throw({ER#emem_res{trace_version = strip(TV)}, LV}); + false -> ?line ok + end, + ?line case has_prefix("> Maximum trace word size:", Line) of + {true, MWS} -> + ?line throw({ER#emem_res{max_word_size = strip(MWS)}, LV}); + false -> ?line ok + end, + ?line case has_prefix("> Actual trace word size:", Line) of + {true, WS} -> + ?line throw({ER#emem_res{word_size = strip(WS)}, LV}); + false -> ?line ok + end, + + %% Footer + ?line case has_prefix("> Maximum:", Line) of + {true, M} -> + ?line throw({ER#emem_res{maximum = string:tokens(M," ")}, LV}); + false -> ?line ok + end, + ?line case has_prefix("> Emulator exited with code:", Line) of + {true, EC} -> + ?line throw({ER#emem_res{exit_code = strip(EC)}, LV}); + false -> ?line ok + end, + ?line Res. + +parse_emem_header_line(_Line, {_ER, _LV} = Res) -> + ?line Res. + +parse_emem_value_line(Line, {EmemRes, _OldLastValues}) -> + ?line {EmemRes, Line}. + +parse_emem_line("", Res) -> + ?line Res; +parse_emem_line(Line, Res) -> + ?line [Prefix | _] = Line, + case Prefix of + $> -> ?line catch parse_emem_main_header_footer_line(Line, Res); + $| -> ?line catch parse_emem_header_line(Line, Res); + _ -> ?line catch parse_emem_value_line(Line, Res) + end. + +start_emem(Config) when is_list(Config) -> + ?line Emem = ?config(emem, Config), + ?line Cd = case ignore_cores:dir(Config) of + false -> []; + Dir -> [{cd, Dir}] + end, + ?line case open_port({spawn, Emem ++ " -t -n -o -i 1"}, + Cd ++ [{line, 1024}, eof]) of + Port when is_port(Port) -> ?line {ok, read_emu_flag(Port), Port}; + Error -> ?line ?t:fail(Error) + end. + +read_emu_flag(Port) -> + ?line Line = case get_emem_line(Port) of + eof -> ?line ?t:fail(unexpected_end_of_file); + L -> ?line L + end, + ?line case has_prefix("> Emulator command line argument:", Line) of + {true, EmuFlag} -> EmuFlag; + false -> ?line read_emu_flag(Port) + end. + +get_emem_line(Port, Acc) -> + ?line receive + {Port, {data, {eol, Data}}} -> + ?line Res = case Acc of + [] -> ?line Data; + _ -> ?line lists:flatten([Acc|Data]) + end, + ?line ?t:format("~s", [Res]), + ?line Res; + {Port, {data, {noeol, Data}}} -> + ?line get_emem_line(Port, [Acc|Data]); + {Port, eof} -> + ?line port_close(Port), + ?line eof + end. + +get_emem_line(Port) -> + ?line get_emem_line(Port, []). + +short_hostname([]) -> + []; +short_hostname([$.|_]) -> + []; +short_hostname([C|Cs]) -> + [C | short_hostname(Cs)]. + +has_prefix([], List) when is_list(List) -> + {true, List}; +has_prefix([P|Xs], [P|Ys]) -> + has_prefix(Xs, Ys); +has_prefix(_, _) -> + false. + +strip(Str) -> string:strip(Str). + +mk_nodename(Config) -> + {A, B, C} = now(), + atom_to_list(?MODULE) + ++ "-" ++ atom_to_list(?config(testcase, Config)) + ++ "-" ++ integer_to_list(A*1000000000000 + B*1000000 + C). + +start_node(Name, Args) -> + ?line Pa = filename:dirname(code:which(?MODULE)), + ?line ?t:start_node(Name, peer, [{args, Args ++ " -pa " ++ Pa}]). + +% stop_node(Node) -> +% ?t:stop_node(Node). + +is_debug_compiled() -> + is_debug_compiled(erlang:system_info(system_version)). + +is_debug_compiled([$d,$e,$b,$u,$g | _]) -> + true; +is_debug_compiled([ _, _, _, _]) -> + false; +is_debug_compiled([]) -> + false; +is_debug_compiled([_|Rest]) -> + is_debug_compiled(Rest). diff --git a/lib/tools/test/eprof_SUITE.erl b/lib/tools/test/eprof_SUITE.erl new file mode 100644 index 0000000000..028fea8fe1 --- /dev/null +++ b/lib/tools/test/eprof_SUITE.erl @@ -0,0 +1,97 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(eprof_SUITE). + +-include("test_server.hrl"). + +-export([all/1,tiny/1,eed/1]). + +all(suite) -> [tiny,eed]. + + +tiny(suite) -> []; +tiny(Config) when is_list(Config) -> + ?line ensure_eprof_stopped(), + ?line {ok, OldCurDir} = file:get_cwd(), + Datadir = ?config(data_dir, Config), + Privdir = ?config(priv_dir, Config), + ?line TTrap=?t:timetrap(60*1000), + % (Trace)Compile to priv_dir and make sure the correct version is loaded. + ?line {ok,eprof_suite_test} = compile:file(filename:join(Datadir, + "eprof_suite_test"), + [trace,{outdir, Privdir}]), + ?line ok = file:set_cwd(Privdir), + ?line code:purge(eprof_suite_test), + ?line {module,eprof_suite_test} = code:load_file(eprof_suite_test), + ?line {ok,_Pid} = eprof:start(), + ?line nothing_to_analyse = eprof:analyse(), + ?line nothing_to_analyse = eprof:total_analyse(), + ?line eprof:profile([], eprof_suite_test, test, [Config]), + ?line ok = eprof:analyse(), + ?line ok = eprof:total_analyse(), + ?line ok = eprof:log("eprof_SUITE_logfile"), + ?line stopped = eprof:stop(), + ?line ?t:timetrap_cancel(TTrap), + ?line ok = file:set_cwd(OldCurDir), + ok. + +eed(suite) -> []; +eed(Config) when is_list(Config) -> + ?line ensure_eprof_stopped(), + ?line Datadir = ?config(data_dir, Config), + ?line Privdir = ?config(priv_dir, Config), + ?line TTrap=?t:timetrap(5*60*1000), + + %% (Trace)Compile to priv_dir and make sure the correct version is loaded. + ?line code:purge(eed), + ?line {ok,eed} = c:c(filename:join(Datadir, "eed"), [trace,{outdir,Privdir}]), + ?line {ok,_Pid} = eprof:start(), + ?line Script = filename:join(Datadir, "ed.script"), + ?line ok = file:set_cwd(Datadir), + ?line {T1,_} = statistics(runtime), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line ok = eed:file(Script), + ?line {T2,_} = statistics(runtime), + ?line {ok,ok} = eprof:profile([], eed, file, [Script]), + ?line {T3,_} = statistics(runtime), + ?line profiling_already_stopped = eprof:stop_profiling(), + ?line ok = eprof:analyse(), + ?line ok = eprof:total_analyse(), + ?line ok = eprof:log("eprof_SUITE_logfile"), + ?line stopped = eprof:stop(), + ?line ?t:timetrap_cancel(TTrap), + S = lists:flatten(io_lib:format("~p times slower", [10*(T3-T2)/(T2-T1)])), + {comment,S}. + +ensure_eprof_stopped() -> + Pid = whereis(eprof), + case whereis(eprof) of + undefined -> + ok; + Pid -> + ?line stopped=eprof:stop() + end. diff --git a/lib/tools/test/eprof_SUITE_data/ed.script b/lib/tools/test/eprof_SUITE_data/ed.script new file mode 100644 index 0000000000..94531a9e98 --- /dev/null +++ b/lib/tools/test/eprof_SUITE_data/ed.script @@ -0,0 +1,8 @@ +H +r eed.erl +g/^[a-z][a-zA-Z_]*\(/i\ +%%% -------------------------------------------------------------\ +%%% A stupid function header.\ +%%% ------------------------------------------------------------- +1,$p +q diff --git a/lib/tools/test/eprof_SUITE_data/eed.erl b/lib/tools/test/eprof_SUITE_data/eed.erl new file mode 100644 index 0000000000..0175abdd0e --- /dev/null +++ b/lib/tools/test/eprof_SUITE_data/eed.erl @@ -0,0 +1,815 @@ +%%%---------------------------------------------------------------------- +%%% File : eed.erl +%%% Author : Bjorn Gustavsson <bjorn@strider> +%%% Purpose : Unix `ed' look-alike. +%%% Created : 24 Aug 1997 by Bjorn Gustavsson <bjorn@strider> +%%%---------------------------------------------------------------------- + +-module(eed). +-author('bjorn@strider'). + +-export([edit/0, edit/1, file/1, cmd_line/1]). + +-record(state, {dot = 0, % Line number of dot. + upto_dot = [], % Lines up to dot (reversed). + after_dot = [], % Lines after dot. + lines = 0, % Total number of lines. + print=false, % Print after command. + filename=[], % Current file. + pattern, % Current pattern. + in_global=false, % True if executing global command. + input=[], % Global input stream. + undo, % Last undo state. + marks=[], % List of marks. + modified=false, % Buffer is modified. + opts=[{prompt, ''}], % Options. + last_error, % The last error encountered. + input_fd % Input file descriptor. + }). + +-record(line, {contents, % Contents of line. + mark=false % Marked (for global prefix). + }). + +cmd_line([Script]) -> + file(Script), + halt(). + +file(Script) -> + case file:open(Script, [read]) of + {ok,Fd} -> + loop(#state{input_fd=Fd}), + ok; + {error,E} -> + {error,E} + end. + +edit() -> + loop(#state{input_fd=group_leader()}). + +edit(Name) -> + loop(command([$e|Name], #state{input_fd=group_leader()})). + +loop(St0) -> + {ok, St1, Cmd} = get_line(St0), + case catch command(lib:nonl(Cmd), St1) of + {'EXIT', Reason} -> + %% XXX Should clear outstanding global command here. + loop(print_error({'EXIT', Reason}, St1)); + quit -> + ok; + {error, Reason} -> + loop(print_error(Reason, St1)); + St2 when record(St2, state) -> + loop(St2) + end. + +command(Cmd, St) -> + case parse_command(Cmd, St) of + quit -> + quit; + St1 when function(St1#state.print) -> + if + St1#state.dot /= 0 -> + print_current(St1); + true -> + ok + end, + St1#state{print=false}; + St1 when record(St1, state) -> + St1 + end. + +get_line(St) -> + Opts = St#state.opts, + {value, {prompt, Prompt}} = lists:keysearch(prompt, 1, Opts), + get_line(Prompt, St). + +get_line(Prompt, St) when St#state.input == [] -> + Line = get_line1(St#state.input_fd, Prompt, []), + {ok, St, Line}; +get_line(_, St) -> + get_input(St#state.input, St, []). + +get_input([eof], St, []) -> + {ok, St, eof}; +get_input([eof], St, Result) -> + {ok, St#state{input=[eof]}, lists:reverse(Result)}; +get_input([$\n|Rest], St, Result) -> + {ok, St#state{input=Rest}, lists:reverse(Result)}; +get_input([C|Rest], St, Result) -> + get_input(Rest, St, [C|Result]). + +get_line1(Io, Prompt, Result) -> + get_line2(Io, io:get_line(Io, Prompt), Result). + +get_line2(Io, eof, []) -> + eof; +get_line2(Io, eof, Result) -> + lists:reverse(Result); +get_line2(Io, [$\\, $\n], Result) -> + get_line1(Io, '', [$\n|Result]); +get_line2(Io, [$\n], Result) -> + lists:reverse(Result, [$\n]); +get_line2(Io, [C|Rest], Result) -> + get_line2(Io, Rest, [C|Result]). + +print_error(Reason, St0) -> + St1 = St0#state{last_error=Reason}, + io:put_chars("?\n"), + case lists:member(help_always, St1#state.opts) of + true -> + help_command([], [], St1), + St1; + false -> + St1 + end. + +format_error(bad_command) -> "unknown command"; +format_error(bad_filename) -> "illegal or missing filename"; +format_error(bad_file) -> "cannot open input file"; +format_error(bad_linenum) -> "line out of range"; +format_error(bad_delimiter) -> "illegal or missing delimiter"; +format_error(bad_undo) -> "nothing to undo"; +format_error(bad_mark) -> "mark not lower case ascii"; +format_error(bad_pattern) -> "invalid regular expression"; +format_error(buffer_modified) -> "warning: expecting `w'"; +format_error(nested_globals) -> "multiple globals not allowed"; +format_error(nomatch) -> "search string not found"; +format_error(missing_space) -> "no space after command"; +format_error(garbage_after_command) -> "illegal suffix"; +format_error(not_implemented) -> "not implemented yet"; +format_error({'EXIT', {Code, {Mod, Func, Args}}}) -> + lists:flatten(io_lib:format("aborted due to bug (~p)", + [{Code, {Mod, Func, length(Args)}}])); +format_error(A) -> atom_to_list(A). + + + +%%% Parsing commands. + +parse_command(Cmd, St) -> + parse_command(Cmd, St, []). + +parse_command(Cmd, State, Nums) -> + case get_one(Cmd, State) of + {ok, Num, Rest, NewState} -> + parse_next_address(Rest, NewState, [Num|Nums]); + false -> + parse_command1(Cmd, State, Nums) + end. + +parse_next_address([$,|Rest], State, Nums) -> + parse_command(Rest, State, Nums); +parse_next_address([$;|Rest], State, [Num|Nums]) -> + parse_command(Rest, move_to(Num, State), [Num|Nums]); +parse_next_address(Rest, State, Nums) -> + parse_command1(Rest, State, Nums). + +parse_command1([Letter|Rest], State, Nums) -> + Cont = fun(Fun, NumLines, Def) -> + execute_command(Fun, NumLines, Def, State, Nums, Rest) end, + parse_cmd_char(Letter, Cont); +parse_command1([], State, Nums) -> + execute_command(fun print_command/3, 1, next, State, Nums, []). + +get_one(Cmd, St) -> + case get_address(Cmd, St) of + {ok, Addr, Cmd1, St1} -> + get_one1(Cmd1, Addr, St1); + false -> + get_one1(Cmd, false, St) + end. + +get_one1([D|Rest], false, St) when $0 =< D, D =< $9 -> + get_one2(get_number([D|Rest]), 1, 0, St); +get_one1([D|Rest], Sum, St) when $0 =< D, D =< $9 -> + get_one2(get_number([D|Rest]), 1, Sum, St); +get_one1([$+, D|Rest], Sum, St) when $0 =< D, D =< $9 -> + get_one2(get_number([D|Rest]), 1, Sum, St); +get_one1([$-, D|Rest], Sum, St) when $0 =< D, D =< $9 -> + get_one2(get_number([D|Rest]), -1, Sum, St); +get_one1([$+|Rest], Sum, St) -> + get_one2({ok, 1, Rest}, 1, Sum, St); +get_one1([$-|Rest], Sum, St) -> + get_one2({ok, 1, Rest}, -1, Sum, St); +get_one1(Cmd, false, St) -> + false; +get_one1(Cmd, Sum, St) -> + {ok, Sum, Cmd, St}. + +get_one2({ok, Number, Rest}, Mul, false, St) -> + get_one1(Rest, St#state.dot+Mul*Number, St); +get_one2({ok, Number, Rest}, Mul, Sum, St) -> + get_one1(Rest, Sum+Mul*Number, St). + +get_number(Cmd) -> + get_number(Cmd, 0). + +get_number([D|Rest], Result) when $0 =< D, D =< $9 -> + get_number(Rest, Result*10+D-$0); +get_number(Rest, Result) -> + {ok, Result, Rest}. + +get_address([$.|Rest], State) -> + {ok, State#state.dot, Rest, State}; +get_address([$$|Rest], State) -> + {ok, State#state.lines, Rest, State}; +get_address([$', Mark|Rest], St) when $a =< Mark, Mark =< $z -> + case lists:keysearch(Mark, 2, St#state.marks) of + {value, {Line, Mark}} -> + {ok, Line, Rest, St}; + false -> + {ok, 0, Rest, St} + end; +get_address([$'|Rest], State) -> + error(bad_mark); +get_address([$/|Rest], State) -> + scan_forward($/, Rest, State); +get_address([$?|Rest], State) -> + error(not_implemented); +get_address(Cmd, St) -> + false. + +scan_forward(End, Patt0, State) -> + {ok, Rest, NewState} = get_pattern(End, Patt0, State), + Dot = NewState#state.dot, + After = NewState#state.after_dot, + scan_forward1(Dot+1, After, NewState, Rest). + +scan_forward1(Linenum, [Line|Rest], State, RestCmd) -> + case regexp:first_match(Line#line.contents, State#state.pattern) of + {match, _, _} -> + {ok, Linenum, RestCmd, State}; + nomatch -> + scan_forward1(Linenum+1, Rest, State, RestCmd) + end; +scan_forward1(_, [], State, RestCmd) -> + Dot = State#state.dot, + Upto = State#state.upto_dot, + case scan_forward2(Dot, Upto, State, RestCmd) of + false -> + error(bad_linenum); + Other -> + Other + end. + +scan_forward2(0, [], State, RestCmd) -> + false; +scan_forward2(Linenum, [Line|Rest], State, RestCmd) -> + case scan_forward2(Linenum-1, Rest, State, RestCmd) of + false -> + case regexp:first_match(Line#line.contents, State#state.pattern) of + {match, _, _} -> + {ok, Linenum, RestCmd, State}; + nomatch -> + false + end; + Other -> + Other + end. + +parse_cmd_char($S, Cont) -> Cont(fun quest_command/3, 0, none); +parse_cmd_char($T, Cont) -> Cont(fun time_command/3, 0, none); +parse_cmd_char($=, Cont) -> Cont(fun print_linenum/3, 1, last); +parse_cmd_char($a, Cont) -> Cont(fun append_command/3, 1, dot); +parse_cmd_char($c, Cont) -> Cont(fun change_command/3, 2, dot); +parse_cmd_char($d, Cont) -> Cont(fun delete_command/3, 2, dot); +parse_cmd_char($e, Cont) -> Cont(fun enter_command/3, 0, none); +parse_cmd_char($E, Cont) -> Cont(fun enter_always_command/3, 0, none); +parse_cmd_char($f, Cont) -> Cont(fun file_command/3, 0, none); +parse_cmd_char($g, Cont) -> Cont(fun global_command/3, 2, all); +parse_cmd_char($h, Cont) -> Cont(fun help_command/3, 0, none); +parse_cmd_char($H, Cont) -> Cont(fun help_always_command/3, 0, none); +parse_cmd_char($i, Cont) -> Cont(fun insert_command/3, 1, dot); +parse_cmd_char($k, Cont) -> Cont(fun mark_command/3, 1, dot); +parse_cmd_char($l, Cont) -> Cont(fun list_command/3, 2, dot); +parse_cmd_char($m, Cont) -> Cont(fun move_command/3, 2, dot); +parse_cmd_char($n, Cont) -> Cont(fun number_command/3, 2, dot); +parse_cmd_char($p, Cont) -> Cont(fun print_command/3, 2, dot); +parse_cmd_char($P, Cont) -> Cont(fun prompt_command/3, 0, none); +parse_cmd_char($q, Cont) -> Cont(fun quit_command/3, 0, none); +parse_cmd_char($Q, Cont) -> Cont(fun quit_always_command/3, 0, none); +parse_cmd_char($r, Cont) -> Cont(fun read_command/3, 1, last); +parse_cmd_char($s, Cont) -> Cont(fun subst_command/3, 2, dot); +parse_cmd_char($t, Cont) -> Cont(fun transpose_command/3, 2, dot); +parse_cmd_char($u, Cont) -> Cont(fun undo_command/3, 0, none); +parse_cmd_char($v, Cont) -> Cont(fun vglobal_command/3, 2, all); +parse_cmd_char($w, Cont) -> Cont(fun write_command/3, 2, all); +parse_cmd_char(_, Cont) -> error(bad_command). + +execute_command(Fun, NumLines, Def, State, Nums, Rest) -> + Lines = check_lines(NumLines, Def, Nums, State), + Fun(Rest, Lines, State). + +check_lines(0, _, [], _State) -> + []; +check_lines(1, dot, [], #state{dot=Dot}) -> + [Dot]; +check_lines(1, next, [], State) when State#state.dot < State#state.lines -> + [State#state.dot+1]; +check_lines(1, last, [], State) -> + [State#state.lines]; +check_lines(1, _, [Num|_], State) when 0 =< Num, Num =< State#state.lines -> + [Num]; +check_lines(2, dot, [], #state{dot=Dot}) -> + [Dot, Dot]; +check_lines(2, all, [], #state{lines=Lines}) -> + [1, Lines]; +check_lines(2, _, [Num], State) when 0 =< Num, Num =< State#state.lines -> + [Num, Num]; +check_lines(2, _, [Num2, Num1|_], State) +when 0 =< Num1, Num1 =< Num2, Num2 =< State#state.lines -> + [Num1, Num2]; +check_lines(_, _, _, _) -> + error(bad_linenum). + + +%%% Executing commands. + +%% ($)= - print line number + +print_linenum(Rest, [Line], State) -> + NewState = check_trailing_p(Rest, State), + io:format("~w\n", [Line]), + NewState. + +%% ? - print state (for debugging) + +quest_command([], [], State) -> + io:format("~p\n", [State]), + State. + +%% Tcmd - time command + +time_command(Cmd, [], St) -> + Fun = fun parse_command/2, + erlang:garbage_collect(), + {Elapsed, Val} = timer:tc(erlang, apply, [Fun, [Cmd, St]]), + io:format("Time used: ~p s~n", [Elapsed/1000000.0]), + case Val of + {error, Reason} -> + throw({error, Reason}); + Other -> + Other + end. + +%% (.)a - append text + +append_command(Rest, [Line], St0) -> + St1 = save_for_undo(St0), + append(move_to(Line, check_trailing_p(Rest, St1))). + +append(St0) -> + {ok, St1, Line0} = get_line('', St0), + case Line0 of + eof -> + St1; + ".\n" -> + St1; + Line -> + append(insert_line(Line, St1)) + end. + +%% (.,.)c + +change_command(Rest, Lines, St0) -> + St1 = delete_command(Rest, Lines, St0), + St2 = append_command([], [St1#state.dot-1], St1), + save_for_undo(St2, St0). + +%% (.,.)d - delete lines + +delete_command(Rest, [0, Last], St) -> + error(bad_linenum); +delete_command(Rest, [First, Last], St0) -> + St1 = check_trailing_p(Rest, save_for_undo(St0)), + delete(Last-First+1, move_to(Last, St1)). + +delete(0, St) when St#state.dot == St#state.lines -> + St; +delete(0, St) -> + next_line(St); +delete(Left, St0) -> + St1 = delete_current_line(St0), + delete(Left-1, St1). + +%% e file - replace buffer with new file + +enter_command(Name, [], St) when St#state.modified == true -> + error(buffer_modified); +enter_command(Name, [], St0) -> + enter_always_command(Name, [], St0). + +%% E file - replace buffer with new file + +enter_always_command(Name, [], St0) -> + St1 = read_command(Name, [0], #state{filename=St0#state.filename, + opts=St0#state.opts}), + St1#state{modified=false}. + +%% f file - print filename; set filename + +file_command([], [], St) -> + io:format("~s~n", [St#state.filename]), + St; +file_command([$_|Name0], [], St) -> + Name = skip_blanks(Name0), + file_command([], [], St#state{filename=Name}); +file_command(_, _, _) -> + error(missing_space). + +%% (1,$)g/RE/commands - execute commands on all matching lines. +%% (1,$)v/RE/commands - execute commands on all non-matching lines. + +global_command(Cmd, Lines, St) -> + check_global0(true, Cmd, Lines, St). + +vglobal_command(Cmd, Lines, St) -> + check_global0(false, Cmd, Lines, St). + +check_global0(_, _, _, St) when St#state.in_global == true -> + error(nested_globals); +check_global0(Sense, [Sep|Pattern], Lines, St0) -> + {ok, Cmd, St1} = get_pattern(Sep, Pattern, St0), + St2 = mark(Sense, Lines, St1), + do_global_command(Cmd, St2#state{in_global=true}, 0). + +mark(Sense, [First, Last], St0) -> + St1 = move_to(Last, St0), + mark1(Sense, First-1, St1). + +mark1(Sense, First, St) when St#state.dot == First -> + St; +mark1(Sense, First, St) -> + [Line|Prev] = St#state.upto_dot, + NewLine = case match(St) of + true -> Line#line{mark=Sense}; + false -> Line#line{mark=not(Sense)} + end, + mark1(Sense, First, prev_line(St#state{upto_dot=[NewLine|Prev]})). + +do_global_command(Cmd, St0, Matches) -> + case find_mark(St0) of + {ok, St1} -> + St2 = St1#state{input=Cmd++[eof]}, + {ok, St3, Cmd1} = get_line(St2), + St4 = command(Cmd1, St3), + %% XXX There might be several commands. + do_global_command(Cmd, St4, Matches+1); + false when Matches == 0 -> + error(nomatch); + false -> + St0#state{in_global=false, input=[]} + end. + +find_mark(State) -> + find_mark(State#state.lines, State). + +find_mark(0, _State) -> + false; +find_mark(Limit, State) when State#state.dot == 0 -> + find_mark(Limit, next_line(State)); +find_mark(Limit, State) -> + case State#state.upto_dot of + [Line|Prev] when Line#line.mark == true -> + NewLine = Line#line{mark=false}, + {ok, State#state{upto_dot=[NewLine|Prev]}}; + _Other -> + find_mark(Limit-1, wrap_next_line(State)) + end. + +%% h - print info about last error + +help_command([], [], St) -> + case St#state.last_error of + undefined -> + St; + Reason -> + io:put_chars(format_error(Reason)), + io:nl(), + St + end; +help_command(_, _, _) -> + error(garbage_after_command). + +%% H - toggle automatic help mode on/off + +help_always_command([], [], St) -> + Opts = St#state.opts, + case lists:member(help_always, Opts) of + true -> + St#state{opts=Opts--[help_always]}; + false -> + help_command([], [], St), + St#state{opts=[help_always|Opts]} + end. + +%% (.)i - insert text + +insert_command(Rest, [0], State) -> + error(bad_linenum); +insert_command(Rest, [Line], State) -> + append_command(Rest, [Line-1], State). + +%% (.)kx - mark line + +mark_command(_, [0], St) -> + error(bad_linenum); +mark_command([Mark|Rest], [Line], St) when $a =< Mark, Mark =< $z -> + error(not_implemented); +mark_command(_, _, _) -> + error(bad_mark). + +%% (.,.)l - list lines + +list_command(Rest, Lines, St) -> + print([$l|Rest], Lines, St). + +%% (.,.)m - move lines + +move_command(Cmd, [First, Last], St) -> + error(not_implemented). + +%% (.,.)t - copy lines + +transpose_command(Cmd, [First, Last], St) -> + error(not_implemented). + +%% (.,.)n - print lines with line numbers + +number_command(Rest, Lines, St) -> + print([$n|Rest], Lines, St). + +%% (.,.)p - print lines + +print_command(Rest, Lines, St) -> + print([$p|Rest], Lines, St). + +%% P - toggle prompt + +prompt_command([], [], St) -> + Opts = St#state.opts, + case lists:keysearch(prompt, 1, Opts) of + {value, {prompt, ''}} -> + St#state{opts=[{prompt, '*'}|Opts]}; + {value, Value} -> + St#state{opts=[{prompt, ''} | Opts--[Value]]} + end; +prompt_command(_, _, _) -> + error(garbage_after_command). + +%% q - quit editor + +quit_command([], [], _) -> + quit; +quit_command(_, _, _) -> + error(garbage_after_command). + +%% Q - quit editor + +quit_always_command([], [], _) -> + quit; +quit_always_command(_, _, _) -> + error(garbage_after_command). + +%% ($)r file - read file + +read_command([], _, St) when St#state.filename == [] -> + error(bad_filename); +read_command([], [After], St) -> + read(After, St#state.filename, St); +read_command([$ |Name0], [After], St) when St#state.filename == [] -> + Name = skip_blanks(Name0), + read(After, Name, St#state{filename=Name}); +read_command([$ |Name0], [After], St) -> + Name = skip_blanks(Name0), + read(After, Name, St); +read_command(_, _, _) -> + error(missing_space). + +read(After, Name, St0) -> + case file:read_file(Name) of + {ok, Bin} -> + Chars = size(Bin), + St1 = move_to(After, St0), + St2 = insert_line(binary_to_list(Bin), St1), + io:format("~w~n", [Chars]), + St2; + {error, _} -> + error(bad_file) + end. + +%% s/pattern/replacement/gp + +subst_command(_, [0, _], _) -> + error(bad_linenum); +subst_command([$ |Cmd0], [First, Last], St0) -> + error(bad_delimiter); +subst_command([$\n|Cmd0], [First, Last], St0) -> + error(bad_delimiter); +subst_command([Sep|Cmd0], [First, Last], St0) -> + St1 = save_for_undo(St0), + {ok, Cmd1, St2} = get_pattern(Sep, Cmd0, St1), + {ok, Replacement, Cmd2} = get_replacement(Sep, Cmd1), + {ok, Sub, Cmd3} = subst_check_gflag(Cmd2), + St3 = check_trailing_p(Cmd3, St2), + subst_command(Last-First+1, Sub, Replacement, move_to(First-1, St3), nomatch); +subst_command([], _, _) -> + error(bad_delimiter). + +subst_command(0, _, _, _, nomatch) -> + error(nomatch); +subst_command(0, _, _, _, StLast) when record(StLast, state) -> + StLast; +subst_command(Left, Sub, Repl, St0, LastMatch) -> + St1 = next_line(St0), + [Line|_] = St1#state.upto_dot, + case regexp:Sub(Line#line.contents, St1#state.pattern, Repl) of + {ok, _, 0} -> + subst_command(Left-1, Sub, Repl, St1, LastMatch); + {ok, NewContents, _} -> + %% XXX This doesn't work with marks. + St2 = delete_current_line(St1), + St3 = insert_line(NewContents, St2), + subst_command(Left-1, Sub, Repl, St3, St3) + end. + +subst_check_gflag([$g|Cmd]) -> {ok, gsub, Cmd}; +subst_check_gflag(Cmd) -> {ok, sub, Cmd}. + +%% u - undo + +undo_command([], [], St) when St#state.undo == undefined -> + error(bad_undo); +undo_command([], [], #state{undo=Undo}) -> + Undo; +undo_command(_, _, _) -> + error(garbage_after_command). + +%% (1,$)w - write buffer to file + +write_command(Cmd, [First, Last], St) -> + error(not_implemented). + + +%%% Primitive buffer operations. + +print_current(St) -> + [Line|_] = St#state.upto_dot, + Printer = St#state.print, + Printer(Line#line.contents, St). + +delete_current_line(St) when St#state.dot == 0 -> + error(bad_linenum); +delete_current_line(St) -> + Lines = St#state.lines, + [_|Prev] = St#state.upto_dot, + St#state{dot=St#state.dot-1, upto_dot=Prev, lines=Lines-1, modified=true}. + +insert_line(Line, State) -> + insert_line1(Line, State, []). + +insert_line1([$\n|Rest], State, Result) -> + NewState = insert_single_line(lists:reverse(Result, [$\n]), State), + insert_line1(Rest, NewState, []); +insert_line1([C|Rest], State, Result) -> + insert_line1(Rest, State, [C|Result]); +insert_line1([], State, []) -> + State; +insert_line1([], State, Result) -> + insert_single_line(lists:reverse(Result, [$\n]), State). + +insert_single_line(Line0, State) -> + Line = #line{contents=Line0}, + Dot = State#state.dot, + Before = State#state.upto_dot, + Lines = State#state.lines, + %% XXX Avoid updating the record every time. + State#state{dot=Dot+1, upto_dot=[Line|Before], lines=Lines+1, modified=true}. + +move_to(Line, State) when Line < State#state.dot -> + move_to(Line, prev_line(State)); +move_to(Line, State) when State#state.dot < Line -> + move_to(Line, next_line(State)); +move_to(Line, State) when Line == State#state.dot -> + State. + +prev_line(State) -> + Dot = State#state.dot, + Before = State#state.upto_dot, + After = State#state.after_dot, + State#state{dot=Dot-1, upto_dot=tl(Before), after_dot=[hd(Before)|After]}. + +next_line(State) -> + Dot = State#state.dot, + Before = State#state.upto_dot, + After = State#state.after_dot, + State#state{dot=Dot+1, upto_dot=[hd(After)|Before], after_dot=tl(After)}. + +wrap_next_line(State) when State#state.dot == State#state.lines -> + move_to(1, State); +wrap_next_line(State) -> + next_line(State). + + +%%% Utilities. + +get_pattern(End, Cmd, State) -> + get_pattern(End, Cmd, State, []). + +get_pattern(End, [End|Rest], State, []) when State#state.pattern /= undefined -> + {ok, Rest, State}; +get_pattern(End, [End|Rest], State, Result) -> + case regexp:parse(lists:reverse(Result)) of + {error, _} -> + error(bad_pattern); + {ok, Re} -> + {ok, Rest, State#state{pattern=Re}} + end; +get_pattern(End, [C|Rest], State, Result) -> + get_pattern(End, Rest, State, [C|Result]); +get_pattern(End, [], State, Result) -> + get_pattern(End, [End], State, Result). + +get_replacement(End, Cmd) -> + get_replacement(End, Cmd, []). + +get_replacement(End, [End|Rest], Result) -> + {ok, lists:reverse(Result), Rest}; +get_replacement(End, [$\\, $&|Rest], Result) -> + get_replacement(End, Rest, [$&, $\\|Result]); +get_replacement(End, [$\\, C|Rest], Result) -> + get_replacement(End, Rest, [C|Result]); +get_replacement(End, [C|Rest], Result) -> + get_replacement(End, Rest, [C|Result]); +get_replacement(End, [], Result) -> + get_replacement(End, [End], Result). + +check_trailing_p([$l], St) -> + St#state{print=fun(Line, _) -> lister(Line, 0) end}; +check_trailing_p([$n], St) -> + St#state{print=fun numberer/2}; +check_trailing_p([$p], St) -> + St#state{print=fun(Line, _) -> io:put_chars(Line) end}; +check_trailing_p([], State) -> + State; +check_trailing_p(Other, State) -> + error(garbage_after_command). + +error(Reason) -> + throw({error, Reason}). + +match(State) when State#state.dot == 0 -> + false; +match(State) -> + [Line|_] = State#state.upto_dot, + Re = State#state.pattern, + case regexp:first_match(Line#line.contents, Re) of + {match, _, _} -> true; + nomatch -> false + end. + +skip_blanks([$ |Rest]) -> + skip_blanks(Rest); +skip_blanks(Rest) -> + Rest. + +print(Rest, [Line], St0) when Line > 0 -> + St1 = check_trailing_p(Rest, St0), + print(Line, move_to(Line-1, St1)); +print(Rest, [First, Last], St0) when First > 0 -> + St1 = check_trailing_p(Rest, St0), + print(Last, move_to(First-1, St1)). + +print(Last, St) when St#state.dot == Last -> + St#state{print=false}; +print(Last, St0) -> + St1 = next_line(St0), + print_current(St1), + print(Last, St1). + +lister(Rest, 64) -> + io:put_chars("\\\n"), + lister(Rest, 0); +lister([C|Rest], Num) -> + list_char(C), + lister(Rest, Num+1); +lister([], _) -> + ok. + +list_char($\t) -> + io:put_chars("\\t"); +list_char($\n) -> + io:put_chars("$\n"); +list_char(C) -> + io:put_chars([C]). + +numberer(Line, St) -> + io:format("~w\t~s", [St#state.dot, Line]). + +save_for_undo(St) -> + St#state{undo=St#state{undo=undefined, print=false}}. + +save_for_undo(St, OldSt) -> + St#state{undo=OldSt#state{undo=undefined, print=false}}. diff --git a/lib/tools/test/eprof_SUITE_data/eprof_suite_test.erl b/lib/tools/test/eprof_SUITE_data/eprof_suite_test.erl new file mode 100644 index 0000000000..a88b6e21f2 --- /dev/null +++ b/lib/tools/test/eprof_SUITE_data/eprof_suite_test.erl @@ -0,0 +1,74 @@ +%% ``The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved via the world wide web at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. +%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings +%% AB. All Rights Reserved.'' +%% +%% $Id$ +%% +%%%---------------------------------------------------------------------- +%%% Purpose : A priority queue. +%%%---------------------------------------------------------------------- +%%% This module implements a priority queue as defined in +%%% "Priority Queues and the STL" by Mark Nelson in Dr.Dobb's Journal, Jan 1996 +%%% see http://web2.airmail.net/markn/articles/pq_stl/priority.htm for more +%%% information. (A heap implementation is planned aswell) +%%%---------------------------------------------------------------------- +%%% The items of the queue is kept priority sorted, and because of that, +%%% a push() operation costs more than a pop() operation (wich only +%%% needs to return the top item of the queue(read: list)). +%%%---------------------------------------------------------------------- +%%% The priority queue can be deceptively nice to use when creating for +%%% example a Huffman coding tree. +%%% See http://web2.airmail.net/markn/articles/pq_stl/priority.htm or +%%% Dr.Dobb's Journal Jan, 96 for more information on this. +%%%---------------------------------------------------------------------- + +-module(eprof_suite_test). +-export([test/1]). +-export([new/0, push/3, pop/1]). + +test(Config) -> + Q1=new(), + Q2=push(Q1, "monkey", 3), + Q3=push(Q2, "banana", 4), + Q4=push(Q3, "jungle", 2), + Q5=push(Q4, "world", 5), + Q6=push(Q5, "universe",6), + Q7=push(Q6, "peanut", 1), +% io:format("~p~n",[Q7]), + {Itm, Q8}=pop(Q7), + ok. + +%% Returns a new priority queue. +new() -> + []. + +%% Pushes a new item with a set priority into the queue. +push(Queue, Itm, Pri) -> + insert(Queue, Itm, Pri, []). + +%% Pops the item with the highest priority out of the queue. +pop([{Itm, Pri}|Queue]) -> + {Itm, Queue}. + +%% --- -- - +%% Support functions. +insert([], Itm, Pri, NewQ) -> + lists:flatten([lists:reverse(NewQ)|[{Itm, Pri}]]); +% Itm>QItm>NewQ>Queue +insert([{QItm,QPri}|Queue], Itm, Pri, NewQ) when Pri>QPri-> + A = [{Itm, Pri}|[{QItm, QPri}]], + lists:flatten([[A|NewQ]|Queue]); +insert([QItm|Rest], Itm, Pri, NewQ) -> + insert(Rest, Itm, Pri, [QItm|NewQ]). +%% --- -- - diff --git a/lib/tools/test/fprof_SUITE.erl b/lib/tools/test/fprof_SUITE.erl new file mode 100644 index 0000000000..e437007e76 --- /dev/null +++ b/lib/tools/test/fprof_SUITE.erl @@ -0,0 +1,1191 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(fprof_SUITE). + +-include("test_server.hrl"). + +%% Test server framework exports +-export([all/1, not_run/1]). + +%% Test suites +-export([stack_seq/1, tail_seq/1, create_file_slow/1, spawn_simple/1, + imm_tail_seq/1, imm_create_file_slow/1, imm_compile/1, + cpu_create_file_slow/1]). + +%% Other exports +-export([create_file_slow/2]). + + +%% Debug exports +-export([parse/1, verify/2]). +-export([spawn_simple_test/3]). + + +-define(line_trace,true). + +%-define(debug,true). +-ifdef(debug). +-define(dbg(Str,Args), io:format(Str,Args)). +-else. +-define(dbg(Str,Args), ok). +-endif. + + + +%%%--------------------------------------------------------------------- +%%% Test suites +%%%--------------------------------------------------------------------- + + + +all(doc) -> + ["Test the 'fprof' profiling tool."]; +all(suite) -> + case test_server:is_native(?MODULE) of + true -> + [not_run]; + false -> + [stack_seq, tail_seq, create_file_slow, spawn_simple, + imm_tail_seq, imm_create_file_slow, imm_compile, + cpu_create_file_slow] + end. + +not_run(Config) when is_list(Config) -> + {skipped, "Native code"}. + +%%%--------------------------------------------------------------------- + +stack_seq(doc) -> + ["Tests a stack recursive variant of lists:seq/3"]; +stack_seq(suite) -> + []; +stack_seq(Config) when is_list(Config) -> + ?line Timetrap = ?t:timetrap(?t:seconds(20)), + ?line PrivDir = ?config(priv_dir, Config), + ?line TraceFile = + filename:join(PrivDir, ?MODULE_STRING"_stack_seq.trace"), + ?line AnalysisFile = + filename:join(PrivDir, ?MODULE_STRING"_stack_seq.analysis"), + ?line Start = 1, + ?line Stop = 1000, + ?line Succ = fun (X) -> X + 1 end, + ?line ok = fprof:stop(kill), + %% + ?line TS0 = erlang:now(), + ?line R0 = fprof:apply(fun seq/3, [Start, Stop, Succ], [{file, TraceFile}]), + ?line TS1 = erlang:now(), + ?line R = seq(Start, Stop, Succ), + ?line TS2 = erlang:now(), + ?line ok = fprof:profile(file, TraceFile), + ?line ok = fprof:analyse(), + ?line ok = fprof:analyse(dest, AnalysisFile), + ?line ok = fprof:stop(), + ?line R = R0, + %% + ?line {ok, [T, P]} = parse(AnalysisFile), + ?line io:format("~p~n~n~p~n", [P, ets:tab2list(T)]), + ?line ok = (catch verify(T, P)), + ?line Proc = pid_to_list(self()), + ?line case P of + [{analysis_options, _}, + [{totals, _, Acc, _}], + [{Proc, _, undefined, _} | _]] -> + ok + end, + %% + ?line check_own_and_acc(TraceFile,AnalysisFile), + %% + ?line ets:delete(T), + ?line file:delete(TraceFile), + ?line file:delete(AnalysisFile), + ?line ?t:timetrap_cancel(Timetrap), + ?line Acc1 = ts_sub(TS1, TS0), + ?line Acc2 = ts_sub(TS2, TS1), + ?line io:format("ts:~w, fprof:~w, bare:~w.~n", [Acc, Acc1, Acc2]), + {comment, io_lib:format("~p times slower", [Acc1/Acc2])}. + +%%%--------------------------------------------------------------------- + +tail_seq(doc) -> + ["Tests a tail recursive variant of lists:seq/3"]; +tail_seq(suite) -> + []; +tail_seq(Config) when is_list(Config) -> + ?line Timetrap = ?t:timetrap(?t:seconds(10)), + ?line PrivDir = ?config(priv_dir, Config), + ?line TraceFile = + filename:join(PrivDir, ?MODULE_STRING"_tail_seq.trace"), + ?line AnalysisFile = + filename:join(PrivDir, ?MODULE_STRING"_tail_seq.analysis"), + ?line Start = 1, + ?line Stop = 1000, + ?line Succ = fun (X) -> X + 1 end, + ?line ok = fprof:stop(kill), + %% + ?line TS0 = erlang:now(), + ?line R = seq_r(Start, Stop, Succ), + ?line TS1 = erlang:now(), + %% + ?line R1 = fprof:apply(fun seq_r/3, [Start, Stop, Succ], + [{file, TraceFile}]), + ?line TS2 = erlang:now(), + ?line ok = fprof:profile([{file,TraceFile}]), + ?line ok = fprof:analyse(), + ?line ok = fprof:analyse(dest, AnalysisFile), + ?line ok = fprof:stop(), + ?line R = R1, + %% + ?line {ok, [T, P]} = parse(AnalysisFile), + ?line io:format("~p~n~n~p~n", [P, ets:tab2list(T)]), + ?line ok = verify(T, P), + ?line Proc = pid_to_list(self()), + ?line case P of + [{analysis_options, _}, + [{totals, _, Acc, _}], + [{Proc, _, undefined, _} | _]] -> + ok + end, + %% + ?line check_own_and_acc(TraceFile,AnalysisFile), + %% + ?line ets:delete(T), + ?line file:delete(TraceFile), + ?line file:delete(AnalysisFile), + ?line ?t:timetrap_cancel(Timetrap), + ?line Acc1 = ts_sub(TS1, TS0), + ?line Acc2 = ts_sub(TS2, TS1), + ?line io:format("ts:~w, fprof:~w, bare:~w.~n", [Acc, Acc2, Acc1]), + {comment, io_lib:format("~p times slower", [Acc2/Acc1])}. + +%%%--------------------------------------------------------------------- + +create_file_slow(doc) -> + ["Tests the create_file_slow benchmark"]; +create_file_slow(suite) -> + []; +create_file_slow(Config) when is_list(Config) -> + ?line Timetrap = ?t:timetrap(?t:seconds(40)), + ?line PrivDir = ?config(priv_dir, Config), + ?line TraceFile = + filename:join(PrivDir, ?MODULE_STRING"_create_file_slow.trace"), + ?line AnalysisFile = + filename:join(PrivDir, ?MODULE_STRING"_create_file_slow.analysis"), + ?line DataFile = + filename:join(PrivDir, ?MODULE_STRING"_create_file_slow.data"), + ?line ok = fprof:stop(kill), + %% + ?line TS0 = erlang:now(), + ?line ok = create_file_slow(DataFile, 1024), + ?line TS1 = erlang:now(), + %% + ?line ok = file:delete(DataFile), + ?line TS2 = erlang:now(), + ?line ok = fprof:apply(?MODULE, create_file_slow, [DataFile, 1024], + [{file, TraceFile}]), + ?line TS3 = erlang:now(), + ?line ok = fprof:profile(file, TraceFile), + ?line ok = fprof:analyse(), + ?line ok = fprof:analyse(dest, AnalysisFile), + ?line ok = fprof:stop(), + %% + ?line {ok, [T, P]} = parse(AnalysisFile), + ?line io:format("~p~n~n~p~n", [P, ets:tab2list(T)]), + ?line ok = verify(T, P), + ?line Proc = pid_to_list(self()), + ?line case P of + [{analysis_options, _}, + [{totals, _, Acc, _}], + [{Proc, _, undefined, _} | _]] -> + ok + end, + %% + ?line check_own_and_acc(TraceFile,AnalysisFile), + %% + ?line ets:delete(T), + ?line file:delete(DataFile), + ?line file:delete(TraceFile), + ?line file:delete(AnalysisFile), + ?line ?t:timetrap_cancel(Timetrap), + ?line Acc1 = ts_sub(TS1, TS0), + ?line Acc3 = ts_sub(TS3, TS2), + ?line io:format("ts:~w, fprof:~w, bare:~w.~n", [Acc, Acc3, Acc1]), + {comment, io_lib:format("~p times slower", [Acc3/Acc1])}. + + + +%%%--------------------------------------------------------------------- + +spawn_simple(doc) -> + ["Tests process spawn"]; +spawn_simple(suite) -> + []; +spawn_simple(Config) when is_list(Config) -> + ?line Timetrap = ?t:timetrap(?t:seconds(30)), + ?line PrivDir = ?config(priv_dir, Config), + ?line TraceFile = + filename:join(PrivDir, ?MODULE_STRING"_spawn_simple.trace"), + ?line AnalysisFile = + filename:join(PrivDir, ?MODULE_STRING"_spawn_simple.analysis"), + ?line Start = 1, + ?line Stop = 1000, + ?line Succ = fun (X) -> X + 1 end, + ?line ok = fprof:stop(kill), + %% + ?line TS0 = erlang:now(), + ?line {{_, R1}, {_, R2}} = spawn_simple_test(Start, Stop, Succ), + ?line TS1 = erlang:now(), + %% + ?line ok = fprof:trace(start, TraceFile), + ?line {{P1, R3}, {P2, R4}} = spawn_simple_test(Start, Stop, Succ), + ?line ok = fprof:trace(stop), + ?line TS2 = erlang:now(), + ?line ok = fprof:profile(file, TraceFile), + ?line ok = fprof:analyse(), + ?line ok = fprof:analyse(dest, AnalysisFile), + ?line ok = fprof:stop(), + ?line R1 = R3, + ?line R2 = R4, + %% + ?line {ok, [T, P]} = parse(AnalysisFile), + ?line io:format("~p~n~n~p~n", [P, ets:tab2list(T)]), + ?line ok = verify(T, P), + ?line Proc1 = pid_to_list(P1), + ?line Proc2 = pid_to_list(P2), + ?line Proc0 = pid_to_list(self()), + ?line io:format("~p~n ~p ~p ~p~n", [P, Proc0, Proc1, Proc2]), + ?line [{analysis_options, _}, [{totals, _, Acc, _}] | Procs] = P, + ?line [[{Proc0, _, undefined, _} | _]] = + lists:filter(fun ([Pt | _]) when element(1, Pt) == Proc0 -> true; + (_) -> false + end, Procs), + ?line [[{Proc1, _, undefined, _}, + {spawned_by, Proc0}, + {spawned_as, {erlang, apply, ["#Fun"++_, []]}}, + {initial_calls, [{erlang, apply, 2}, + {?MODULE, '-spawn_simple_test/3-fun-0-', 4}]} + | _]] = + lists:filter(fun ([Pt | _]) when element(1, Pt) == Proc1 -> true; + (_) -> false + end, Procs), + ?line [[{Proc2, _, undefined, _}, + {spawned_by, Proc0}, + {spawned_as, {erlang, apply, ["#Fun"++_, []]}}, + {initial_calls, [{erlang, apply, 2}, + {?MODULE, '-spawn_simple_test/3-fun-1-', 4}]} + | _]] = + lists:filter(fun ([Pt | _]) when element(1, Pt) == Proc2 -> true; + (_) -> false + end, Procs), + ?line 3 = length(Procs), + ?line R1 = lists:reverse(R2), + %% + ?line check_own_and_acc(TraceFile,AnalysisFile), + %% + ?line ets:delete(T), + ?line file:delete(TraceFile), + ?line file:delete(AnalysisFile), + ?line ?t:timetrap_cancel(Timetrap), + ?line Acc1 = ts_sub(TS1, TS0), + ?line Acc2 = ts_sub(TS2, TS1), + ?line io:format("ts:~w, fprof:~w, bare:~w.~n", [Acc, Acc2, Acc1]), + {comment, io_lib:format("~p times slower", [Acc2/Acc1])}. + + +spawn_simple_test(Start, Stop, Succ) -> + Parent = self(), + Seq = + spawn_link( + fun () -> + Parent ! {self(), seq(Start, Stop, Succ)} + end), + SeqR = + spawn_link( + fun () -> + Parent ! {self(), seq_r(Start, Stop, Succ)} + end), + receive {Seq, SeqResult} -> + receive {SeqR, SeqRResult} -> + {{Seq, SeqResult}, {SeqR, SeqRResult}} + end + end. + + + +%%%--------------------------------------------------------------------- + +imm_tail_seq(doc) -> + ["Tests a tail recursive variant of lists:seq/3 ", + "with immediate trace to profile"]; +imm_tail_seq(suite) -> + []; +imm_tail_seq(Config) when is_list(Config) -> + ?line Timetrap = ?t:timetrap(?t:seconds(10)), + ?line PrivDir = ?config(priv_dir, Config), + ?line AnalysisFile = + filename:join(PrivDir, ?MODULE_STRING"_imm_tail_seq.analysis"), + ?line Start = 1, + ?line Stop = 1000, + ?line Succ = fun (X) -> X + 1 end, + ?line ok = fprof:stop(kill), + ?line catch eprof:stop(), + %% + ?line TS0 = erlang:now(), + ?line R0 = seq_r(Start, Stop, Succ), + ?line TS1 = erlang:now(), + %% + ?line profiling = eprof:start_profiling([self()]), + ?line TS2 = erlang:now(), + ?line R2 = seq_r(Start, Stop, Succ), + ?line TS3 = erlang:now(), + ?line profiling_stopped = eprof:stop_profiling(), + ?line R2 = R0, + %% + ?line eprof:analyse(), + ?line stopped = eprof:stop(), + %% + ?line {ok, Tracer} = fprof:profile(start), + ?line ok = fprof:trace([start, {tracer, Tracer}]), + ?line TS4 = erlang:now(), + ?line R4 = seq_r(Start, Stop, Succ), + ?line TS5 = erlang:now(), + ?line ok = fprof:trace(stop), + ?line ok = fprof:analyse(), + ?line ok = fprof:analyse(dest, AnalysisFile), + ?line ok = fprof:stop(), + ?line R4 = R0, + %% + ?line {ok, [T, P]} = parse(AnalysisFile), + ?line io:format("~p~n~n~p~n", [P, ets:tab2list(T)]), + ?line ok = verify(T, P), + ?line Proc = pid_to_list(self()), + ?line case P of + [{analysis_options, _}, + [{totals, _, Acc, _}], + [{Proc, _, undefined, _} | _]] -> + ok + end, + %% + ?line ets:delete(T), + ?line file:delete(AnalysisFile), + ?line ?t:timetrap_cancel(Timetrap), + ?line Acc1 = ts_sub(TS1, TS0), + ?line Acc3 = ts_sub(TS3, TS2), + ?line Acc5 = ts_sub(TS5, TS4), + ?line io:format("~p (plain), ~p (eprof), ~p (fprof), ~p (cpu)~n", + [Acc1/1000, Acc3/1000, Acc5/1000, Acc/1000]), + {comment, io_lib:format("~p/~p (fprof/eprof) times slower", + [Acc5/Acc1, Acc3/Acc1])}. + +%%%--------------------------------------------------------------------- + +imm_create_file_slow(doc) -> + ["Tests a tail recursive variant of lists:seq/3 ", + "with immediate trace to profile"]; +imm_create_file_slow(suite) -> + []; +imm_create_file_slow(Config) when is_list(Config) -> + ?line Timetrap = ?t:timetrap(?t:seconds(60)), + ?line PrivDir = ?config(priv_dir, Config), + ?line DataFile = + filename:join(PrivDir, ?MODULE_STRING"_imm_create_file_slow.data"), + ?line AnalysisFile = + filename:join(PrivDir, ?MODULE_STRING"_imm_create_file_slow.analysis"), + ?line ok = fprof:stop(kill), + %% + ?line TS0 = erlang:now(), + ?line ok = create_file_slow(DataFile, 1024), + ?line TS1 = erlang:now(), + ?line ok = file:delete(DataFile), + %% + ?line {ok, Tracer} = fprof:profile(start), + ?line TS2 = erlang:now(), + ?line ok = fprof:apply(?MODULE, create_file_slow, [DataFile, 1024], + [{tracer, Tracer}, continue]), + ?line TS3 = erlang:now(), + ?line ok = fprof:profile(stop), + ?line ok = fprof:analyse(), + ?line ok = fprof:analyse(dest, AnalysisFile), + ?line ok = fprof:stop(), + %% + ?line {ok, [T, P]} = parse(AnalysisFile), + ?line io:format("~p~n~n~p~n", [P, ets:tab2list(T)]), + ?line ok = verify(T, P), + ?line Proc = pid_to_list(self()), + ?line case P of + [{analysis_options, _}, + [{totals, _, Acc, _}], + [{Proc, _, undefined, _} | _]] -> + ok + end, + %% + ?line ets:delete(T), + ?line file:delete(DataFile), + ?line file:delete(AnalysisFile), + ?line ?t:timetrap_cancel(Timetrap), + ?line Acc1 = ts_sub(TS1, TS0), + ?line Acc3 = ts_sub(TS3, TS2), + ?line io:format("ts:~w, fprof:~w, bare:~w.~n", [Acc, Acc3, Acc1]), + {comment, io_lib:format("~p times slower", [Acc3/Acc1])}. + +%%%--------------------------------------------------------------------- + +imm_compile(doc) -> + ["Tests to compile a small source file ", + "with immediate trace to profile"]; +imm_compile(suite) -> + []; +imm_compile(Config) when is_list(Config) -> + ?line Timetrap = ?t:timetrap(?t:minutes(20)), + ?line DataDir = ?config(data_dir, Config), + ?line SourceFile = filename:join(DataDir, "foo.erl"), + ?line PrivDir = ?config(priv_dir, Config), + ?line AnalysisFile = + filename:join(PrivDir, ?MODULE_STRING"_imm_compile.analysis"), + ?line ok = fprof:stop(kill), + ?line catch eprof:stop(), + %% + ?line {ok, foo, _} = compile:file(SourceFile, [binary]), + ?line TS0 = erlang:now(), + ?line {ok, foo, _} = compile:file(SourceFile, [binary]), + ?line TS1 = erlang:now(), + %% + ?line profiling = eprof:start_profiling([self()]), + ?line TS2 = erlang:now(), + ?line {ok, foo, _} = compile:file(SourceFile, [binary]), + ?line TS3 = erlang:now(), + ?line profiling_stopped = eprof:stop_profiling(), + %% + ?line eprof:analyse(), + ?line stopped = eprof:stop(), + %% + ?line {ok, Tracer} = fprof:profile(start), + ?line ok = fprof:trace([start, {tracer, Tracer}]), + ?line TS4 = erlang:now(), + ?line {ok, foo, _} = compile:file(SourceFile, [binary]), + ?line TS5 = erlang:now(), + ?line ok = fprof:trace(stop), + %% + ?line io:format("Analysing...~n"), + ?line ok = fprof:analyse(dest, AnalysisFile), + ?line ok = fprof:stop(), + %% + ?line {ok, [T, P]} = parse(AnalysisFile), + ?line io:format("~p~n", [P]), + ?line Acc1 = ts_sub(TS1, TS0), + ?line Acc3 = ts_sub(TS3, TS2), + ?line Acc5 = ts_sub(TS5, TS4), + ?line io:format("Verifying...~n"), + ?line ok = verify(T, P), + ?line case P of + [{analysis_options, _}, + [{totals, _, Acc, _}] | _] -> + ok + end, + %% + ?line ets:delete(T), + ?line file:delete(AnalysisFile), + ?line ?t:timetrap_cancel(Timetrap), + ?line io:format("~p (plain), ~p (eprof), ~p (fprof), ~p(cpu)~n", + [Acc1/1000, Acc3/1000, Acc5/1000, Acc/1000]), + {comment, io_lib:format("~p/~p (fprof/eprof) times slower", + [Acc5/Acc1, Acc3/Acc1])}. + +%%%--------------------------------------------------------------------- + +cpu_create_file_slow(doc) -> + ["Tests the create_file_slow benchmark using cpu_time"]; +cpu_create_file_slow(suite) -> + []; +cpu_create_file_slow(Config) when is_list(Config) -> + ?line Timetrap = ?t:timetrap(?t:seconds(40)), + ?line PrivDir = ?config(priv_dir, Config), + ?line TraceFile = + filename:join(PrivDir, ?MODULE_STRING"_cpu_create_file_slow.trace"), + ?line AnalysisFile = + filename:join(PrivDir, ?MODULE_STRING"_cpu_create_file_slow.analysis"), + ?line DataFile = + filename:join(PrivDir, ?MODULE_STRING"_cpu_create_file_slow.data"), + ?line ok = fprof:stop(kill), + %% + ?line TS0 = erlang:now(), + ?line Result = (catch fprof:apply(?MODULE, create_file_slow, + [DataFile, 1024], + [{file, TraceFile}, cpu_time])), + ?line TS1 = erlang:now(), + ?line TestResult = + case Result of + ok -> + ?line ok = fprof:profile(file, TraceFile), + ?line ok = fprof:analyse(), + ?line ok = fprof:analyse(dest, AnalysisFile), + ?line ok = fprof:stop(), + %% + ?line {ok, [T, P]} = parse(AnalysisFile), + ?line io:format("~p~n~n~p~n", [P, ets:tab2list(T)]), + ?line ok = verify(T, P), + ?line Proc = pid_to_list(self()), + ?line case P of + [{analysis_options, _}, + [{totals, _, Acc, _}], + [{Proc, _, undefined, _} | _]] -> + ok + end, + %% + ?line check_own_and_acc(TraceFile,AnalysisFile), + %% + ?line ets:delete(T), + ?line file:delete(DataFile), + ?line file:delete(TraceFile), + ?line file:delete(AnalysisFile), + ?line Acc1 = ts_sub(TS1, TS0), + ?line io:format("cpu_ts:~w, fprof:~w~n", [Acc, Acc1]), + {comment, io_lib:format("~p% cpu utilization", + [100*Acc/Acc1])}; + {'EXIT', not_supported} -> + case {os:type(), os:version()} of + {{unix, sunos}, {Major, Minor, _}} + when Major >= 5, Minor >= 7 -> + test_server:fail(Result); + _ -> + {skipped, "not_supported"} + end; + _ -> + test_server:fail(Result) + end, + ?line ?t:timetrap_cancel(Timetrap), + TestResult. + + + +%%%--------------------------------------------------------------------- +%%% Functions to test +%%%--------------------------------------------------------------------- + + + +%% Stack recursive seq +seq(Stop, Stop, Succ) when is_function(Succ) -> + [Stop]; +seq(Start, Stop, Succ) when is_function(Succ) -> + [Start | seq(Succ(Start), Stop, Succ)]. + + + +%% Tail recursive seq, result list is reversed +seq_r(Start, Stop, Succ) when is_function(Succ) -> + seq_r(Start, Stop, Succ, []). + +seq_r(Stop, Stop, _, R) -> + [Stop | R]; +seq_r(Start, Stop, Succ, R) -> + seq_r(Succ(Start), Stop, Succ, [Start | R]). + + + +create_file_slow(Name, N) when is_integer(N), N >= 0 -> + {ok, FD} = + file:open(Name, [raw, write, delayed_write, binary]), + if N > 256 -> + ok = file:write(FD, + lists:map(fun (X) -> <<X:32/unsigned>> end, + lists:seq(0, 255))), + ok = create_file_slow(FD, 256, N); + true -> + ok = create_file_slow(FD, 0, N) + end, + ok = file:close(FD). + +create_file_slow(_FD, M, M) -> + ok; +create_file_slow(FD, M, N) -> + ok = file:write(FD, <<M:32/unsigned>>), + create_file_slow(FD, M+1, N). + + + +%%%--------------------------------------------------------------------- +%%% Profile verification functions +%%%--------------------------------------------------------------------- + + + +verify(Tab, [{analysis_options, _}, + [{totals, Cnt, Acc, Own} | _] | Processes]) -> + Processes_1 = + lists:map( + fun ([{Proc, Cnt_P, undefined, Own_P} | _]) -> + case sum_process(Tab, Proc) of + {Proc, Cnt_P, Acc_P, Own_P} = Clocks + when Acc_P >= Own_P -> + Clocks; + Weird -> + throw({error, [?MODULE, ?LINE, Weird]}) + end + end, + Processes), + case lists:foldl( + fun ({_, Cnt_P2, Acc_P2, Own_P2}, + {totals, Cnt_T, Acc_T, Own_T}) -> + {totals, Cnt_P2+Cnt_T, Acc_P2+Acc_T, Own_P2+Own_T} + end, + {totals, 0, 0, 0}, + Processes_1) of + {totals, Cnt, Acc_T, Own} when Acc_T >= Acc -> + ok; + Weird -> + throw({error, [?MODULE, ?LINE, Weird]}) + end. + + + +sum_process(Tab, Proc) -> + ets_select_fold( + Tab, [{{{Proc, '_'}, '_'}, [], ['$_']}], 100, + fun ({{P, MFA}, {Callers, {MFA, Cnt, Acc, Own}, Called}}, + {P, Cnt_P, Acc_P, Own_P}) when P == Proc -> + ok = verify_callers(Tab, Proc, MFA, Callers), + ok = verify_called(Tab, Proc, MFA, Called), + {P, Cnt+Cnt_P, Acc+Acc_P, Own+Own_P}; + (Weird, Clocks) -> + throw({error, [?MODULE, ?LINE, Weird, Clocks]}) + end, + {Proc, 0, 0, 0}). + +verify_callers(_, _, _, []) -> + ok; +verify_callers(Tab, Proc, MFA, [{Caller, Cnt, Acc, Own} | Tail]) -> + Id = {Proc, Caller}, + case ets:lookup(Tab, Id) of + [{Id, {_, {Caller, _, _, _}, Called}}] -> + case lists:keysearch(MFA, 1, Called) of + {value, {MFA, Cnt, Acc, Own}} -> + verify_callers(Tab, Proc, MFA, Tail); + false -> + throw({error, [?MODULE, ?LINE, MFA, Id]}) + end; + Weird -> + throw({error, [?MODULE, ?LINE, Weird]}) + end. + +verify_called(_, _, _, []) -> + ok; +verify_called(Tab, Proc, MFA, [{Called, Cnt, Acc, Own} | Tail]) -> + Id = {Proc, Called}, + case ets:lookup(Tab, Id) of + [{Id, {Callers, {Called, _, _, _}, _}}] -> + case lists:keysearch(MFA, 1, Callers) of + {value, {MFA, Cnt, Acc, Own}} -> + verify_called(Tab, Proc, MFA, Tail); + false -> + throw({error, [?MODULE, ?LINE, MFA, Id]}) + end; + Weird -> + throw({error, [?MODULE, ?LINE, Weird]}) + end. + + + +%% Parse a analysis file and return an Ets table with all function entries, +%% and a list of process entries. Checks the concistency of the function +%% entries when they are read. +parse(Filename) -> + case file:open(Filename, [read]) of + {ok, FD} -> + Result = parse_stream(FD), + file:close(FD), + Result; + Error -> + Error + end. + +parse_stream(FD) -> + Tab = ets:new(fprof_SUITE, []), + parse_stream(FD, Tab, [], void). + +parse_stream(FD, Tab, R, Proc) -> + case catch io:read(FD, '') of + {'EXIT', _} -> + {error, [?MODULE, ?LINE]}; + {ok, Term} -> + case parse_term(Term) of + {ok, {analysis_options, _} = Term_1} + when Proc == void -> + parse_stream(FD, Tab, [Term_1 | R], analysis_options); + {ok, [{totals, _, _, _} | _] = Term_1} + when Proc == analysis_options -> + parse_stream(FD, Tab, [Term_1 | R], totals); + {ok, [{P, _, _, _} | _] = Term_1} -> + parse_stream(FD, Tab, [Term_1 | R], P); + {ok, {_Callers, {MFA, _, _, _}, _Called} = Term_1} + when Proc == totals; is_list(Proc) -> + ets:insert(Tab, {{Proc, MFA}, Term_1}), + parse_stream(FD, Tab, R, Proc); + {ok, Term_1} -> + {error, [?MODULE, ?LINE, Term_1]}; + E -> + E + end; + eof -> + {ok, [Tab, lists:reverse(R)]}; + Error -> + Error + end. + +parse_term({Callers, Func, Called}) + when is_list(Callers), is_list(Called) -> + Callers_1 = lists:map(fun parse_clocks/1, Callers), + Func_1 = parse_clocks(Func), + Called_1 = lists:map(fun parse_clocks/1, Called), + Result = {Callers_1, Func_1, Called_1}, + case chk_invariant(Result) of + ok -> + {ok, Result}; + Error -> + Error + end; +parse_term([{_, _, _, _} = Clocks | Tail]) -> + {ok, [parse_clocks(Clocks) | Tail]}; +parse_term(Term) -> + {ok, Term}. + +parse_clocks({MFA, Cnt, undefined, Own}) -> + {MFA, Cnt, undefined, round(Own*1000)}; +parse_clocks({MFA, Cnt, Acc, Own}) -> + {MFA, Cnt, round(Acc*1000), round(Own*1000)}; +parse_clocks(Clocks) -> + Clocks. + + + +chk_invariant({Callers, {MFA, Cnt, Acc, Own}, Called} = Term) -> + {_, Callers_Cnt, Callers_Acc, Callers_Own} = Callers_Sum = sum(Callers), +% {_, Called_Cnt, Called_Acc, Called_Own} = Called_Sum = sum(Called), + case {MFA, + lists:keymember(suspend, 1, Callers), + lists:keymember(garbage_collect, 1, Callers), + Called} of + {suspend, false, _, []} -> + ok; + {suspend, _, _, _} = Weird -> + {error, [?MODULE, ?LINE, Weird, Term]}; + {garbage_collect, false, false, []} -> + ok; + {garbage_collect, false, false, [{suspend, _, _, _}]} -> + ok; + {garbage_collect, _, _, _} = Weird -> + {error, [?MODULE, ?LINE, Weird, Term]}; + {undefined, false, false, _} + when Callers == [], Cnt == 0, Acc == 0, Own == 0 -> + ok; + {undefined, _, _, _} = Weird -> + {error, [?MODULE, ?LINE, Weird, Term]}; + {_, _, _, _} -> + case chk_self_call(Term) of + true when Callers_Cnt /= Cnt; Callers_Acc /= Acc; + Callers_Own /= Own -> + {error, [?MODULE, ?LINE, Callers_Sum, Term]}; +% true when Called_Acc + Own /= Acc -> +% io:format("WARNING: ~p:~p, ~p, ~p.~n", +% [?MODULE, ?LINE, Term, Called_Sum]), +% {error, [?MODULE, ?LINE, Term, Called_Sum]}; +% ok; + true -> + ok; + false -> + {error, [?MODULE, ?LINE, Term]} + end + end. + +ts_sub({A, B, C}, {A0, B0, C0}) -> + ((A - A0)*1000000000000 + (B - B0))*1000000 + C - C0. + +sum(Funcs) -> + {sum, _Cnt, _Acc, _Own} = + lists:foldl( + fun ({_, C1, A1, O1}, {sum, C2, A2, O2}) -> + {sum, C1+C2, A1+A2, O1+O2} + end, + {sum, 0, 0, 0}, + Funcs). + +chk_self_call({Callers, {MFA, _Cnt, _Acc, _Own}, Called}) -> + case lists:keysearch(MFA, 1, Callers) of + false -> + true; + {value, {MFA, C, 0, O}} -> + case lists:keysearch(MFA, 1, Called) of + false -> + false; + {value, {MFA, C, 0, O}} -> + true; + {value, _} -> + false + end; + {value, _} -> + false + end. + + + +%%%--------------------------------------------------------------------- +%%% Fairly generic support functions +%%%--------------------------------------------------------------------- + + +ets_select_fold(Table, MatchSpec, Limit, Fun, Acc) -> + ets:safe_fixtable(Table, true), + ets_select_fold_1(ets:select(Table, MatchSpec, Limit), Fun, Acc). + +ets_select_fold_1('$end_of_table', _, Acc) -> + Acc; +ets_select_fold_1({Matches, Continuation}, Fun, Acc) -> + ets_select_fold_1(ets:select(Continuation), + Fun, + lists:foldl(Fun, Acc, Matches)). + + + +% ets_select_foreach(Table, MatchSpec, Limit, Fun) -> +% ets:safe_fixtable(Table, true), +% ets_select_foreach_1(ets:select(Table, MatchSpec, Limit), Fun). + +% ets_select_foreach_1('$end_of_table', _) -> +% ok; +% ets_select_foreach_1({Matches, Continuation}, Fun) -> +% lists:foreach(Fun, Matches), +% ets_select_foreach_1(ets:select(Continuation), Fun). + + +%%%--------------------------------------------------------------------- +%%% Simple smulation of fprof used for checking own and acc times for +%%% each function. +%%% The function 'undefined' is ignored +%%%--------------------------------------------------------------------- + +%% check_own_and_acc_traced(TraceFile, AnalysisFile) -> +%% check_own_and_acc(TraceFile, AnalysisFile, fun handle_trace_traced/2). + +check_own_and_acc(TraceFile, AnalysisFile) -> + check_own_and_acc(TraceFile, AnalysisFile, fun handle_trace/2). + +check_own_and_acc(TraceFile, AnalysisFile, HandlerFun) -> + dbg:trace_client(file,TraceFile,{HandlerFun,{init,self()}}), + receive {result,Result} -> + compare(Result,get_own_and_acc_from_analysis(AnalysisFile)) + end. + +%% handle_trace_traced(Trace, Msg) -> +%% io:format("handle_trace_traced(~p, ~p).", [Trace, Msg]), +%% handle_trace(Trace, Msg). + +handle_trace(Trace,{init,Parent}) -> + ?dbg("~p",[start]), + ets:new(fprof_verify_tab,[named_table]), + handle_trace(Trace,Parent); +handle_trace({trace_ts,Pid,in,MFA,TS},P) -> + ?dbg("~p",[{{in,Pid,MFA},get(Pid)}]), + case get(Pid) of + [suspend|[suspend|_]=NewStack] -> + T = ts_sub(TS,get({Pid,last_ts})), + update_acc(Pid,NewStack,T), + put(Pid,NewStack); + [suspend|NewStack] = Stack -> + T = ts_sub(TS,get({Pid,last_ts})), + update_acc(Pid,Stack,T), + put(Pid,NewStack); + [] -> + put(Pid,[MFA]), + insert(Pid,MFA); + undefined -> + put(first_ts,TS), + put(Pid,[MFA]), + insert(Pid,MFA) + end, + put({Pid,last_ts},TS), + P; +handle_trace({trace_ts,Pid,out,_MfaOrZero,TS},P) -> + ?dbg("~p",[{{out,Pid,_MfaOrZero},get(Pid)}]), + T = ts_sub(TS,get({Pid,last_ts})), + case get(Pid) of + [suspend|S] = Stack -> + update_acc(Pid,S,T), + put(Pid,[suspend|Stack]); + [MFA|_] = Stack -> + insert(Pid,suspend), + update_own(Pid,MFA,T), + update_acc(Pid,Stack,T), + put(Pid,[suspend|Stack]); + [] -> + insert(Pid,suspend), + put(Pid,[suspend]) + end, + put({Pid,last_ts},TS), + P; +handle_trace({trace_ts,Pid,call,MFA,{cp,Caller},TS},P) -> + ?dbg("~p",[{{call,Pid,MFA},get(Pid)}]), + T = ts_sub(TS,get({Pid,last_ts})), + case get(Pid) of + [MFA|_] = Stack -> + %% recursive + update_own(Pid,MFA,T), + update_acc(Pid,Stack,T); + [CallingMFA|_] = Stack when Caller==undefined -> + insert(Pid,MFA), + update_own(Pid,CallingMFA,T), + update_acc(Pid,Stack,T), + put(Pid,[MFA|Stack]); + [] when Caller==undefined -> + insert(Pid,MFA), + insert(Pid,MFA), + put(Pid,[MFA]); + Stack0 -> + Stack = [CallingMFA|_] = insert_caller(Caller,Stack0,[]), + insert(Pid,MFA), + insert(Pid,Caller), + update_own(Pid,CallingMFA,T), + update_acc(Pid,Stack,T), + put(Pid,[MFA|Stack]) + end, + put({Pid,last_ts},TS), + P; +handle_trace({trace_ts,Pid,return_to,MFA,TS},P) -> + ?dbg("~p",[{{return_to,Pid,MFA},get(Pid)}]), + T = ts_sub(TS,get({Pid,last_ts})), + case get(Pid) of + [MFA|_] = Stack -> + %% recursive + update_own(Pid,MFA,T), + update_acc(Pid,Stack,T), + put(Pid,Stack); + [ReturnFromMFA,MFA|RestOfStack] = Stack -> + update_own(Pid,ReturnFromMFA,T), + update_acc(Pid,Stack,T), + put(Pid,[MFA|RestOfStack]); + [ReturnFromMFA|RestOfStack] = Stack -> + update_own(Pid,ReturnFromMFA,T), + update_acc(Pid,Stack,T), + case find_return_to(MFA,RestOfStack) of + [] when MFA==undefined -> + put(Pid,[]); + [] -> + insert(Pid,MFA), + put(Pid,[MFA]); + NewStack -> + put(Pid,NewStack) + end + end, + put({Pid,last_ts},TS), + P; +handle_trace({trace_ts,Pid,gc_start,_,TS},P) -> + ?dbg("~p",[{{gc_start,Pid},get(Pid)}]), + case get(Pid) of + [suspend|_] = Stack -> + T = ts_sub(TS,get({Pid,last_ts})), + insert(Pid,garbage_collect), + update_acc(Pid,Stack,T), + put(Pid,[garbage_collect|Stack]); + [CallingMFA|_] = Stack -> + T = ts_sub(TS,get({Pid,last_ts})), + insert(Pid,garbage_collect), + update_own(Pid,CallingMFA,T), + update_acc(Pid,Stack,T), + put(Pid,[garbage_collect|Stack]); + undefined -> + put(first_ts,TS), + put(Pid,[garbage_collect]), + insert(Pid,garbage_collect) + end, + put({Pid,last_ts},TS), + P; +handle_trace({trace_ts,Pid,gc_end,_,TS},P) -> + ?dbg("~p",[{{gc_end,Pid},get(Pid)}]), + T = ts_sub(TS,get({Pid,last_ts})), + case get(Pid) of + [garbage_collect|RestOfStack] = Stack -> + update_own(Pid,garbage_collect,T), + update_acc(Pid,Stack,T), + put(Pid,RestOfStack) + end, + put({Pid,last_ts},TS), + P; +handle_trace({trace_ts,Pid,spawn,NewPid,{M,F,Args},TS},P) -> + MFA = {M,F,length(Args)}, + ?dbg("~p",[{{spawn,Pid,NewPid,MFA},get(Pid)}]), + T = ts_sub(TS,get({Pid,last_ts})), + put({NewPid,last_ts},TS), + put(NewPid,[suspend,MFA]), + insert(NewPid,suspend), + insert(NewPid,MFA), + case get(Pid) of + [SpawningMFA|_] = Stack -> + update_own(Pid,SpawningMFA,T), + update_acc(Pid,Stack,T) + end, + put({Pid,last_ts},TS), + P; +handle_trace({trace_ts,Pid,exit,_Reason,TS},P) -> + ?dbg("~p",[{{exit,Pid,_Reason},get(Pid)}]), + T = ts_sub(TS,get({Pid,last_ts})), + case get(Pid) of + [DyingMFA|_] = Stack -> + update_own(Pid,DyingMFA,T), + update_acc(Pid,Stack,T), + put(Pid,[]); + [] -> + ok + end, + put({Pid,last_ts},TS), + P; +handle_trace({trace_ts,_,Link,_,_},P) + when Link==link; + Link==unlink; + Link==getting_linked; + Link==getting_unlinked -> + P; +handle_trace(end_of_trace,P) -> + ?dbg("~p",['end']), + Result = ets:tab2list(fprof_verify_tab), + {TotOwn,ProcOwns} = get_proc_owns(Result,[],0), + TotAcc = ts_sub(get_last_ts(),get(first_ts)), + P ! {result,[{totals,TotAcc,TotOwn}|ProcOwns]++Result}, + P; +handle_trace(Other,_P) -> + exit({unexpected,Other}). + +find_return_to(MFA,[MFA|_]=Stack) -> + Stack; +find_return_to(MFA,[_|Stack]) -> + find_return_to(MFA,Stack); +find_return_to(_MFA,[]) -> + []. + +insert_caller(MFA,[MFA|Rest],Result) -> + lists:reverse(Result)++[MFA|Rest]; +insert_caller(MFA,[Other|Rest],Result) -> + insert_caller(MFA,Rest,[Other|Result]); +insert_caller(MFA,[],Result) -> + lists:reverse([MFA|Result]). + +insert(Pid,MFA) -> + case ets:member(fprof_verify_tab,{Pid,MFA}) of + false -> + ets:insert(fprof_verify_tab,{{Pid,MFA},0,0}); + true -> + ok + end. + +update_own(Pid,MFA,T) -> + ets:update_counter(fprof_verify_tab,{Pid,MFA},{3,T}). + +update_acc(Pid,[MFA|Rest],T) -> + case lists:member(MFA,Rest) of + true -> + %% Only charge one time for recursive functions + ok; + false -> + ets:update_counter(fprof_verify_tab,{Pid,MFA},{2,T}) + end, + update_acc(Pid,Rest,T); +update_acc(_Pid,[],_T) -> + ok. + + +get_last_ts() -> + get_last_ts(get(),{0,0,0}). +get_last_ts([{{_,last_ts},TS}|Rest],Last) when TS>Last -> + get_last_ts(Rest,TS); +get_last_ts([_|Rest],Last) -> + get_last_ts(Rest,Last); +get_last_ts([],Last) -> + Last. + +get_proc_owns([{{Pid,_MFA},_Acc,Own}|Rest],Result,Sum) -> + NewResult = + case lists:keysearch(Pid,1,Result) of + {value,{Pid,undefined,PidOwn}} -> + lists:keyreplace(Pid,1,Result,{Pid,undefined,PidOwn+Own}); + false -> + [{Pid,undefined,Own}|Result] + end, + get_proc_owns(Rest,NewResult,Sum+Own); +get_proc_owns([],Result,Sum) -> + {Sum,Result}. + + +compare([X|Rest],FprofResult) -> + FprofResult1 = + case lists:member(X,FprofResult) of + true -> + ?dbg("~p",[X]), + lists:delete(X,FprofResult); + false -> + case lists:keysearch(element(1,X),1,FprofResult) of + {value,Fprof} -> + put(compare_error,true), + io:format("Error: Different values\n" + "Fprof: ~p\n" + "Simulator: ~p",[Fprof,X]), + lists:delete(Fprof,FprofResult); + false -> + put(compare_error,true), + io:format("Error: Missing in fprof: ~p",[X]), + FprofResult + end + end, + compare(Rest,FprofResult1); +compare([],Rest) -> + case {remove_undefined(Rest,[]),get(compare_error)} of + {[],undefined} -> ok; + {Error,_} -> + case Error of + [] -> ok; + _ -> io:format("\nMissing in simulator results:\n~p\n",[Error]) + end, + ?t:fail({error,mismatch_between_simulator_and_fprof}) + end. + +remove_undefined([{{_Pid,undefined},_,_}|Rest],Result) -> + remove_undefined(Rest,Result); +remove_undefined([X|Rest],Result) -> + remove_undefined(Rest,[X|Result]); +remove_undefined([],Result) -> + Result. + +get_own_and_acc_from_analysis(Log) -> + case file:consult(Log) of + {ok,[_Options,[{totals,_,TotAcc,TotOwn}]|Rest]} -> + get_own_and_acc(undefined,Rest, + [{totals,m1000(TotAcc),m1000(TotOwn)}]); + Error -> + exit({error,{cant_open,Log,Error}}) + end. + +get_own_and_acc(_,[[{PidStr,_,Acc,Own}|_]|Rest],Result) -> + Pid = list_to_pid(PidStr), + get_own_and_acc(Pid,Rest,[{Pid,m1000(Acc),m1000(Own)}|Result]); +get_own_and_acc(Pid,[{_Callers,{MFA,_,Acc,Own},_Called}|Rest],Result) -> + get_own_and_acc(Pid,Rest,[{{Pid,MFA},m1000(Acc),m1000(Own)}|Result]); +get_own_and_acc(_,[],Result) -> + lists:reverse(Result). + +m1000(undefined) -> + undefined; +m1000(X) -> + round(X*1000). + diff --git a/lib/tools/test/fprof_SUITE_data/foo.erl b/lib/tools/test/fprof_SUITE_data/foo.erl new file mode 100644 index 0000000000..eaa8132b1e --- /dev/null +++ b/lib/tools/test/fprof_SUITE_data/foo.erl @@ -0,0 +1,41 @@ +%% ``The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved via the world wide web at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. +%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings +%% AB. All Rights Reserved.'' +%% +%% $Id$ +%% +-module(foo). + +-export([create_file_slow/2]). + + + +create_file_slow(Name, N) when integer(N), N >= 0 -> + {ok, FD} = + file:open(Name, [raw, write, delayed_write, binary]), + if N > 256 -> + ok = file:write(FD, + lists:map(fun (X) -> <<X:32/unsigned>> end, + lists:seq(0, 255))), + ok = create_file_slow(FD, 256, N); + true -> + ok = create_file_slow(FD, 0, N) + end, + ok = file:close(FD). + +create_file_slow(FD, M, M) -> + ok; +create_file_slow(FD, M, N) -> + ok = file:write(FD, <<M:32/unsigned>>), + create_file_slow(FD, M+1, N). diff --git a/lib/tools/test/ignore_cores.erl b/lib/tools/test/ignore_cores.erl new file mode 120000 index 0000000000..8902a469ef --- /dev/null +++ b/lib/tools/test/ignore_cores.erl @@ -0,0 +1 @@ +../../../erts/test/ignore_cores.erl
\ No newline at end of file diff --git a/lib/tools/test/instrument_SUITE.erl b/lib/tools/test/instrument_SUITE.erl new file mode 100644 index 0000000000..da5930e015 --- /dev/null +++ b/lib/tools/test/instrument_SUITE.erl @@ -0,0 +1,129 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1998-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(instrument_SUITE). + +-export([all/1,init_per_testcase/2,fin_per_testcase/2]). + +-export(['+Mim true'/1, '+Mis true'/1]). + +-include("test_server.hrl"). + +init_per_testcase(_Case, Config) -> + ?line Dog=?t:timetrap(10000), + [{watchdog, Dog}|Config]. + +fin_per_testcase(_Case, Config) -> + Dog=?config(watchdog, Config), + ?t:timetrap_cancel(Dog), + ok. + +all(suite) -> ['+Mim true', '+Mis true']. + +'+Mim true'(doc) -> ["Check that memory data can be read and processed"]; +'+Mim true'(suite) -> []; +'+Mim true'(Config) when is_list(Config) -> + ?line Node = start_slave("+Mim true"), + ?line MD = rpc:call(Node, instrument, memory_data, []), + ?line [{total,[{sizes,S1,S2,S3},{blocks,B1,B2,B3}]}] + = rpc:call(Node, instrument, memory_status, [total]), + ?line stop_slave(Node), + ?line true = S1 =< S2, + ?line true = S2 =< S3, + ?line true = B1 =< B2, + ?line true = B2 =< B3, + ?line MDS = instrument:sort(MD), + ?line {Low, High} = instrument:mem_limits(MDS), + ?line true = Low < High, + ?line {_, AL} = MDS, + ?line SumBlocks = instrument:sum_blocks(MD), + ?line case SumBlocks of + N when is_integer(N) -> + ?line N = lists:foldl(fun ({_,_,Size,_}, Sum) -> + Size+Sum + end, + 0, + AL), + ?line N =< S3; + Other -> + ?line ?t:fail(Other) + end, + ?line lists:foldl( + fun ({TDescr,Addr,Size,Proc}, MinAddr) -> + ?line true = TDescr /= invalid_type, + ?line true = is_integer(TDescr), + ?line true = is_integer(Addr), + ?line true = is_integer(Size), + ?line true = Addr >= MinAddr, + ?line case Proc of + {0, Number, Serial} -> + ?line true = is_integer(Number), + ?line true = is_integer(Serial); + undefined -> + ok; + BadProc -> + ?line ?t:fail({badproc, BadProc}) + end, + ?line NextMinAddr = Addr+Size, + ?line true = NextMinAddr =< High, + ?line NextMinAddr + end, + Low, + AL), + ?line {_, DAL} = instrument:descr(MDS), + ?line lists:foreach( + fun ({TDescr,_,_,Proc}) -> + ?line true = TDescr /= invalid_type, + ?line true = is_atom(TDescr) orelse is_list(TDescr), + ?line true = is_pid(Proc) orelse Proc == undefined + end, + DAL), + ?line ASL = lists:map(fun ({_,A,S,_}) -> {A,S} end, AL), + ?line ASL = lists:map(fun ({_,A,S,_}) -> {A,S} end, DAL), + ?line instrument:holes(MDS), + ?line {comment, + "total status - sum of blocks = " ++ integer_to_list(S1-SumBlocks)}. + +'+Mis true'(doc) -> ["Check that memory data can be read and processed"]; +'+Mis true'(suite) -> []; +'+Mis true'(Config) when is_list(Config) -> + ?line Node = start_slave("+Mis true"), + ?line [{total,[{sizes,S1,S2,S3},{blocks,B1,B2,B3}]}] + = rpc:call(Node, instrument, memory_status, [total]), + ?line true = S1 =< S2, + ?line true = S2 =< S3, + ?line true = B1 =< B2, + ?line true = B2 =< B3, + ?line true = is_list(rpc:call(Node,instrument,memory_status,[allocators])), + ?line true = is_list(rpc:call(Node,instrument,memory_status,[classes])), + ?line true = is_list(rpc:call(Node,instrument,memory_status,[types])), + ?line ok. + +start_slave(Args) -> + ?line {A, B, C} = now(), + ?line MicroSecs = A*1000000000000 + B*1000000 + C, + ?line Name = "instr_" ++ integer_to_list(MicroSecs), + ?line Pa = filename:dirname(code:which(?MODULE)), + ?line {ok, Node} = ?t:start_node(list_to_atom(Name), + slave, + [{args, "-pa " ++ Pa ++ " " ++ Args}]), + ?line Node. + + +stop_slave(Node) -> + ?line true = ?t:stop_node(Node). diff --git a/lib/tools/test/make_SUITE.erl b/lib/tools/test/make_SUITE.erl new file mode 100644 index 0000000000..72dccdb465 --- /dev/null +++ b/lib/tools/test/make_SUITE.erl @@ -0,0 +1,295 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(make_SUITE). + +-export([all/1, make_all/1, make_files/1]). +-export([otp_6057_init/1, + otp_6057_a/1, otp_6057_b/1, otp_6057_c/1, + otp_6057_end/1]). + +-include("test_server.hrl"). + +-include_lib("kernel/include/file.hrl"). + +%% in ./make_SUITE_data there are test-files used by this +%% test suite. There are 4 files named test1.erl ... test5.erl. +%% The test files are attacked in various ways in order to put make on trial. +%% +%% Also, and Emakefile exists in ./make_SUITE_data. This file specifies +%% that the file :"test5.erl" shall be compiled with the 'S' option, +%% i.e. produce "test5.S" instead of "test5.<objext>" + +all(suite) -> [make_all, make_files, + {conf, otp_6057_init, + [otp_6057_a,otp_6057_b,otp_6057_c], otp_6057_end}]. + +test_files() -> ["test1", "test2", "test3", "test4"]. + +make_all(suite) -> []; +make_all(Config) when is_list(Config) -> + ?line Current = prepare_data_dir(Config), + ?line up_to_date = make:all(), + ?line ok = ensure_exists(test_files()), + ?line ok = ensure_exists(["test5"],".S"), % Emakefile: [{test5,['S']} + ?line file:set_cwd(Current), + ?line ensure_no_messages(), + ok. + +make_files(suite) -> []; +make_files(Config) when is_list(Config) -> + ?line Current = prepare_data_dir(Config), + + %% Make files that exist. + + ?line Files = [test1, test2], + ?line up_to_date = make:files(Files), % ok files + ?line ok = ensure_exists(Files), + + ?line error = make:files([test1,test7]), % non existing file + ?line up_to_date = make:files([test1,test2],[debug_info]), % with option + + ?line file:set_cwd(Current), + ?line ensure_no_messages(), + ok. + + +%% Moves to the data directory of this suite, clean it from any object +%% files (*.jam for a JAM emulator). Returns the previous directory. +prepare_data_dir(Config) -> + ?line {ok, Current} = file:get_cwd(), + ?line {value, {data_dir, Dir}} = lists:keysearch(data_dir, 1, Config), + ?line file:set_cwd(Dir), + ?line {ok, Files} = file:list_dir("."), + ?line delete_obj(Files, code:objfile_extension()), + ?line ensure_no_messages(), + Current. + +delete_obj([File|Rest], ObjExt) -> + ?line case filename:extension(File) of + ObjExt -> file:delete(File); + ".S" -> file:delete(File); + _ -> ok + end, + ?line delete_obj(Rest, ObjExt); +delete_obj([], _) -> + ok. + + + +%% Ensure that the given object files exists. +ensure_exists(Names) -> + ensure_exists(Names, code:objfile_extension()). + +ensure_exists([Name|Rest], ObjExt) when is_atom(Name) -> + ensure_exists([atom_to_list(Name)|Rest], ObjExt); +ensure_exists([Name|Rest], ObjExt) -> + case filelib:is_regular(Name++ObjExt) of + true -> + ensure_exists(Rest, ObjExt); + false -> + Name++ObjExt + end; +ensure_exists([], _) -> + ok. + +otp_6057_init(Config) when is_list(Config) -> + ?line DataDir = ?config(data_dir, Config), + ?line PrivDir = ?config(priv_dir, Config), + + %% Create the directories PrivDir/otp_6057/src1, /src2 and /ebin + Src1 = filename:join([PrivDir, otp_6057, src1]), + Src2 = filename:join([PrivDir, otp_6057, src2]), + Ebin = filename:join([PrivDir, otp_6057, ebin]), + ?line ok = file:make_dir(filename:join(PrivDir, otp_6057)), + ?line ok = file:make_dir(Src1), + ?line ok = file:make_dir(Src2), + ?line ok = file:make_dir(Ebin), + + %% Copy test1.erl and test2.erl to src1, and test3.erl to src2 + Test1orig = filename:join(DataDir, "test1.erl"), + Test2orig = filename:join(DataDir, "test2.erl"), + Test3orig = filename:join(DataDir, "test3.erl"), + Test1 = filename:join(Src1, "test1.erl"), + Test2 = filename:join(Src1, "test2.erl"), + Test3 = filename:join(Src2, "test3.erl"), + ?line {ok, _} = file:copy(Test1orig, Test1), + ?line {ok, _} = file:copy(Test2orig, Test2), + ?line {ok, _} = file:copy(Test3orig, Test3), + + %% Create an Emakefile in src1 + Emakefile = filename:join(Src1, "Emakefile"), + ?line {ok, Fd} = file:open(Emakefile, write), + ?line ok = io:write(Fd, {["test1.erl","test2","../src2/test3"], + [{outdir,"../ebin"}]}), + ?line ok = io:fwrite(Fd, ".~n", []), + ?line ok = file:close(Fd), + + ?line ensure_no_messages(), + Config. + +otp_6057_a(suite) -> + []; +otp_6057_a(doc) -> + ["Test that make:all/0 looks for object file in correct place"]; +otp_6057_a(Config) when is_list(Config) -> + ?line PrivDir = ?config(priv_dir, Config), + + %% Go to src1, saving old CWD + ?line {ok, CWD} = file:get_cwd(), + Src1 = filename:join([PrivDir, otp_6057, src1]), + ?line ok = file:set_cwd(Src1), + + %% Call make:all() + ?line up_to_date = make:all(), + + %% Ensure that all beam files are created in the ebin directory + Ebin = filename:join([PrivDir, otp_6057, ebin]), + Test1 = filename:join(Ebin, test1), + Test2 = filename:join(Ebin, test2), + Test3 = filename:join(Ebin, test3), + case ensure_exists([Test1, Test2, Test3]) of + ok -> ok; + Missing -> + ?line ?t:fail({"missing beam file", Missing}) + end, + + %% Check creation date of test1.beam and make sure it is not + %% recompiled if make:all() is called again. + %% (Sleep a while, if the file is recompiled within a second then + %% mtime will be the same). + ?line {ok, FileInfo1} = file:read_file_info(Test1++".beam"), + Date1 = FileInfo1#file_info.mtime, + ?t:sleep(?t:seconds(2)), + ?line up_to_date = make:all(), + ?line {ok, FileInfo2} = file:read_file_info(Test1++".beam"), + case FileInfo2#file_info.mtime of + Date1 -> ok; + _Date2 -> + ?line ?t:fail({"recompiled beam file", Test1++".beam"}) + end, + + %% Remove the beam files + ?line ok = + ensure_removed([Test1++".beam",Test2++".beam",Test2++".beam"]), + + %% Return to original CWD + ?line ok = file:set_cwd(CWD), + + ?line ensure_no_messages(), + ok. + +otp_6057_b(suite) -> + []; +otp_6057_b(doc) -> + ["Test that make:files/1 can handle a file in another directory"]; +otp_6057_b(Config) when is_list(Config) -> + ?line PrivDir = ?config(priv_dir, Config), + + %% Go to src1, saving old CWD + ?line {ok, CWD} = file:get_cwd(), + Src1 = filename:join([PrivDir, otp_6057, src1]), + ?line ok = file:set_cwd(Src1), + + %% Ensure there is no beam file already + Ebin = filename:join([PrivDir, otp_6057, ebin]), + Test3 = filename:join(Ebin, "test3"), + ?line ok = ensure_removed([Test3++".beam"]), + + %% Call make:files/1 + ?line up_to_date = make:files(["../src2/test3"]), + + %% Ensure that the beam file is created in the ebin directory + case ensure_exists([Test3]) of + ok -> ok; + Missing -> + ?line ?t:fail({"missing beam file", Missing}) + end, + + %% Remove the beam file + ?line ok = ensure_removed([Test3++".beam"]), + + %% Return to original CWD + ?line ok = file:set_cwd(CWD), + + ?line ensure_no_messages(), + ok. + +otp_6057_c(suite) -> + []; +otp_6057_c(doc) -> + ["Test that make:files/1 find options in Emakefile if a file is " + "given with the .erl extension there"]; +otp_6057_c(Config) when is_list(Config) -> + ?line PrivDir = ?config(priv_dir, Config), + + %% Go to src1, saving old CWD + ?line {ok, CWD} = file:get_cwd(), + Src1 = filename:join([PrivDir, otp_6057, src1]), + ?line ok = file:set_cwd(Src1), + + %% Ensure there are no beam files already + Ebin = filename:join([PrivDir, otp_6057, ebin]), + Test1 = filename:join(Ebin, "test1"), + Test2 = filename:join(Ebin, "test2"), + ?line ok = ensure_removed([Test1++".beam",Test2++".beam"]), + + %% Call make:files/1 + ?line up_to_date = make:files([test1, test2]), + + %% Ensure that the beam files are created in the ebin directory + Ebin = filename:join([PrivDir, otp_6057, ebin]), + case ensure_exists([Test1, Test2]) of + ok -> ok; + Missing -> + ?line ?t:fail({"missing beam file", Missing}) + end, + + %% Remove the beam files + ?line ok = ensure_removed([Test1++".beam", Test2++".beam"]), + + %% Return to original CWD + ?line ok = file:set_cwd(CWD), + + ?line ensure_no_messages(), + ok. + +otp_6057_end(Config) when is_list(Config) -> + Config. + +ensure_removed([File|Files]) -> + file:delete(File), + ensure_removed(Files); +ensure_removed([]) -> + ok. + +ensure_no_messages() -> + ensure_no_messages(0). + +ensure_no_messages(N) -> + receive + Any -> + io:format("Unexpected message: ~p", [Any]), + ensure_no_messages(N+1) + after 0 -> + case N of + 0 -> ok; + N -> ?t:fail() + end + end. + diff --git a/lib/tools/test/make_SUITE_data/Emakefile b/lib/tools/test/make_SUITE_data/Emakefile new file mode 100644 index 0000000000..ae9abb3cbe --- /dev/null +++ b/lib/tools/test/make_SUITE_data/Emakefile @@ -0,0 +1,20 @@ +%% ``The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved via the world wide web at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. +%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings +%% AB. All Rights Reserved.'' +%% +%% $Id$ +%% + +{test5,['S']}. +'*'. diff --git a/lib/tools/test/make_SUITE_data/test1.erl b/lib/tools/test/make_SUITE_data/test1.erl new file mode 100644 index 0000000000..f4a133008e --- /dev/null +++ b/lib/tools/test/make_SUITE_data/test1.erl @@ -0,0 +1,10 @@ +-module(test1). +-copyright('Copyright (c) 1991-97 Ericsson Telecom AB'). +-vsn('$Revision: /main/release/2 $'). +-compile(export_all). + +f1() -> + true. + +f2() -> + true. diff --git a/lib/tools/test/make_SUITE_data/test2.erl b/lib/tools/test/make_SUITE_data/test2.erl new file mode 100644 index 0000000000..5845357c3e --- /dev/null +++ b/lib/tools/test/make_SUITE_data/test2.erl @@ -0,0 +1,10 @@ +-module(test2). +-copyright('Copyright (c) 1991-97 Ericsson Telecom AB'). +-vsn('$Revision: /main/release/2 $'). +-compile(export_all). + +f1() -> + true. + +f2() -> + true. diff --git a/lib/tools/test/make_SUITE_data/test3.erl b/lib/tools/test/make_SUITE_data/test3.erl new file mode 100644 index 0000000000..4339260ecb --- /dev/null +++ b/lib/tools/test/make_SUITE_data/test3.erl @@ -0,0 +1,10 @@ +-module(test3). +-copyright('Copyright (c) 1991-97 Ericsson Telecom AB'). +-vsn('$Revision: /main/release/2 $'). +-compile(export_all). + +f1() -> + true. + +f2() -> + true. diff --git a/lib/tools/test/make_SUITE_data/test4.erl b/lib/tools/test/make_SUITE_data/test4.erl new file mode 100644 index 0000000000..11b37123f1 --- /dev/null +++ b/lib/tools/test/make_SUITE_data/test4.erl @@ -0,0 +1,10 @@ +-module(test4). +-copyright('Copyright (c) 1991-97 Ericsson Telecom AB'). +-vsn('$Revision: /main/release/2 $'). +-compile(export_all). + +f1() -> + true. + +f2() -> + true. diff --git a/lib/tools/test/make_SUITE_data/test5.erl b/lib/tools/test/make_SUITE_data/test5.erl new file mode 100644 index 0000000000..108ab8e494 --- /dev/null +++ b/lib/tools/test/make_SUITE_data/test5.erl @@ -0,0 +1,10 @@ +-module(test5). +-copyright('Copyright (c) 1991-97 Ericsson Telecom AB'). +-vsn('$Revision: /main/release/1'). +-compile(export_all). + +f1() -> + true. + +f2() -> + true. diff --git a/lib/tools/test/tools.spec b/lib/tools/test/tools.spec new file mode 100644 index 0000000000..93d5930472 --- /dev/null +++ b/lib/tools/test/tools.spec @@ -0,0 +1 @@ +{topcase, {dir, "../tools_test"}}. diff --git a/lib/tools/test/tools.spec.win b/lib/tools/test/tools.spec.win new file mode 100644 index 0000000000..b43d542ff1 --- /dev/null +++ b/lib/tools/test/tools.spec.win @@ -0,0 +1,2 @@ +{topcase, {dir, "../tools_test"}}. +{skip, {emem_SUITE, "Not on windows, yet. FIXME!!!"}}. diff --git a/lib/tools/test/tools_SUITE.erl b/lib/tools/test/tools_SUITE.erl new file mode 100644 index 0000000000..6b952f10ab --- /dev/null +++ b/lib/tools/test/tools_SUITE.erl @@ -0,0 +1,56 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +-module(tools_SUITE). + +-include("test_server.hrl"). + +%% Default timetrap timeout (set in init_per_testcase). +-define(default_timeout, ?t:minutes(1)). +-define(application, tools). + +%% Test server specific exports +-export([all/1]). +-export([init_per_testcase/2, fin_per_testcase/2]). + +%% Test cases must be exported. +-export([app_test/1]). + +all(doc) -> + []; +all(suite) -> + [app_test]. + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. +fin_per_testcase(_Case, Config) -> + Dog=?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%% +%%% Test cases starts here. +%%% + +app_test(doc) -> + ["Test that the .app file does not contain any `basic' errors"]; +app_test(suite) -> + []; +app_test(Config) when is_list(Config) -> + ?line ?t:app_test(tools, tolerant). diff --git a/lib/tools/test/xref_SUITE.erl b/lib/tools/test/xref_SUITE.erl new file mode 100644 index 0000000000..0bbb3ba0f1 --- /dev/null +++ b/lib/tools/test/xref_SUITE.erl @@ -0,0 +1,2743 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% + +-module(xref_SUITE). + +%-define(debug, true). + +-ifdef(debug). +-define(format(S, A), io:format(S, A)). +-define(line, put(line, ?LINE), ). +-define(config(X,Y), "./log_dir/"). +-define(t,test_server). +-define(datadir, "xref_SUITE_data"). +-define(privdir, "xref_SUITE_priv"). +-define(copydir, "xref_SUITE_priv/datacopy"). +-else. +-include("test_server.hrl"). +-define(format(S, A), ok). +-define(datadir, ?config(data_dir, Conf)). +-define(privdir, ?config(priv_dir, Conf)). +-define(copydir, ?config(copy_dir, Conf)). +-endif. + +-export([all/1, init/1, fini/1]). + +-export([xref/1, + addrem/1, convert/1, intergraph/1, lines/1, loops/1, + no_data/1, modules/1]). + +-export([files/1, + add/1, default/1, info/1, lib/1, read/1, read2/1, remove/1, + replace/1, update/1, deprecated/1, trycatch/1, + abstract_modules/1, fun_mfa/1, qlc/1]). + +-export([analyses/1, + analyze/1, basic/1, md/1, q/1, variables/1, unused_locals/1]). + +-export([misc/1, + format_error/1, otp_7423/1, otp_7831/1]). + +-import(lists, [append/2, flatten/1, keysearch/3, member/2, sort/1, usort/1]). + +-import(sofs, [converse/1, from_term/1, intersection/2, is_sofs_set/1, + range/1, relation_to_family/1, set/1, to_external/1, + union/2]). + +-export([init_per_testcase/2, fin_per_testcase/2]). + +%% Checks some info counters of a server and some relations that should hold. +-export([check_count/1, check_state/1]). + +-include_lib("kernel/include/file.hrl"). + +-include_lib("tools/src/xref.hrl"). + +all(suite) -> + {conf, init, [xref, files, analyses, misc], fini}. + +init(Conf) when is_list(Conf) -> + DataDir = ?datadir, + PrivDir = ?privdir, + ?line CopyDir = fname(PrivDir, "datacopy"), + ?line TarFile = fname(PrivDir, "datacopy.tgz"), + ?line {ok, Tar} = erl_tar:open(TarFile, [write, compressed]), + ?line ok = erl_tar:add(Tar, DataDir, CopyDir, [compressed]), + ?line ok = erl_tar:close(Tar), + ?line ok = erl_tar:extract(TarFile, [compressed]), + ?line ok = file:delete(TarFile), + [{copy_dir, CopyDir} | Conf]. + +fini(Conf) when is_list(Conf) -> + %% Nothing. + Conf. + +init_per_testcase(_Case, Config) -> + Dog=?t:timetrap(?t:minutes(2)), + [{watchdog, Dog}|Config]. + +fin_per_testcase(_Case, _Config) -> + Dog=?config(watchdog, _Config), + test_server:timetrap_cancel(Dog), + ok. + +xref(suite) -> + [addrem, convert, intergraph, lines, loops, no_data, modules]. + +%% Seems a bit short... +addrem(suite) -> []; +addrem(doc) -> ["Simple test of removing modules"]; +addrem(Conf) when is_list(Conf) -> + S0 = new(), + + F1 = {m1,f1,1}, + F2 = {m2,f1,2}, + + E1 = {F1,F2}, + E2 = {F2,F1}, + + D1 = {F1,12}, + DefAt_m1 = [D1], + X_m1 = [F1], + % L_m1 = [], + XC_m1 = [E1], + LC_m1 = [], + LCallAt_m1 = [], + XCallAt_m1 = [{E1,13}], + Info1 = #xref_mod{name = m1, app_name = [a1]}, + ?line S1 = add_module(S0, Info1, DefAt_m1, X_m1, LCallAt_m1, XCallAt_m1, + XC_m1, LC_m1), + + D2 = {F2,7}, + DefAt_m2 = [D2], + X_m2 = [F2], + % L_m2 = [], + XC_m2 = [E2], + LC_m2 = [], + LCallAt_m2 = [], + XCallAt_m2 = [{E2,96}], + Info2 = #xref_mod{name = m2, app_name = [a2]}, + ?line S2 = add_module(S1, Info2, DefAt_m2, X_m2, LCallAt_m2, XCallAt_m2, + XC_m2, LC_m2), + + ?line S5 = set_up(S2), + + ?line {ok, XMod1, S6} = remove_module(S5, m1), + ?line [a1] = XMod1#xref_mod.app_name, + ?line {ok, XMod2, S6a} = remove_module(S6, m2), + ?line [a2] = XMod2#xref_mod.app_name, + ?line S7 = set_up(S6a), + + ?line AppInfo1 = #xref_app{name = a1, rel_name = [r1]}, + ?line S9 = add_application(S7, AppInfo1), + ?line S10 = set_up(S9), + ?line AppInfo2 = #xref_app{name = a2, rel_name = [r1]}, + ?line _S11 = add_application(S10, AppInfo2), + ok. + +convert(suite) -> []; +convert(doc) -> ["Coercion of data"]; +convert(Conf) when is_list(Conf) -> + S0 = new(), + + F1 = {m1,f1,1}, + F6 = {m1,f2,6}, % X + F2 = {m2,f1,2}, + F3 = {m2,f2,3}, % X + F7 = {m2,f3,7}, % X + F4 = {m3,f1,4}, % X + F5 = {m3,f2,5}, + + UF1 = {m1,f12,17}, + UF2 = {m17,f17,177}, + + E1 = {F1,F3}, % X + E2 = {F6,F7}, % X + E3 = {F2,F6}, % X + E4 = {F1,F4}, % X + E5 = {F4,F5}, + E6 = {F7,F4}, % X + + UE1 = {F2,UF2}, % X + UE2 = {F5,UF1}, % X + + D1 = {F1,12}, + D6 = {F6,3}, + DefAt_m1 = [D1,D6], + X_m1 = [F6], + % L_m1 = [F1], + XC_m1 = [E1,E2,E4], + LC_m1 = [], + LCallAt_m1 = [], + XCallAt_m1 = [{E1,13},{E2,17},{E4,7}], + Info1 = #xref_mod{name = m1, app_name = [a1]}, + ?line S1 = add_module(S0, Info1, DefAt_m1, X_m1, LCallAt_m1, XCallAt_m1, + XC_m1, LC_m1), + + D2 = {F2,7}, + D3 = {F3,9}, + D7 = {F7,19}, + DefAt_m2 = [D2,D3,D7], + X_m2 = [F3,F7], + % L_m2 = [F2], + XC_m2 = [E3,E6,UE1], + LC_m2 = [], + LCallAt_m2 = [], + XCallAt_m2 = [{E3,96},{E6,12},{UE1,77}], + Info2 = #xref_mod{name = m2, app_name = [a2]}, + ?line S2 = add_module(S1, Info2, DefAt_m2, X_m2, LCallAt_m2, XCallAt_m2, + XC_m2, LC_m2), + + D4 = {F4,6}, + D5 = {F5,97}, + DefAt_m3 = [D4,D5], + X_m3 = [F4], + % L_m3 = [F5], + XC_m3 = [UE2], + LC_m3 = [E5], + LCallAt_m3 = [{E5,19}], + XCallAt_m3 = [{UE2,22}], + Info3 = #xref_mod{name = m3, app_name = [a3]}, + ?line S3 = add_module(S2, Info3, DefAt_m3, X_m3, LCallAt_m3, XCallAt_m3, + XC_m3, LC_m3), + + Info4 = #xref_mod{name = m4, app_name = [a2]}, + ?line S4 = add_module(S3, Info4, [], [], [], [], [], []), + + AppInfo1 = #xref_app{name = a1, rel_name = [r1]}, + ?line S9 = add_application(S4, AppInfo1), + AppInfo2 = #xref_app{name = a2, rel_name = [r1]}, + ?line S10 = add_application(S9, AppInfo2), + AppInfo3 = #xref_app{name = a3, rel_name = [r2]}, + ?line S11 = add_application(S10, AppInfo3), + + RelInfo1 = #xref_rel{name = r1}, + ?line S12 = add_release(S11, RelInfo1), + RelInfo2 = #xref_rel{name = r2}, + ?line S13 = add_release(S12, RelInfo2), + + ?line S = set_up(S13), + + ?line {ok, _} = eval("(Lin)(m1->m1:Mod) * m1->m1", type_error, S), + ?line {ok, _} = eval("(XXL)(Lin)(m1->m1:Mod) * m1->m1", type_error, S), + + ?line AllDefAt = eval("(Lin) M", S), + ?line AllV = eval("(Fun) M", S), + ?line AllCallAt = eval("(XXL)(Lin) E", S), + ?line AllE = eval("E", S), + + ?line AM = eval("AM", S), + ?line A = eval("A", S), + ?line R = eval("R", S), + + + % vertices + % general 1 step + ?line {ok, _} = eval("(Fun) (Lin) M", AllV, S), + ?line {ok, _} = eval("(Fun) (Lin) (Lin) M", AllV, S), + ?line {ok, _} = eval(f("(Fun) (Lin) ~p", [[F1, F3]]), [F1,F3], S), + ?line {ok, _} = eval(f("(Mod) ~p", [AllV]), [m1,m17,m2,m3], S), + ?line {ok, _} = eval(f("(Mod) ~p", [[F1,F3,F6]]), [m1,m2], S), + ?line {ok, _} = eval("(App) M", A, S), + ?line {ok, _} = eval(f("(App) ~p", [[m1,m2,m4]]), [a1,a2], S), + ?line {ok, _} = eval(f("(Rel) ~p", [A]), R, S), + ?line {ok, _} = eval(f("(Rel) ~p", [[a1,a2,a2]]), [r1], S), + % general 2 steps + ?line {ok, _} = eval("(Mod) (Lin) M", [m1,m17,m2,m3], S), + ?line {ok, _} = eval(f("(App) ~p", [AllV]), [a1,a2,a3], S), + ?line {ok, _} = eval("(Rel) M", R, S), + % general 4 steps + ?line {ok, _} = eval("(Rel) (Lin) M", [r1,r2], S), + + % special 1 step + ?line {ok, _} = eval(f("(Lin) ~p", [AllV]), AllDefAt, S), + ?line {ok, _} = eval(f("(Lin) ~p", [[F1,F3]]), [{F1,12},{F3,9}], S), + ?line {ok, _} = eval("(Fun) M", AllV, S), + ?line {ok, _} = eval(f("(Fun) ~p", [[m1,m2]]), [F1,F2,F3,F6,F7,UF1], S), + ?line {ok, _} = eval(f("(Mod) ~p", [A]), AM, S), + ?line {ok, _} = eval(f("(Mod) ~p", [[a1,a2]]), [m1,m2,m4], S), + ?line {ok, _} = eval(f("(App) ~p", [R]), A, S), + ?line {ok, _} = eval(f("(App) ~p", [[r1]]), [a1,a2], S), + % special 2 steps + ?line {ok, _} = eval("(Lin) M", AllDefAt, S), + ?line AnalyzedV = eval("(Fun) AM", S), + ?line {ok, _} = eval(f("(Fun) ~p", [A]), AnalyzedV, S), + ?line {ok, _} = eval(f("(Mod) ~p", [R]), AM, S), + % special 4 steps + ?line AnalyzedAllDefAt = eval("(Lin) AM", S), + ?line {ok, _} = eval("(Lin) R", AnalyzedAllDefAt, S), + + % edges + Ms = [{m1,m2},{m1,m3},{m2,m1},{m2,m3},{m3,m3}], + UMs = [{m2,m17},{m3,m1}], + AllMs = append(Ms, UMs), + As = [{a1,a2},{a1,a3},{a2,a1},{a2,a3},{a3,a3}], + Rs = [{r1,r1},{r1,r2},{r2,r2}], + + % general 1 step + ?line {ok, _} = eval("(Fun) (Lin) E", AllE, S), + ?line {ok, _} = eval(f("(Fun)(Lin) ~p", [[E1, E6]]), [E1, E6], S), + ?line {ok, _} = eval("(Mod) E", AllMs, S), + ?line {ok, _} = eval(f("(Mod) ~p", [[E1, E6]]), [{m1,m2},{m2,m3}], S), + ?line {ok, _} = eval(f("(App) ~p", [As]), As, S), + ?line {ok, _} = eval("(App) [m1->m2,m2->m3]", [{a1,a2},{a2,a3}], S), + ?line {ok, _} = eval(f("(Rel) ~p", [As]), Rs, S), + ?line {ok, _} = eval("(Rel) a1->a2", [{r1,r1}], S), + + % special 1 step + ?line {ok, _} = eval("(XXL) (Lin) (Fun) E", AllCallAt, S), + ?line {ok, _} = eval("(XXL) (XXL) (Lin) (Fun) E", AllCallAt, S), + + ?line {ok, _} = eval(f("(XXL) (Lin) ~p", [[E1, E6]]), + [{{D1,D3},[13]}, {{D7,D4},[12]}], S), + ?line {ok, _} = eval(f("(Fun) ~p", [AllMs]), AllE, S), + ?line {ok, _} = eval("(Fun) [m1->m2,m2->m3]", [E1,E2,E6], S), + ?line {ok, _} = eval(f("(Mod) ~p", [As]), Ms, S), + ?line {ok, _} = eval("(Mod) [a1->a2,a2->a3]", [{m1,m2},{m2,m3}], S), + ?line {ok, _} = eval(f("(App) ~p", [Rs]), As, S), + ?line {ok, _} = eval("(App) r1->r1", [{a1,a2},{a2,a1}], S), + ok. + +intergraph(suite) -> []; +intergraph(doc) -> ["Inter Call Graph"]; +intergraph(Conf) when is_list(Conf) -> + S0 = new(), + + F1 = {m1,f1,1}, % X + F2 = {m1,f2,2}, % X + F3 = {m1,f3,3}, + F4 = {m1,f4,4}, + F5 = {m1,f5,5}, + + F6 = {m2,f1,6}, % X + F7 = {m2,f1,7}, + F8 = {m2,f1,8}, + F9 = {m2,f1,9}, + F10 = {m2,f1,10}, + F11 = {m2,f1,11}, + + % Note: E1 =:= E4! + E1 = {F2,F1}, + E2 = {F2,F3}, + E3 = {F3,F1}, + E4 = {F2,F1}, % X + E5 = {F4,F2}, + E6 = {F5,F4}, + E7 = {F4,F5}, + + E8 = {F6,F7}, + E9 = {F7,F8}, + E10 = {F8,F1}, % X + E11 = {F6,F9}, + E12 = {F6,F10}, + E13 = {F9,F11}, + E14 = {F10,F11}, + E15 = {F11,F1}, % X + + D1 = {F1,1}, + D2 = {F2,2}, + D3 = {F3,3}, + D4 = {F4,4}, + D5 = {F5,5}, + DefAt_m1 = [D1,D2,D3,D4,D5], + X_m1 = [F1,F2], + % L_m1 = [F3,F4,F5], + XC_m1 = [E4], + LC_m1 = [E1,E2,E3,E5,E6,E7], + % Note: E1 and E4 together! + LCallAt_m1 = [{E1,1},{E2,2},{E3,3},{E5,5},{E6,6},{E7,7}], + XCallAt_m1 = [{E1,4}], + Info1 = #xref_mod{name = m1, app_name = [a1]}, + ?line S1 = add_module(S0, Info1, DefAt_m1, X_m1, LCallAt_m1, XCallAt_m1, + XC_m1, LC_m1), + + D6 = {F6,6}, + D7 = {F7,7}, + D8 = {F8,8}, + D9 = {F9,9}, + D10 = {F10,10}, + D11 = {F11,11}, + DefAt_m2 = [D6,D7,D8,D9,D10,D11], + X_m2 = [F6], + % L_m2 = [F7,F8,F9,F10,F11], + XC_m2 = [E10,E15], + LC_m2 = [E8,E9,E11,E12,E13,E14], + LCallAt_m2 = [{E8,8},{E9,9},{E11,11},{E12,12},{E13,13},{E14,14}], + XCallAt_m2 = [{E10,10},{E15,15}], + Info2 = #xref_mod{name = m2, app_name = [a2]}, + ?line S2 = add_module(S1, Info2, DefAt_m2, X_m2, LCallAt_m2, XCallAt_m2, + XC_m2, LC_m2), + + AppInfo1 = #xref_app{name = a1, rel_name = [r1]}, + ?line S5 = add_application(S2, AppInfo1), + AppInfo2 = #xref_app{name = a2, rel_name = [r1]}, + ?line S6 = add_application(S5, AppInfo2), + + RelInfo = #xref_rel{name = r1}, + ?line S7 = add_release(S6, RelInfo), + + ?line S = set_up(S7), + + ?line {ok, _} = eval("EE | m1", [E1,E5,E6,E7], S), + ?line {ok, _} = eval("EE | m2", [{F6,F1}], S), + ?line {ok, _} = eval("EE | m2 + EE | m2", [{F6,F1}], S), + + ?line {ok, _} = eval("(Fun)(Lin)(E | m1)", + to_external(union(set(XC_m1), set(LC_m1))), S), + ?line {ok, _} = eval("(XXL)(ELin) (EE | m1)", + [{{D2,D1},[1,2,4]},{{D4,D2},[5]},{{D5,D4},[6]},{{D4,D5},[7]}], + S), + ?line {ok, _} = eval("(XXL)(ELin)(EE | m2)", [{{D6,D1},[8,11,12]}], S), + ?line {ok, _} = eval("(XXL)(ELin)(ELin)(EE | m2)", + [{{D6,D1},[8,11,12]}], S), + + %% Combining graphs (equal or different): + ?line {ok, _} = eval("(XXL)(ELin)(EE | m2 + EE | m2)", + [{{D6,D1},[8,11,12]}], S), + ?line {ok, _} = eval("(XXL)(ELin)(EE | m2 * EE | m2)", + [{{D6,D1},[8,11,12]}], S), + ?line {ok, _} = eval("(XXL)(ELin)(EE | m2 - EE | m1)", + [{{D6,D1},[8,11,12]}], S), + ?line {ok, _} = eval("(XXL)(ELin)(EE | m2 - E | m2)", + [{{D6,D1},[8,11,12]}], S), + ?line {ok, _} = eval("(XXL)(ELin)(Fun)(ELin)(EE | m2)", + [{{D6,D1},[8,11,12]}], S), + ?line {ok, _} = eval("EE | m1 + E | m1", LC_m1, S), + ?line {ok, _} = eval(f("EE | ~p + E | ~p", [F2, F2]), [E1,E2], S), + %% [1,4] from 'calls' is a subset of [1,2,4] from Inter Call Graph: + ?line {ok, _} = eval(f("(XXL)(Lin) (E | ~p)", [F2]), + [{{D2,D1},[1,4]},{{D2,D3},[2]}], S), + + ?line {ok, _} = eval(f("(XXL)(ELin) (EE | ~p)", [F2]), + [{{D2,D1},[1,2,4]}], S), + ?line {ok, _} = eval(f("(XXL)((ELin)(EE | ~p) + (Lin)(E | ~p))", [F2, F2]), + [{{D2,D1},[1,2,4]},{{D2,D3},[2]}], S), + ?line {ok, _} = + eval(f("(XXL)((ELin) ~p + (Lin) ~p)", [{F2, F1}, {F2, F1}]), + [{{D2,D1},[1,2,4]}], S), + ?line {ok, _} = eval(f("(Fun)(Lin) ~p", [{F2, F1}]), [E1], S), + %% The external call E4 is included in the reply: + ?line {ok, _} = eval("(XXL)(Lin)(LC | m1)", + [{{D2,D1},[1,4]},{{D2,D3},[2]},{{D3,D1},[3]}, + {{D4,D2},[5]},{{D4,D5},[7]},{{D5,D4},[6]}], S), + %% The local call E1 is included in the reply: + ?line {ok, _} = eval("(XXL)(Lin)(XC | m1)", [{{D2,D1},[1,4]}], S), + + ?line {ok, _} = eval(f("(LLin) (E | ~p || ~p) + (XLin) (E | ~p || ~p)", + [F2, F1, F2, F1]), [{E4,[1,4]}], S), + + ?line {ok, _} = eval("# (ELin) E", 6, S), + + ok. + +lines(suite) -> []; +lines(doc) -> ["More test of Inter Call Graph, and regular expressions"]; +lines(Conf) when is_list(Conf) -> + S0 = new(), + + F1 = {m1,f1,1}, % X + F2 = {m1,f2,2}, + F3 = {m1,f3,3}, + F4 = {m2,f4,4}, % X + F5 = {m1,f5,5}, % X + F6 = {m1,f6,6}, + + E1 = {F1,F2}, + E2 = {F2,F1}, % X + E3 = {F3,F2}, + E4 = {F1,F4}, % X + E5 = {F2,F4}, % X + E6 = {F5,F6}, + E7 = {F6,F4}, % X + + D1 = {F1,1}, + D2 = {F2,2}, + D3 = {F3,3}, + D4 = {F4,4}, + D5 = {F5,5}, + D6 = {F6,6}, + + DefAt_m1 = [D1,D2,D3,D5,D6], + X_m1 = [F1,F5], + % L_m1 = [F2,F3,F6], + XC_m1 = [E4,E5,E7], + LC_m1 = [E1,E2,E3,E6], + LCallAt_m1 = [{E1,1},{E3,3},{E6,6}], + XCallAt_m1 = [{E2,2},{E4,4},{E5,5},{E7,7}], + Info1 = #xref_mod{name = m1, app_name = [a1]}, + ?line S1 = add_module(S0, Info1, DefAt_m1, X_m1, LCallAt_m1, XCallAt_m1, + XC_m1, LC_m1), + + DefAt_m2 = [D4], + X_m2 = [F4], + % L_m2 = [], + XC_m2 = [], + LC_m2 = [], + LCallAt_m2 = [], + XCallAt_m2 = [], + Info2 = #xref_mod{name = m2, app_name = [a2]}, + ?line S2 = add_module(S1, Info2, DefAt_m2, X_m2, LCallAt_m2, XCallAt_m2, + XC_m2, LC_m2), + + AppInfo1 = #xref_app{name = a1, rel_name = [r1]}, + ?line S5 = add_application(S2, AppInfo1), + AppInfo2 = #xref_app{name = a2, rel_name = [r1]}, + ?line S6 = add_application(S5, AppInfo2), + + RelInfo = #xref_rel{name = r1}, + ?line S7 = add_release(S6, RelInfo), + + ?line S = set_up(S7), + + ?line {ok, _} = eval("(XXL) (ELin) (EE | m1)", + [{{D1,D1},[1]},{{D1,D4},[1,4]},{{D3,D1},[3]},{{D3,D4},[3]}, + {{D5,D4},[6]}], S), + ?line {ok, _} = eval("(XXL)(Lin) (E | m1)", + [{{D1,D2},[1]},{{D1,D4},[4]},{{D2,D1},[2]}, + {{D2,D4},[5]},{{D3,D2},[3]},{{D5,D6},[6]},{{D6,D4},[7]}], + S), + ?line {ok, _} = eval("(E | m1) + (EE | m1)", + [E1,E2,E3,E4,E5,E6,E7,{F1,F1},{F3,F1},{F3,F4},{F5,F4}], + S), + ?line {ok, _} = eval("(Lin)(E | m1)", + [{E4,[4]},{E1,[1]},{E2,[2]},{E5,[5]}, + {E3,[3]},{E7,[7]},{E6,[6]}], S), + ?line {ok, _} = eval("(ELin)(EE | m1)", + [{{F1,F1},[1]},{{F1,F4},[1,4]},{{F3,F1},[3]},{{F3,F4},[3]}, + {{F5,F4},[6]}], S), + ?line {ok, _} = eval("(Lin)(E | m1) + (ELin)(EE | m1)", + [{E4,[1,4]},{E1,[1]},{E2,[2]},{E5,[5]}, + {E3,[3]},{E7,[7]},{E6,[6]}, + {{F1,F1},[1]},{{F3,F1},[3]},{{F3,F4},[3]}, + {{F5,F4},[6]}], S), + ?line {ok, _} = eval("(Lin)(E | m1) - (ELin)(EE | m1)", + [{E1,[1]},{E2,[2]},{E5,[5]}, + {E3,[3]},{E7,[7]},{E6,[6]}], S), + ?line {ok, _} = eval("(Lin)(E | m1) * (ELin)(EE | m1)", + [{E4,[4]}], S), + ?line {ok, _} = eval("(XXL)(Lin) (E | m1)", + [{{D1,D4},[4]},{{D1,D2},[1]},{{D2,D1},[2]},{{D2,D4},[5]}, + {{D3,D2},[3]},{{D6,D4},[7]},{{D5,D6},[6]}], S), + ?line {ok, _} = eval("(XXL)(ELin) (EE | m1)", + [{{D1,D1},[1]},{{D1,D4},[1,4]},{{D3,D1},[3]},{{D3,D4},[3]}, + {{D5,D4},[6]}], S), + ?line {ok, _} = eval("(XXL)(Lin)(Fun)(Lin) (E | m1)", + [{{D1,D4},[4]},{{D1,D2},[1]},{{D2,D1},[2]},{{D2,D4},[5]}, + {{D3,D2},[3]},{{D6,D4},[7]},{{D5,D6},[6]}], S), + ?line {ok, _} = eval("(XXL)(ELin)(Fun)(ELin) (EE | m1)", + [{{D1,D1},[1]},{{D1,D4},[1,4]},{{D3,D1},[3]},{{D3,D4},[3]}, + {{D5,D4},[6]}], S), + + %% A few tests on regexp. + ?line {ok, _} = eval("\"(foo\":Mod", parse_error, S), + ?line {ok, _} = eval("_Foo:_/_", parse_error, S), + ?line {ok, _} = eval("\".*foo\"", parse_error, S), + ?line {ok, _} = eval("_:_/_:Lin", parse_error, S), + ?line {ok, _} = eval("_:_/_:Mod", parse_error, S), + ?line {ok, _} = eval("_:_/_:App", parse_error, S), + ?line {ok, _} = eval("_:_/_:Rel", parse_error, S), + ?line {ok, _} = eval("m2:_/4", [F4], S), + ?line {ok, _} = eval("m2:_/4:Fun", [F4], S), + ?line {ok, _} = eval("\"m.?\":\"f.*\"/\"6\"", [F6], S), + ?line {ok, _} = eval("_:_/6", [F6], S), + ?line {ok, _} = eval("m1:\"f1\"/_", [F1], S), + ?line {ok, _} = eval("\"m1\":f1/_", [F1], S), + ?line {ok, _} = eval("\"m1\":Mod", [m1], S), + ?line {ok, _} = eval("\"a1\":App", [a1], S), + ?line {ok, _} = eval("\"r1\":Rel", [r1], S), + ?line {ok, _} = eval("_:_/-1", [], S), + + ok. + +loops(suite) -> []; +loops(doc) -> ["More Inter Call Graph, loops and \"unusual\" cases"]; +loops(Conf) when is_list(Conf) -> + S0 = new(), + + F1 = {m1,f1,1}, % X + F2 = {m1,f2,2}, + F3 = {m1,f3,3}, % X + F4 = {m1,f4,4}, + F5 = {m1,f5,5}, + F6 = {m1,f1,6}, % X + F7 = {m1,f1,7}, + + E1 = {F1,F1}, % X + E2 = {F2,F2}, + E3 = {F3,F4}, + E4 = {F4,F5}, + E5 = {F5,F3}, % X + + D1 = {F1,1}, + D2 = {F2,2}, + D3 = {F3,3}, + D4 = {F4,4}, + D5 = {F5,5}, + D6 = {F6,6}, + D7 = {F7,7}, + DefAt_m1 = [D1,D2,D3,D4,D5,D6,D7], + X_m1 = [F1,F3,F6], + % L_m1 = [F2,F4,F5], + XC_m1 = [], + LC_m1 = [E1,E2,E3,E4,E5], + LCallAt_m1 = [{E2,2},{E3,3},{E4,4}], + XCallAt_m1 = [{E1,1},{E5,5}], + Info1 = #xref_mod{name = m1, app_name = [a1]}, + ?line S1 = add_module(S0, Info1, DefAt_m1, X_m1, LCallAt_m1, XCallAt_m1, + XC_m1, LC_m1), + + ?line S = set_up(S1), + + % Neither F6 nor F7 is included. Perhaps one should change that? + ?line {ok, _} = eval("EE | m1", [E1,E2,{F3,F3}], S), + ?line {ok, _} = eval(f("(XXL)(ELin) (EE | ~p)", [F3]), [{{D3,D3},[3]}], S), + + ?line {ok, _} = eval("m1->m1 | m1->m1", type_error, S), + ?line {ok, _} = eval(f("~p | ~p", [F2, F1]), type_error, S), + + ?line {ok, _} = eval(f("range (closure EE | ~p)", [F1]), [F1], S), + ?line {ok, _} = eval(f("domain (closure EE || ~p)", [F3]), [F3], S), + + ?line {ok, _} = eval(f("domain (closure E || ~p)", [F3]), [F3,F4,F5], S), + + ?line {ok, _} = eval("components E", [[F1],[F2],[F3,F4,F5]], S), + ?line {ok, _} = eval("components EE", [[F1],[F2],[F3]], S), + + ok. + +no_data(suite) -> []; +no_data(doc) -> ["Simple tests when there is no data"]; +no_data(Conf) when is_list(Conf) -> + S0 = new(), + ?line S1 = set_up(S0), + ?line {ok, _} = eval("M", [], S1), + ?line {ok, _} = eval("A", [], S1), + ?line {ok, _} = eval("R", [], S1), + + ModInfo = #xref_mod{name = m, app_name = []}, + ?line S2 = add_module(S1, ModInfo, [], [], [], [], [], []), + AppInfo = #xref_app{name = a, rel_name = []}, + ?line S3 = add_application(S2, AppInfo), + RelInfo = #xref_rel{name = r, dir = ""}, + ?line S4 = add_release(S3, RelInfo), + ?line S5 = set_up(S4), + ?line {ok, _} = eval("M", [m], S5), + ?line {ok, _} = eval("A", [a], S5), + ?line {ok, _} = eval("R", [r], S5), + ok. + +modules(suite) -> []; +modules(doc) -> ["Modules mode"]; +modules(Conf) when is_list(Conf) -> + CopyDir = ?copydir, + Dir = fname(CopyDir, "rel2"), + X = fname(Dir, "x.erl"), + Y = fname(Dir, "y.erl"), + A1_1 = fname([Dir,"lib","app1-1.1"]), + A2 = fname([Dir,"lib","app2-1.1"]), + EB1_1 = fname(A1_1, "ebin"), + EB2 = fname(A2, "ebin"), + Xbeam = fname(EB2, "x.beam"), + Ybeam = fname(EB1_1, "y.beam"), + + ?line {ok, x} = compile:file(X, [debug_info, {outdir,EB2}]), + ?line {ok, y} = compile:file(Y, [debug_info, {outdir,EB1_1}]), + + ?line {ok, S0} = xref_base:new([{xref_mode, modules}]), + ?line {ok, release2, S1} = + xref_base:add_release(S0, Dir, [{name,release2}]), + ?line S = set_up(S1), + ?line {{error, _, {unavailable_analysis, undefined_function_calls}}, _} = + xref_base:analyze(S, undefined_function_calls), + ?line {{error, _, {unavailable_analysis, locals_not_used}}, _} = + xref_base:analyze(S, locals_not_used), + ?line {{error, _, {unavailable_analysis, {call, foo}}}, _} = + xref_base:analyze(S, {call, foo}), + ?line {{error, _, {unavailable_analysis, {use, foo}}}, _} = + xref_base:analyze(S, {use, foo}), + ?line analyze(undefined_functions, [{x,undef,0}], S), + ?line 5 = length(xref_base:info(S)), + + %% More: all info, conversions. + + ?line ok = file:delete(Xbeam), + ?line ok = file:delete(Ybeam), + ?line ok = xref_base:delete(S), + ok. + +files(suite) -> + [add, default, info, lib, read, read2, remove, replace, update, + deprecated, trycatch, abstract_modules, fun_mfa, qlc]. + +add(suite) -> []; +add(doc) -> ["Add modules, applications, releases, directories"]; +add(Conf) when is_list(Conf) -> + CopyDir = ?copydir, + Dir = fname(CopyDir, "rel2"), + UDir = fname([CopyDir,"dir","unreadable"]), + DDir = fname(CopyDir,"dir"), + UFile = fname([DDir, "dir","unreadable.beam"]), + X = fname(Dir, "x.erl"), + Y = fname(Dir, "y.erl"), + A1_1 = fname([Dir,"lib","app1-1.1"]), + A2 = fname([Dir,"lib","app2-1.1"]), + EB1_1 = fname(A1_1, "ebin"), + EB2 = fname(A2, "ebin"), + Xbeam = fname(EB2, "x.beam"), + Ybeam = fname(EB1_1, "y.beam"), + + ?line {ok, x} = compile:file(X, [debug_info, {outdir,EB2}]), + ?line {ok, y} = compile:file(Y, [debug_info, {outdir,EB1_1}]), + + ?line case os:type() of + {unix, _} -> + ?line make_udir(UDir), + ?line make_ufile(UFile); + _ -> + true + end, + + ?line {error, _, {invalid_options,[not_an_option] }} = + xref_base:new([not_an_option]), + ?line {error, _, {invalid_options,[{verbose,not_a_value}] }} = + xref_base:new([{verbose,not_a_value}]), + ?line S = new(), + ?line {error, _, {invalid_options,[not_an_option]}} = + xref_base:set_up(S, [not_an_option]), + ?line {error, _, {invalid_options,[{builtins,true},not_an_option]}} = + xref_base:add_directory(S, foo, [{builtins,true},not_an_option]), + ?line {error, _, {invalid_options,[{builtins,not_a_value}]}} = + xref_base:add_directory(S, foo, [{builtins,not_a_value}]), + ?line {error, _, {invalid_filename,{foo,bar}}} = + xref_base:add_directory(S, {foo,bar}, []), + ?line {error, _, {invalid_options,[{builtins,true},not_an_option]}} = + xref_base:add_module(S, foo, [{builtins,true},not_an_option]), + ?line {error, _, {invalid_options,[{builtins,not_a_value}]}} = + xref_base:add_module(S, foo, [{builtins,not_a_value}]), + ?line {error, _, {invalid_filename,{foo,bar}}} = + xref_base:add_module(S, {foo,bar}, []), + ?line {error, _, {invalid_options,[{builtins,true},not_an_option]}} = + xref_base:add_application(S, foo, [{builtins,true},not_an_option]), + ?line {error, _, {invalid_options,[{builtins,not_a_value}]}} = + xref_base:add_application(S, foo, [{builtins,not_a_value}]), + ?line {error, _, {invalid_filename,{foo,bar}}} = + xref_base:add_application(S, {foo,bar}, []), + ?line {error, _, {invalid_options,[not_an_option]}} = + xref_base:add_release(S, foo, [not_an_option]), + ?line {error, _, {invalid_options,[{builtins,not_a_value}]}} = + xref_base:add_release(S, foo, [{builtins,not_a_value}]), + ?line {error, _, {invalid_filename,{foo,bar}}} = + xref_base:add_release(S, {foo,bar}, []), + ?line {ok, S1} = + xref_base:set_default(S, [{verbose,false}, {warnings, false}]), + ?line case os:type() of + {unix, _} -> + ?line {error, _, {file_error, _, _}} = + xref_base:add_release(S, UDir); + _ -> + true + end, + ?line {error, _, {file_error, _, _}} = + xref_base:add_release(S, fname(["/a/b/c/d/e/f","__foo"])), + ?line {ok, release2, S2} = + xref_base:add_release(S1, Dir, [{name,release2}]), + ?line {error, _, {module_clash, {x, _, _}}} = + xref_base:add_module(S2, Xbeam), + ?line {ok, S3} = xref_base:remove_release(S2, release2), + ?line {ok, rel2, S4} = xref_base:add_release(S3, Dir), + ?line {error, _, {release_clash, {rel2, _, _}}} = + xref_base:add_release(S4, Dir), + ?line {ok, S5} = xref_base:remove_release(S4, rel2), + %% One unreadable file and one JAM file found (no verification here): + ?line {ok, [], S6} = xref_base:add_directory(S5, fname(CopyDir,"dir"), + [{recurse,true}, {warnings,true}]), + ?line case os:type() of + {unix, _} -> + ?line {error, _, {file_error, _, _}} = + xref_base:add_directory(S6, UDir); + _ -> + true + end, + ?line {ok, app1, S7} = xref_base:add_application(S6, A1_1), + ?line {error, _, {application_clash, {app1, _, _}}} = + xref_base:add_application(S7, A1_1), + ?line {ok, S8} = xref_base:remove_application(S7, app1), + ?line ok = xref_base:delete(S8), + ?line ok = file:delete(Xbeam), + ?line ok = file:delete(Ybeam), + ?line case os:type() of + {unix, _} -> + ?line ok = file:del_dir(UDir), + ?line ok = file:delete(UFile); + _ -> + true + end, + ok. + +default(suite) -> []; +default(doc) -> ["Default values of options"]; +default(Conf) when is_list(Conf) -> + S = new(), + ?line {error, _, {invalid_options,[not_an_option]}} = + xref_base:set_default(S, not_an_option, true), + ?line {error, _, {invalid_options,[{builtins, not_a_value}]}} = + xref_base:set_default(S, builtins, not_a_value), + ?line {error, _, {invalid_options,[not_an_option]}} = + xref_base:get_default(S, not_an_option), + ?line {error, _, {invalid_options,[not_an_option]}} = + xref_base:set_default(S, [not_an_option]), + + ?line D = xref_base:get_default(S), + ?line [{builtins,false},{recurse,false},{verbose,false},{warnings,true}] = + D, + + ?line ok = xref_base:delete(S), + ok. + +info(suite) -> []; +info(doc) -> ["The info functions"]; +info(Conf) when is_list(Conf) -> + CopyDir = ?copydir, + Dir = fname(CopyDir,"rel2"), + LDir = fname(CopyDir,"lib_test"), + X = fname(Dir, "x.erl"), + Y = fname(Dir, "y.erl"), + A1_1 = fname([Dir,"lib","app1-1.1"]), + A2 = fname([Dir,"lib","app2-1.1"]), + EB1_1 = fname(A1_1, "ebin"), + EB2 = fname(A2, "ebin"), + Xbeam = fname(EB2, "x.beam"), + Ybeam = fname(EB1_1, "y.beam"), + + ?line {ok, x} = compile:file(X, [debug_info, {outdir,EB2}]), + ?line {ok, y} = compile:file(Y, [debug_info, {outdir,EB1_1}]), + + ?line {ok, _} = start(s), + ?line {error, _, {no_such_info, release}} = xref:info(s, release), + ?line {error, _, {no_such_info, release}} = xref:info(s, release, rel), + ?line {error, _, {no_such_module, mod}} = xref:info(s, modules, mod), + ?line {error, _, {no_such_application, app}} = + xref:info(s, applications, app), + ?line {error, _, {no_such_release, rel}} = xref:info(s, releases, rel), + ?line ok = xref:set_default(s, [{verbose,false}, {warnings, false}]), + ?line {ok, rel2} = xref:add_release(s, Dir), + ?line 9 = length(xref:info(s)), + ?line [{x,_}, {y, _}] = xref:info(s, modules), + ?line [{app1,_}, {app2, _}] = xref:info(s, applications), + ?line [{rel2,_}] = xref:info(s, releases), + ?line [] = xref:info(s, libraries), + ?line [{x,_}] = xref:info(s, modules, x), + ?line [{rel2,_}] = xref:info(s, releases, rel2), + ?line {error, _, {no_such_library, foo}} = xref:info(s, libraries, [foo]), + + ?line {ok, lib1} = + compile:file(fname(LDir,lib1),[debug_info,{outdir,LDir}]), + ?line {ok, lib2} = + compile:file(fname(LDir,lib2),[debug_info,{outdir,LDir}]), + ?line ok = xref:set_library_path(s, [LDir], [{verbose,false}]), + ?line [{lib1,_}, {lib2, _}] = xref:info(s, libraries), + ?line [{lib1,_}, {lib2, _}] = xref:info(s, libraries, [lib1,lib2]), + ?line ok = file:delete(fname(LDir, "lib1.beam")), + ?line ok = file:delete(fname(LDir, "lib2.beam")), + + ?line check_state(s), + + ?line xref:stop(s), + + ?line ok = file:delete(Xbeam), + ?line ok = file:delete(Ybeam), + + ok. + +lib(suite) -> []; +lib(doc) -> ["Library modules"]; +lib(Conf) when is_list(Conf) -> + CopyDir = ?copydir, + Dir = fname(CopyDir,"lib_test"), + UDir = fname([CopyDir,"dir","non_existent"]), + + ?line {ok, lib1} = compile:file(fname(Dir,lib1),[debug_info,{outdir,Dir}]), + ?line {ok, lib2} = compile:file(fname(Dir,lib2),[debug_info,{outdir,Dir}]), + ?line {ok, lib3} = compile:file(fname(Dir,lib3),[debug_info,{outdir,Dir}]), + ?line {ok, t} = compile:file(fname(Dir,t),[debug_info,{outdir,Dir}]), + + ?line {ok, _} = start(s), + ?line ok = xref:set_default(s, [{verbose,false}, {warnings, false}]), + ?line {ok, t} = xref:add_module(s, fname(Dir,"t.beam")), + ?line {error, _, {invalid_options,[not_an_option]}} = + xref:set_library_path(s, ["foo"], [not_an_option]), + ?line {error, _, {invalid_path,otp}} = xref:set_library_path(s,otp), + ?line {error, _, {invalid_path,[""]}} = xref:set_library_path(s,[""]), + ?line {error, _, {invalid_path,[[$a | $b]]}} = + xref:set_library_path(s,[[$a | $b]]), + ?line {error, _, {invalid_path,[otp]}} = xref:set_library_path(s,[otp]), + ?line {ok, []} = xref:get_library_path(s), + ?line ok = xref:set_library_path(s, [Dir], [{verbose,false}]), + ?line {ok, UnknownFunctions} = xref:q(s, "U"), + ?line [{lib1,unknown,0}, {lib2,local,0}, + {lib2,unknown,0}, {unknown,unknown,0}] + = UnknownFunctions, + ?line {ok, [{lib2,f,0},{lib3,f,0}]} = xref:q(s, "DF"), + ?line {ok, []} = xref:q(s, "DF_1"), + ?line {ok, [{lib2,f,0}]} = xref:q(s, "DF_2"), + ?line {ok, [{lib2,f,0}]} = xref:q(s, "DF_3"), + + ?line {ok, [unknown]} = xref:q(s, "UM"), + ?line {ok, UnknownDefAt} = xref:q(s, "(Lin)U"), + ?line [{{lib1,unknown,0},0},{{lib2,local,0},0}, {{lib2,unknown,0},0}, + {{unknown,unknown,0},0}] = UnknownDefAt, + ?line {ok, LibFuns} = xref:q(s, "X * LM"), + ?line [{lib2,f,0},{lib3,f,0}] = LibFuns, + ?line {ok, LibMods} = xref:q(s, "LM"), + ?line [lib1,lib2,lib3] = LibMods, + ?line {ok, [{{lib2,f,0},0},{{lib3,f,0},0}]} = xref:q(s, "(Lin) (LM * X)"), + ?line {ok, [{{lib1,unknown,0},0}, {{lib2,f,0},0}, {{lib2,local,0},0}, + {{lib2,unknown,0},0}, {{lib3,f,0},0}]} = xref:q(s,"(Lin)LM"), + ?line {ok,[lib1,lib2,lib3,t,unknown]} = xref:q(s,"M"), + ?line {ok,[{lib2,f,0},{lib3,f,0},{t,t,0}]} = xref:q(s,"X * M"), + ?line check_state(s), + + ?line copy_file(fname(Dir, "lib1.erl"), fname(Dir,"lib1.beam")), + ?line ok = xref:set_library_path(s, [Dir]), + ?line {error, _, _} = xref:q(s, "U"), + + %% OTP-3921. AM and LM not always disjoint. + ?line {ok, lib1} = compile:file(fname(Dir,lib1),[debug_info,{outdir,Dir}]), + ?line {ok, lib1} = xref:add_module(s, fname(Dir,"lib1.beam")), + ?line check_state(s), + + ?line {error, _, {file_error, _, _}} = xref:set_library_path(s, [UDir]), + + ?line xref:stop(s), + ?line ok = file:delete(fname(Dir, "lib1.beam")), + ?line ok = file:delete(fname(Dir, "lib2.beam")), + ?line ok = file:delete(fname(Dir, "lib3.beam")), + ?line ok = file:delete(fname(Dir, "t.beam")), + + ?line {ok, cp} = compile:file(fname(Dir,cp),[debug_info,{outdir,Dir}]), + ?line {ok, _} = start(s), + ?line ok = xref:set_default(s, [{verbose,false}, {warnings, false}]), + ?line {ok, cp} = xref:add_module(s, fname(Dir,"cp.beam")), + ?line {ok, [{lists, sort, 1}]} = xref:q(s, "U"), + ?line ok = xref:set_library_path(s, code_path), + ?line {ok, []} = xref:q(s, "U"), + ?line check_state(s), + ?line xref:stop(s), + ?line ok = file:delete(fname(Dir, "cp.beam")), + ok. + +read(suite) -> []; +read(doc) -> ["Data read from the Abstract Code"]; +read(Conf) when is_list(Conf) -> + CopyDir = ?copydir, + Dir = fname(CopyDir,"read"), + File = fname(Dir, "read"), + Beam = fname(Dir, "read.beam"), + ?line {ok, read} = compile:file(File, [debug_info,{outdir,Dir}]), + ?line do_read(File, abstract_v2), + ?line copy_file(fname(Dir, "read.beam.v1"), Beam), + ?line do_read(File, abstract_v1), + ?line ok = file:delete(Beam), + ok. + +do_read(File, Version) -> + ?line {ok, _} = start(s), + ?line ok = xref:set_default(s, [{verbose,false}, {warnings, false}]), + ?line {ok, read} = xref:add_module(s, File), + + ?line {U, OK, OKB} = read_expected(Version), + + %% {ok, UC} = xref:q(s, "(Lin) UC"), + %% RR = to_external(converse(family_to_relation(family(UC)))), + %% lists:foreach(fun(X) -> io:format("~w~n", [X]) end, RR), + Unres = to_external(relation_to_family(converse(from_term(U)))), + ?line {ok, Unres} = xref:q(s, "(Lin) UC"), + + %% {ok, EE} = xref:q(s, "(Lin) (E - UC)"), + %% AA = to_external(converse(family_to_relation(family(EE)))), + %% lists:foreach(fun(X) -> io:format("~w~n", [X]) end, AA), + Calls = to_external(relation_to_family(converse(from_term(OK)))), + ?line {ok, Calls} = xref:q(s, "(Lin) (E - UC) "), + + ?line ok = check_state(s), + ?line {ok, UM} = xref:q(s, "UM"), + ?line true = member('$M_EXPR', UM), + + ?line {ok, X} = xref:q(s, "X"), + ?line true = member({read, module_info, 0}, X), + ?line false = member({foo, module_info, 0}, X), + ?line false = member({erlang, module_info, 0}, X), + ?line {ok, Unknowns} = xref:q(s, "U"), + ?line false = member({read, module_info, 0}, Unknowns), + ?line true = member({foo, module_info, 0}, Unknowns), + ?line true = member({erlang, module_info, 0}, Unknowns), + ?line {ok, LC} = xref:q(s, "LC"), + ?line true = member({{read,bi,0},{read,bi,0}}, LC), + + ?line ok = xref:set_library_path(s, add_erts_code_path(fname(code:lib_dir(kernel),ebin))), + ?line io:format("~p~n",[(catch xref:get_library_path(s))]), + ?line {ok, X2} = xref:q(s, "X"), + ?line ok = check_state(s), + ?line true = member({read, module_info, 0}, X2), + ?line false = member({foo, module_info, 0}, X2), + ?line true = member({erlang, module_info, 0}, X2), + ?line {ok, Unknowns2} = xref:q(s, "U"), + ?line false = member({read, module_info, 0}, Unknowns2), + ?line true = member({foo, module_info, 0}, Unknowns2), + ?line false = member({erlang, module_info, 0}, Unknowns2), + + ?line ok = xref:remove_module(s, read), + ?line {ok, read} = xref:add_module(s, File, [{builtins,true}]), + + UnresB = to_external(relation_to_family(converse(from_term(U)))), + ?line {ok, UnresB} = xref:q(s, "(Lin) UC"), + CallsB = to_external(relation_to_family(converse(from_term(OKB)))), + ?line {ok, CallsB} = xref:q(s, "(Lin) (E - UC) "), + ?line ok = check_state(s), + ?line {ok, XU} = xref:q(s, "XU"), + ?line Erl = set([{erlang,length,1},{erlang,integer,1}, + {erlang,binary_to_term,1}]), + ?line [{erlang,binary_to_term,1},{erlang,length,1}] = + to_external(intersection(set(XU), Erl)), + ?line xref:stop(s). + +%% What is expected when xref_SUITE_data/read/read.erl is added: +read_expected(Version) -> + %% Line positions in xref_SUITE_data/read/read.erl: + POS1 = 28, POS2 = POS1+10, POS3 = POS2+6, POS4 = POS3+6, POS5 = POS4+10, + POS6 = POS5+5, POS7 = POS6+6, POS8 = POS7+6, POS9 = POS8+8, + POS10 = POS9+10, POS11 = POS10+7, POS12 = POS11+8, POS13 = POS12+10, + POS14 = POS13+18, % POS15 = POS14+23, + + FF = {read,funfuns,0}, + U = [{POS1+5,{FF,{dist,'$F_EXPR',0}}}, + {POS1+8,{FF,{dist,'$F_EXPR',0}}}, + {POS2+8,{{read,funfuns,0},{expr,'$F_EXPR',1}}}, + {POS3+4,{FF,{expr,'$F_EXPR',2}}}, + {POS4+2,{FF,{modul,'$F_EXPR',1}}}, + {POS4+4,{FF,{spm,'$F_EXPR',1}}}, + {POS4+6,{FF,{spm,'$F_EXPR',1}}}, + {POS4+8,{FF,{spm,'$F_EXPR',1}}}, + {POS5+1,{FF,{'$M_EXPR','$F_EXPR',0}}}, + {POS5+2,{FF,{'$M_EXPR','$F_EXPR',0}}}, + {POS5+3,{FF,{'$M_EXPR','$F_EXPR',0}}}, + {POS6+1,{FF,{'$M_EXPR','$F_EXPR',0}}}, + {POS6+2,{FF,{'$M_EXPR','$F_EXPR',0}}}, + {POS6+4,{FF,{n,'$F_EXPR',-1}}}, + {POS7+1,{FF,{'$M_EXPR',f,1}}}, + {POS7+2,{FF,{'$M_EXPR',f,1}}}, + {POS8+2,{FF,{hej,'$F_EXPR',1}}}, + {POS8+3,{FF,{t,'$F_EXPR',1}}}, + {POS8+5,{FF,{a,'$F_EXPR',1}}}, + {POS8+7,{FF,{m,'$F_EXPR',1}}}, + {POS9+1,{FF,{'$M_EXPR',f,1}}}, + {POS9+3,{FF,{a,'$F_EXPR',1}}}, + {POS10+1,{FF,{'$M_EXPR',foo,1}}}, + {POS10+2,{FF,{'$M_EXPR','$F_EXPR',1}}}, + {POS10+3,{FF,{'$M_EXPR','$F_EXPR',2}}}, + {POS10+4,{FF,{'$M_EXPR','$F_EXPR',1}}}, + {POS10+5,{FF,{'$M_EXPR',san,1}}}, + {POS10+6,{FF,{'$M_EXPR','$F_EXPR',1}}}, + {POS11+1,{FF,{'$M_EXPR','$F_EXPR',1}}}, + {POS11+2,{FF,{'$M_EXPR','$F_EXPR',-1}}}, + {POS11+3,{FF,{m,f,-1}}}, + {POS11+4,{FF,{m,f,-1}}}, + {POS11+5,{FF,{'$M_EXPR','$F_EXPR',1}}}, + {POS11+6,{FF,{'$M_EXPR','$F_EXPR',1}}}, + {POS12+1,{FF,{'$M_EXPR','$F_EXPR',-1}}}, + {POS12+4,{FF,{'$M_EXPR','$F_EXPR',2}}}, + {POS12+7,{FF,{'$M_EXPR','$F_EXPR',-1}}}, + {POS12+8,{FF,{m4,f4,-1}}}, + {POS13+2,{FF,{debug,'$F_EXPR',0}}}, + {POS13+3,{FF,{'$M_EXPR','$F_EXPR',-1}}}, + {POS14+8,{{read,bi,0},{'$M_EXPR','$F_EXPR',1}}}], + + O1 = [{0,{FF,{modul,'$F_EXPR',179}}}, + {0,{FF,{read,'$F_EXPR',178}}}, + {20,{{read,lc,0},{ets,new,0}}}, + {21,{{read,lc,0},{ets,tab2list,1}}}, + {POS1+1,{FF,{erlang,spawn,1}}}, + {POS1+1,{FF,{mod17,fun17,0}}}, + {POS1+2,{FF,{erlang,spawn,1}}}, + {POS1+2,{FF,{read,local,0}}}, + {POS1+3,{FF,{erlang,spawn,1}}}, + {POS1+4,{FF,{dist,func,0}}}, + {POS1+4,{FF,{erlang,spawn,1}}}, + {POS1+5,{FF,{erlang,spawn,1}}}, + {POS1+6,{FF,{erlang,spawn_link,1}}}, + {POS1+6,{FF,{mod17,fun17,0}}}, + {POS1+7,{FF,{dist,func,0}}}, + {POS1+7,{FF,{erlang,spawn_link,1}}}, + {POS1+8,{FF,{erlang,spawn_link,1}}}, + {POS2+1,{FF,{d,f,0}}}, + {POS2+1,{FF,{dist,func,2}}}, + {POS2+1,{FF,{erlang,spawn,2}}}, + {POS2+2,{FF,{dist,func,2}}}, + {POS2+2,{FF,{erlang,spawn,2}}}, + {POS2+2,{FF,{mod42,func,0}}}, + {POS2+3,{FF,{d,f,0}}}, + {POS2+3,{FF,{dist,func,2}}}, + {POS2+3,{FF,{erlang,spawn_link,2}}}, + {POS2+4,{FF,{dist,func,2}}}, + {POS2+4,{FF,{erlang,spawn_link,2}}}, + {POS2+4,{FF,{mod42,func,0}}}, + {POS3+1,{FF,{dist,func,2}}}, + {POS3+3,{FF,{dist,func,2}}}, + {POS4+1,{FF,{erlang,spawn,4}}}, + {POS4+1,{FF,{modul,function,0}}}, + {POS4+2,{FF,{erlang,spawn,4}}}, + {POS4+3,{FF,{dist,func,2}}}, + {POS4+3,{FF,{erlang,spawn,4}}}, + {POS4+3,{FF,{spm,spf,2}}}, + {POS4+4,{FF,{dist,func,2}}}, + {POS4+4,{FF,{erlang,spawn,4}}}, + {POS4+5,{FF,{dist,func,2}}}, + {POS4+5,{FF,{erlang,spawn_link,4}}}, + {POS4+5,{FF,{spm,spf,2}}}, + {POS4+6,{FF,{dist,func,2}}}, + {POS4+6,{FF,{erlang,spawn_link,4}}}, + {POS4+7,{FF,{erlang,spawn_opt,4}}}, + {POS4+7,{FF,{read,bi,0}}}, + {POS4+7,{FF,{spm,spf,2}}}, + {POS4+8,{FF,{erlang,spawn_opt,4}}}, + {POS4+8,{FF,{read,bi,0}}}, + {POS5+1,{FF,{erlang,spawn,1}}}, + {POS5+2,{FF,{erlang,spawn,1}}}, + {POS5+3,{FF,{erlang,spawn_link,1}}}, + {POS6+1,{FF,{erlang,spawn,2}}}, + {POS6+2,{FF,{erlang,spawn_link,2}}}, + {POS7+1,{FF,{erlang,spawn,4}}}, + {POS7+2,{FF,{erlang,spawn_opt,4}}}, + {POS8+1,{FF,{hej,san,1}}}, + {POS8+4,{FF,{a,b,1}}}, + {POS8+4,{FF,{erlang,apply,2}}}, + {POS8+5,{FF,{erlang,apply,2}}}, + {POS8+6,{FF,{erlang,apply,3}}}, + {POS8+6,{FF,{m,f,1}}}, + {POS8+7,{FF,{erlang,apply,3}}}, + {POS9+1,{FF,{erlang,apply,3}}}, + {POS9+1,{FF,{read,bi,0}}}, + {POS9+2,{FF,{a,b,1}}}, + {POS9+2,{FF,{erlang,apply,2}}}, + {POS9+3,{FF,{erlang,apply,2}}}, + {POS9+4,{FF,{erlang,apply,2}}}, + {POS9+4,{FF,{erlang,not_a_function,1}}}, + {POS9+5,{FF,{erlang,apply,3}}}, + {POS9+5,{FF,{mod,func,2}}}, + {POS9+6,{FF,{erlang,apply,1}}}, + {POS9+7,{FF,{erlang,apply,2}}}, + {POS9+7,{FF,{math,add3,1}}}, + {POS9+8,{FF,{q,f,1}}}, + {POS10+4,{FF,{erlang,apply,2}}}, + {POS10+5,{FF,{mod1,fun1,1}}}, + {POS11+1,{FF,{erlang,apply,3}}}, + {POS11+2,{FF,{erlang,apply,3}}}, + {POS11+3,{FF,{erlang,apply,3}}}, + {POS11+4,{FF,{erlang,apply,3}}}, + {POS11+6,{FF,{erlang,apply,2}}}, + {POS12+1,{FF,{erlang,apply,2}}}, + {POS12+4,{FF,{erlang,apply,2}}}, + {POS12+5,{FF,{erlang,apply,3}}}, + {POS12+5,{FF,{m3,f3,2}}}, + {POS12+7,{FF,{erlang,apply,2}}}, + {POS12+8,{FF,{erlang,apply,3}}}, + {POS13+1,{FF,{dm,df,1}}}, + {POS13+6,{{read,bi,0},{foo,module_info,0}}}, + {POS13+7,{{read,bi,0},{read,module_info,0}}}, + {POS13+9,{{read,bi,0},{t,foo,1}}}, + {POS14+11,{{read,bi,0},{erlang,module_info,0}}}, + {POS14+17,{{read,bi,0},{read,bi,0}}}], + + OK = case Version of + abstract_v1 -> + [{POS8+3, {FF,{erlang,apply,3}}}, + {POS10+1, {FF,{erlang,apply,3}}}, + {POS10+6, {FF,{erlang,apply,3}}}] + ++ O1; + _ -> +% [{POS15+2,{{read,bi,0},{foo,t,0}}}, +% {POS15+3,{{read,bi,0},{bar,t,0}}}, +% {POS15+6,{{read,bi,0},{read,local,0}}}, +% {POS15+8,{{read,bi,0},{foo,t,0}}}, +% {POS15+10,{{read,bi,0},{bar,t,0}}}] ++ + O1 + end, + + %% When builtins =:= true: + OKB = [{POS13+1,{FF,{erts_debug,apply,4}}}, + {POS13+2,{FF,{erts_debug,apply,4}}}, + {POS13+3,{FF,{erts_debug,apply,4}}}, + {POS1+3, {FF,{erlang,binary_to_term,1}}}, + {POS3+1, {FF,{erlang,spawn,3}}}, + {POS3+2, {FF,{erlang,spawn,3}}}, + {POS3+3, {FF,{erlang,spawn_link,3}}}, + {POS3+4, {FF,{erlang,spawn_link,3}}}, + {POS6+4, {FF,{erlang,spawn,3}}}, + {POS13+5, {{read,bi,0},{erlang,length,1}}}, + {POS14+3, {{read,bi,0},{erlang,length,1}}}] + ++ OK, + + {U, OK, OKB}. + +read2(suite) -> []; +read2(doc) -> ["Data read from the Abstract Code (cont)"]; +read2(Conf) when is_list(Conf) -> + %% Handles the spawn_opt versions added in R9 (OTP-4180). + %% Expected augmentations: try/catch, cond. + CopyDir = ?copydir, + Dir = fname(CopyDir,"read"), + File = fname(Dir, "read2.erl"), + MFile = fname(Dir, "read2"), + Beam = fname(Dir, "read2.beam"), + Test = <<"-module(read2). + -compile(export_all). + + f() -> + spawn_opt({read2,f}, % POS2 + [f()]), + spawn_opt(fun() -> foo end, [link]), + spawn_opt(f(), + {read2,f}, [{min_heap_size,1000}]), + spawn_opt(f(), + fun() -> f() end, [flopp]), + spawn_opt(f(), + read2, f, [], []); + f() -> + %% Duplicated unresolved calls are ignored: + (f())(foo,bar),(f())(foo,bar). % POS1 + ">>, + ?line ok = file:write_file(File, Test), + ?line {ok, read2} = compile:file(File, [debug_info,{outdir,Dir}]), + + ?line {ok, _} = xref:start(s), + ?line {ok, read2} = xref:add_module(s, MFile), + ?line {U0, OK0} = read2_expected(), + + U = to_external(relation_to_family(converse(from_term(U0)))), + OK = to_external(relation_to_family(converse(from_term(OK0)))), + ?line {ok, U2} = xref:q(s, "(Lin) UC"), + ?line {ok, OK2} = xref:q(s, "(Lin) (E - UC)"), + ?line true = U =:= U2, + ?line true = OK =:= OK2, + ?line ok = check_state(s), + ?line xref:stop(s), + + ?line ok = file:delete(File), + ?line ok = file:delete(Beam), + ok. + + +read2_expected() -> + POS1 = 16, + POS2 = 5, + FF = {read2,f,0}, + U = [{POS1,{FF,{'$M_EXPR','$F_EXPR',2}}}], + OK = [{POS2,{FF,{erlang,spawn_opt,2}}}, + {POS2,{FF,FF}}, + {POS2+1,{FF,FF}}, + {POS2+2,{FF,{erlang,spawn_opt,2}}}, + {POS2+3,{FF,{erlang,spawn_opt,3}}}, + {POS2+3,{FF,FF}}, + {POS2+3,{FF,FF}}, + {POS2+5,{FF,{erlang,spawn_opt,3}}}, + {POS2+5,{FF,FF}}, + {POS2+6,{FF,FF}}, + {POS2+7,{FF,{erlang,spawn_opt,5}}}, + {POS2+7,{FF,FF}}, + {POS2+7,{FF,FF}}, + {POS1,{FF,FF}}], + {U, OK}. + +remove(suite) -> []; +remove(doc) -> ["Remove modules, applications, releases"]; +remove(Conf) when is_list(Conf) -> + S = new(), + ?line {error, _, {no_such_module, mod}} = + xref_base:remove_module(S, mod), + ?line {error, _, {no_such_application, app}} = + xref_base:remove_application(S, app), + ?line {error, _, {no_such_release, rel}} = + xref_base:remove_release(S, rel), + ?line ok = xref_base:delete(S), + ok. + +replace(suite) -> []; +replace(doc) -> ["Replace modules, applications, releases"]; +replace(Conf) when is_list(Conf) -> + CopyDir = ?copydir, + Dir = fname(CopyDir,"rel2"), + X = fname(Dir, "x.erl"), + Y = fname(Dir, "y.erl"), + A1_0 = fname(Dir, fname("lib","app1-1.0")), + A1_1 = fname(Dir, fname("lib","app1-1.1")), + A2 = fname(Dir, fname("lib","app2-1.1")), + EB1_0 = fname(A1_0, "ebin"), + EB1_1 = fname(A1_1, "ebin"), + Xbeam = fname(EB1_1, "x.beam"), + Ybeam = fname(EB1_1, "y.beam"), + + ?line {ok, x} = compile:file(X, [debug_info, {outdir,EB1_0}]), + ?line {ok, x} = compile:file(X, [debug_info, {outdir,EB1_1}]), + ?line {ok, y} = compile:file(Y, [debug_info, {outdir,EB1_1}]), + + ?line {ok, _} = start(s), + ?line {ok, false} = xref:set_default(s, verbose, false), + ?line {ok, true} = xref:set_default(s, warnings, false), + ?line {ok, rel2} = xref:add_release(s, Dir, []), + ?line {error, _, _} = xref:replace_application(s, app1, "no_data"), + ?line {error, _, {no_such_application, app12}} = + xref:replace_application(s, app12, A1_0, []), + ?line {error, _, {invalid_filename,{foo,bar}}} = + xref:replace_application(s, app1, {foo,bar}, []), + ?line {error, _, {invalid_options,[not_an_option]}} = + xref:replace_application(s, foo, bar, [not_an_option]), + ?line {error, _, {invalid_options,[{builtins,not_a_value}]}} = + xref:replace_application(s, foo, bar, [{builtins,not_a_value}]), + ?line {ok, app1} = + xref:replace_application(s, app1, A1_0), + ?line [{_, AppInfo}] = xref:info(s, applications, app1), + ?line {value, {release, [rel2]}} = keysearch(release, 1, AppInfo), + + ?line {error, _, {no_such_module, xx}} = + xref:replace_module(s, xx, Xbeam, []), + ?line {error, _, {invalid_options,[{builtins,true},not_an_option]}} = + xref:replace_module(s, foo, bar,[{builtins,true},not_an_option]), + ?line {error, _, {invalid_options,[{builtins,not_a_value}]}} = + xref:replace_module(s, foo, bar, [{builtins,not_a_value}]), + ?line {error, _, {invalid_filename,{foo,bar}}} = + xref:replace_module(s, x, {foo,bar}), + ?line {ok, x} = xref:replace_module(s, x, Xbeam), + ?line [{x, ModInfo}] = xref:info(s, modules, x), + ?line {value, {application, [app1]}} = + keysearch(application, 1, ModInfo), + + ?line {ok, x} = compile:file(X, [no_debug_info, {outdir,EB1_1}]), + ?line {error, _, {no_debug_info, _}} = xref:replace_module(s, x, Xbeam), + ?line {error, _, {module_mismatch, x,y}} = + xref:replace_module(s, x, Ybeam), + ?line case os:type() of + {unix, _} -> + ?line hide_file(Ybeam), + ?line {error, _, {file_error, _, _}} = + xref:replace_module(s, x, Ybeam); + _ -> + true + end, + ?line ok = xref:remove_module(s, x), + ?line {error, _, {no_debug_info, _}} = xref:add_module(s, Xbeam), + + %% "app2" is ignored, the old application name is kept + ?line {ok, app1} = xref:replace_application(s, app1, A2), + + ?line xref:stop(s), + ?line ok = file:delete(fname(EB1_0, "x.beam")), + ?line ok = file:delete(Xbeam), + ?line ok = file:delete(Ybeam), + ok. + +update(suite) -> []; +update(doc) -> ["The update() function"]; +update(Conf) when is_list(Conf) -> + CopyDir = ?copydir, + Dir = fname(CopyDir,"update"), + Source = fname(Dir, "x.erl"), + Beam = fname(Dir, "x.beam"), + ?line copy_file(fname(Dir, "x.erl.1"), Source), + ?line {ok, x} = compile:file(Source, [debug_info, {outdir,Dir}]), + + ?line {ok, _} = start(s), + ?line ok = xref:set_default(s, [{verbose,false}, {warnings, false}]), + ?line {ok, [x]} = xref:add_directory(s, Dir, [{builtins,true}]), + ?line {error, _, {invalid_options,[not_an_option]}} = + xref:update(s, [not_an_option]), + ?line {ok, []} = xref:update(s), + ?line {ok, [{erlang,atom_to_list,1}]} = xref:q(s, "XU"), + + ?line [{x, ModInfo}] = xref:info(s, modules, x), + ?line case keysearch(directory, 1, ModInfo) of + {value, {directory, Dir}} -> ok + end, + + timer:sleep(2000), % make sure modification time has changed + ?line copy_file(fname(Dir, "x.erl.2"), Source), + ?line {ok, x} = compile:file(Source, [debug_info, {outdir,Dir}]), + ?line {ok, [x]} = xref:update(s, []), + ?line {ok, [{erlang,list_to_atom,1}]} = xref:q(s, "XU"), + + timer:sleep(2000), + ?line {ok, x} = compile:file(Source, [no_debug_info,{outdir,Dir}]), + ?line {error, _, {no_debug_info, _}} = xref:update(s), + + ?line xref:stop(s), + ?line ok = file:delete(Beam), + ?line ok = file:delete(Source), + ok. + +deprecated(suite) -> []; +deprecated(doc) -> ["OTP-4695: Deprecated functions."]; +deprecated(Conf) when is_list(Conf) -> + Dir = ?copydir, + File = fname(Dir, "depr.erl"), + MFile_r9c = fname(Dir, "depr_r9c"), + MFile = fname(Dir, "depr"), + Beam = fname(Dir, "depr.beam"), + %% This file has been compiled to ?datadir/depr_r9c.beam + %% using the R9C compiler. From R10B and onwards the linter + %% checks the 'deprecated' attribute as well. +% Test = <<"-module(depr). + +% -export([t/0,f/1,bar/2,f/2,g/3]). + +% -deprecated([{f,1}, % DF +% {bar,2,eventually}]). % DF_3 +% -deprecated([{f,1,next_major_release}]). % DF_2 (again) +% -deprecated([{frutt,0,next_version}]). % message... +% -deprecated([{f,2,next_major_release}, % DF_2 +% {g,3,next_version}, % DF_1 +% {ignored,10,100}]). % message... +% -deprecated([{does_not_exist,1}]). % message... + +% -deprecated(foo). % message... + +% t() -> +% frutt(1), +% g(1,2, 3), +% ?MODULE:f(10). + +% f(A) -> +% ?MODULE:f(A,A). + +% f(X, Y) -> +% ?MODULE:g(X, Y, X). + +% g(F, G, H) -> +% ?MODULE:bar(F, {G,H}). + +% bar(_, _) -> +% true. + +% frutt(_) -> +% frutt(). + +% frutt() -> +% true. +% ">>, + +% ?line ok = file:write_file(File, Test), +% ?line {ok, depr_r9c} = compile:file(File, [debug_info,{outdir,Dir}]), + + ?line {ok, _} = xref:start(s), + ?line {ok, depr_r9c} = xref:add_module(s, MFile_r9c), + M9 = depr_r9c, + DF_1 = usort([{{M9,f,2},{M9,g,3}}]), + DF_2 = usort(DF_1++[{{M9,f,1},{M9,f,2}},{{M9,t,0},{M9,f,1}}]), + DF_3 = usort(DF_2++[{{M9,g,3},{M9,bar,2}}]), + DF = usort(DF_3++[{{M9,t,0},{M9,f,1}}]), + + ?line {ok,DF} = xref:analyze(s, deprecated_function_calls), + ?line {ok,DF_1} = + xref:analyze(s, {deprecated_function_calls,next_version}), + ?line {ok,DF_2} = + xref:analyze(s, {deprecated_function_calls,next_major_release}), + ?line {ok,DF_3} = + xref:analyze(s, {deprecated_function_calls,eventually}), + + D = to_external(range(from_term(DF))), + D_1 = to_external(range(from_term(DF_1))), + D_2 = to_external(range(from_term(DF_2))), + D_3 = to_external(range(from_term(DF_3))), + + ?line {ok,D} = xref:analyze(s, deprecated_functions), + ?line {ok,D_1} = + xref:analyze(s, {deprecated_functions,next_version}), + ?line {ok,D_2} = + xref:analyze(s, {deprecated_functions,next_major_release}), + ?line {ok,D_3} = + xref:analyze(s, {deprecated_functions,eventually}), + + ?line ok = check_state(s), + ?line xref:stop(s), + + Test2= <<"-module(depr). + + -export([t/0,f/1,bar/2,f/2,g/3]). + + -deprecated([{'_','_',eventually}]). % DF_3 + -deprecated([{f,'_',next_major_release}]). % DF_2 + -deprecated([{g,'_',next_version}]). % DF_1 + -deprecated([{bar,2}]). % DF + + t() -> + g(1,2, 3), + ?MODULE:f(10). + + f(A) -> + ?MODULE:f(A,A). + + f(X, Y) -> + ?MODULE:g(X, Y, X). + + g(F, G, H) -> + ?MODULE:bar(F, {G,H}). + + bar(_, _) -> + ?MODULE:t(). + ">>, + + ?line ok = file:write_file(File, Test2), + ?line {ok, depr} = compile:file(File, [debug_info,{outdir,Dir}]), + + ?line {ok, _} = xref:start(s), + ?line {ok, depr} = xref:add_module(s, MFile), + + M = depr, + DFa_1 = usort([{{M,f,2},{M,g,3}}]), + DFa_2 = usort(DFa_1++[{{M,f,1},{M,f,2}},{{M,t,0},{M,f,1}}]), + DFa_3 = usort(DFa_2++[{{M,bar,2},{M,t,0}},{{M,g,3},{M,bar,2}}]), + DFa = DFa_3, + + ?line {ok,DFa} = xref:analyze(s, deprecated_function_calls), + ?line {ok,DFa_1} = + xref:analyze(s, {deprecated_function_calls,next_version}), + ?line {ok,DFa_2} = + xref:analyze(s, {deprecated_function_calls,next_major_release}), + ?line {ok,DFa_3} = + xref:analyze(s, {deprecated_function_calls,eventually}), + + ?line ok = check_state(s), + ?line xref:stop(s), + + %% All of the module is deprecated. + Test3= <<"-module(depr). + + -export([t/0,f/1,bar/2,f/2,g/3]). + + -deprecated([{f,'_',next_major_release}]). % DF_2 + -deprecated([{g,'_',next_version}]). % DF_1 + -deprecated(module). % DF + + t() -> + g(1,2, 3), + ?MODULE:f(10). + + f(A) -> + ?MODULE:f(A,A). + + f(X, Y) -> + ?MODULE:g(X, Y, X). + + g(F, G, H) -> + ?MODULE:bar(F, {G,H}). + + bar(_, _) -> + ?MODULE:t(). + ">>, + + ?line ok = file:write_file(File, Test3), + ?line {ok, depr} = compile:file(File, [debug_info,{outdir,Dir}]), + + ?line {ok, _} = xref:start(s), + ?line {ok, depr} = xref:add_module(s, MFile), + + DFb_1 = usort([{{M,f,2},{M,g,3}}]), + DFb_2 = usort(DFb_1++[{{M,f,1},{M,f,2}},{{M,t,0},{M,f,1}}]), + DFb_3 = DFb_2, + DFb = usort(DFb_2++[{{M,bar,2},{M,t,0}},{{M,g,3},{M,bar,2}}]), + + ?line {ok,DFb} = xref:analyze(s, deprecated_function_calls), + ?line {ok,DFb_1} = + xref:analyze(s, {deprecated_function_calls,next_version}), + ?line {ok,DFb_2} = + xref:analyze(s, {deprecated_function_calls,next_major_release}), + ?line {ok,DFb_3} = + xref:analyze(s, {deprecated_function_calls,eventually}), + + ?line ok = check_state(s), + ?line xref:stop(s), + + ?line ok = file:delete(File), + ?line ok = file:delete(Beam), + ok. + + +trycatch(suite) -> []; +trycatch(doc) -> ["OTP-5152: try/catch, final (?) version."]; +trycatch(Conf) when is_list(Conf) -> + Dir = ?copydir, + File = fname(Dir, "trycatch.erl"), + MFile = fname(Dir, "trycatch"), + Beam = fname(Dir, "trycatch.beam"), + Test = <<"-module(trycatch). + + -export([trycatch/0]). + + trycatch() -> + try + foo:bar(), + bar:foo() of + 1 -> foo:foo(); + 2 -> bar:bar() + catch + error:a -> err:e1(); + error:b -> err:e2() + after + fini:shed() + end. + ">>, + + ?line ok = file:write_file(File, Test), + ?line {ok, trycatch} = compile:file(File, [debug_info,{outdir,Dir}]), + + ?line {ok, _} = xref:start(s), + ?line {ok, trycatch} = xref:add_module(s, MFile), + A = trycatch, + {ok,[{{{A,A,0},{bar,bar,0}},[10]}, + {{{A,A,0},{bar,foo,0}},[8]}, + {{{A,A,0},{err,e1,0}},[12]}, + {{{A,A,0},{err,e2,0}},[13]}, + {{{A,A,0},{fini,shed,0}},[15]}, + {{{A,A,0},{foo,bar,0}},[7]}, + {{{A,A,0},{foo,foo,0}},[9]}]} = + xref:q(s, "(Lin) (E | trycatch:trycatch/0)"), + + ?line ok = check_state(s), + ?line xref:stop(s), + + ?line ok = file:delete(File), + ?line ok = file:delete(Beam), + ok. + + +abstract_modules(suite) -> []; +abstract_modules(doc) -> ["OTP-5520: Abstract (parameterized) modules."]; +abstract_modules(Conf) when is_list(Conf) -> + Dir = ?copydir, + File = fname(Dir, "absmod.erl"), + MFile = fname(Dir, "absmod"), + Beam = fname(Dir, "absmod.beam"), + Test = <<"-module(param, [A, B]). + + -export([args/1]). + + args(C) -> + X = local(C), + Y = THIS:new(), % undef + Z = new(A, B), + {X, Y, Z}. + + local(C) -> + module_info(C). + ">>, + + ?line ok = file:write_file(File, Test), + + %% The compiler will no longer allow us to have a mismatch between + %% the module name and the output file, so we must use a trick. + ?line {ok, param, BeamCode} = compile:file(File, [binary,debug_info]), + ?line ok = file:write_file(filename:join(Dir, Beam), BeamCode), + + ?line {ok, _} = xref:start(s), + ?line {ok, param} = xref:add_module(s, MFile, {warnings,false}), + A = param, + ?line {ok, [{{{A,args,1},{'$M_EXPR',new,0}},[7]}, + {{{A,args,1},{A,local,1}},[6]}, + {{{A,args,1},{A,new,2}},[8]}, + {{{A,local,1},{A,module_info,1}},[12]}, + {{{param,new,2},{param,instance,2}},[0]}]} = + xref:q(s, "(Lin) E"), + ?line {ok,[{param,args,1}, + {param,instance,2}, + {param,local,1}, + {param,module_info,1}, + {param,new,2}]} = xref:q(s, "F"), + + ?line ok = check_state(s), + ?line xref:stop(s), + + ?line {ok, _} = xref:start(s, {xref_mode, modules}), + ?line {ok, param} = xref:add_module(s, MFile), + ?line {ok,[{param,args,1}, + {param,instance,2}, + {param,new,2}]} = xref:q(s, "X"), + ?line ok = check_state(s), + ?line xref:stop(s), + + ?line ok = file:delete(File), + ?line ok = file:delete(Beam), + ok. + +fun_mfa(suite) -> []; +fun_mfa(doc) -> ["OTP-5653: fun M:F/A."]; +fun_mfa(Conf) when is_list(Conf) -> + Dir = ?copydir, + File = fname(Dir, "fun_mfa.erl"), + MFile = fname(Dir, "fun_mfa"), + Beam = fname(Dir, "fun_mfa.beam"), + Test = <<"-module(fun_mfa). + + -export([t/0, t1/0, t2/0, t3/0]). + + t() -> + F = fun ?MODULE:t/0, + (F)(). + + t1() -> + F = fun t/0, + (F)(). + + t2() -> + fun ?MODULE:t/0(). + + t3() -> + fun t3/0(). + ">>, + + ?line ok = file:write_file(File, Test), + A = fun_mfa, + ?line {ok, A} = compile:file(File, [debug_info,{outdir,Dir}]), + ?line {ok, _} = xref:start(s), + ?line {ok, A} = xref:add_module(s, MFile, {warnings,false}), + ?line {ok, [{{{A,t,0},{'$M_EXPR','$F_EXPR',0}},[7]}, + {{{A,t,0},{A,t,0}},[6]}, + {{{A,t1,0},{'$M_EXPR','$F_EXPR',0}},[11]}, + {{{A,t1,0},{A,t,0}},[10]}, + {{{A,t2,0},{A,t,0}},[14]}, + {{{A,t3,0},{fun_mfa,t3,0}},[17]}]} = + xref:q(s, "(Lin) E"), + + ?line ok = check_state(s), + ?line xref:stop(s), + + ?line ok = file:delete(File), + ?line ok = file:delete(Beam), + ok. + +qlc(suite) -> []; +qlc(doc) -> ["OTP-5195: A bug fix when using qlc:q/1,2."]; +qlc(Conf) when is_list(Conf) -> + Dir = ?copydir, + File = fname(Dir, "qlc.erl"), + MFile = fname(Dir, "qlc"), + Beam = fname(Dir, "qlc.beam"), + Test = <<"-module(qlc). + + -include_lib(\"stdlib/include/qlc.hrl\"). + + -export([t/0]). + + t() -> + dets:open_file(t, []), + dets:insert(t, [{1,a},{2,b},{3,c},{4,d}]), + MS = ets:fun2ms(fun({X,Y}) when (X > 1) or (X < 5) -> {Y} + end), + QH1 = dets:table(t, [{traverse, {select, MS}}]), + QH2 = qlc:q([{Y} || {X,Y} <- dets:table(t), + (X > 1) or (X < 5)]), + true = qlc:info(QH1) =:= qlc:info(QH2), + dets:close(t), + ok. + ">>, + + ?line ok = file:write_file(File, Test), + A = qlc, + ?line {ok, A} = compile:file(File, [debug_info,{outdir,Dir}]), + ?line {ok, _} = xref:start(s), + ?line {ok, A} = xref:add_module(s, MFile, {warnings,false}), + ?line {ok, _} = xref:q(s, "(Lin) E"), % is can be loaded + + ?line ok = check_state(s), + ?line xref:stop(s), + + ?line ok = file:delete(File), + ?line ok = file:delete(Beam), + ok. + + +analyses(suite) -> + [analyze, basic, md, q, variables, unused_locals]. + +analyze(suite) -> []; +analyze(doc) -> ["Simple analyses"]; +analyze(Conf) when is_list(Conf) -> + S0 = new(), + ?line {{error, _, {invalid_options,[not_an_option]}}, _} = + xref_base:analyze(S0, undefined_function_calls, [not_an_option]), + ?line {{error, _, {invalid_query,{q}}}, _} = xref_base:q(S0,{q}), + ?line {{error, _, {unknown_analysis,foo}}, _} = xref_base:analyze(S0, foo), + ?line {{error, _, {unknown_constant,"foo:bar/-1"}}, _} = + xref_base:analyze(S0, {use,{foo,bar,-1}}), + + CopyDir = ?copydir, + Dir = fname(CopyDir,"rel2"), + X = fname(Dir, "x.erl"), + Y = fname(Dir, "y.erl"), + A1_1 = fname([Dir,"lib","app1-1.1"]), + A2 = fname([Dir,"lib","app2-1.1"]), + EB1_1 = fname(A1_1, "ebin"), + EB2 = fname(A2, "ebin"), + Xbeam = fname(EB2, "x.beam"), + Ybeam = fname(EB1_1, "y.beam"), + + ?line {ok, x} = compile:file(X, [debug_info, {outdir,EB2}]), + ?line {ok, y} = compile:file(Y, [debug_info, {outdir,EB1_1}]), + + ?line {ok, rel2, S1} = xref_base:add_release(S0, Dir, [{verbose,false}]), + ?line S = set_up(S1), + + ?line {ok, _} = + analyze(undefined_function_calls, [{{x,xx,0},{x,undef,0}}], S), + ?line {ok, _} = analyze(undefined_functions, [{x,undef,0}], S), + ?line {ok, _} = analyze(locals_not_used, [{x,l,0},{x,l1,0}], S), + ?line {ok, _} = analyze(exports_not_used, [{x,xx,0},{y,t,0}], S), + + ?line {ok, _} = + analyze(deprecated_function_calls, [{{y,t,0},{x,t,0}}], S), + ?line {ok, _} = analyze({deprecated_function_calls,next_version}, [], S), + ?line {ok, _} = + analyze({deprecated_function_calls,next_major_release}, [], S), + ?line {ok, _} = analyze({deprecated_function_calls,eventually}, + [{{y,t,0},{x,t,0}}], S), + ?line {ok, _} = analyze(deprecated_functions, [{x,t,0}], S), + ?line {ok, _} = analyze({deprecated_functions,next_version}, [], S), + ?line {ok, _} = + analyze({deprecated_functions,next_major_release}, [], S), + ?line {ok, _} = analyze({deprecated_functions,eventually}, [{x,t,0}], S), + + ?line {ok, _} = analyze({call, {x,xx,0}}, [{x,undef,0}], S), + ?line {ok, _} = + analyze({call, [{x,xx,0},{x,l,0}]}, [{x,l1,0},{x,undef,0}], S), + ?line {ok, _} = analyze({use, {x,l,0}}, [{x,l1,0}], S), + ?line {ok, _} = + analyze({use, [{x,l,0},{x,l1,0}]}, [{x,l,0},{x,l1,0}], S), + + ?line {ok, _} = analyze({module_call, x}, [x], S), + ?line {ok, _} = analyze({module_call, [x,y]}, [x], S), + ?line {ok, _} = analyze({module_use, x}, [x,y], S), + ?line {ok, _} = analyze({module_use, [x,y]}, [x,y], S), + + ?line {ok, _} = analyze({application_call, app1}, [app2], S), + ?line {ok, _} = analyze({application_call, [app1,app2]}, [app2], S), + ?line {ok, _} = analyze({application_use, app2}, [app1,app2], S), + ?line {ok, _} = analyze({application_use, [app1,app2]}, [app1,app2], S), + + ?line ok = xref_base:delete(S), + ?line ok = file:delete(Xbeam), + ?line ok = file:delete(Ybeam), + ok. + +basic(suite) -> []; +basic(doc) -> ["Use of operators"]; +basic(Conf) when is_list(Conf) -> + ?line S0 = new(), + + F1 = {m1,f1,1}, + F6 = {m1,f2,6}, % X + F2 = {m2,f1,2}, + F3 = {m2,f2,3}, % X + F7 = {m2,f3,7}, % X + F4 = {m3,f1,4}, % X + F5 = {m3,f2,5}, + + UF1 = {m1,f12,17}, + UF2 = {m17,f17,177}, + + E1 = {F1,F3}, % X + E2 = {F6,F7}, % X + E3 = {F2,F6}, % X + E4 = {F1,F4}, % X + E5 = {F4,F5}, + E6 = {F7,F4}, % X + E7 = {F1,F6}, + + UE1 = {F2,UF2}, % X + UE2 = {F5,UF1}, % X + + D1 = {F1,12}, + D6 = {F6,3}, + DefAt_m1 = [D1,D6], + X_m1 = [F6], + % L_m1 = [F1], + XC_m1 = [E1,E2,E4], + LC_m1 = [E7], + LCallAt_m1 = [{E7,12}], + XCallAt_m1 = [{E1,13},{E2,17},{E4,7}], + Info1 = #xref_mod{name = m1, app_name = [a1]}, + ?line S1 = add_module(S0, Info1, DefAt_m1, X_m1, LCallAt_m1, XCallAt_m1, + XC_m1, LC_m1), + + D2 = {F2,7}, + D3 = {F3,9}, + D7 = {F7,19}, + DefAt_m2 = [D2,D3,D7], + X_m2 = [F3,F7], + % L_m2 = [F2], + XC_m2 = [E3,E6,UE1], + LC_m2 = [], + LCallAt_m2 = [], + XCallAt_m2 = [{E3,96},{E6,12},{UE1,77}], + Info2 = #xref_mod{name = m2, app_name = [a2]}, + ?line S2 = add_module(S1, Info2, DefAt_m2, X_m2, LCallAt_m2, XCallAt_m2, + XC_m2, LC_m2), + + D4 = {F4,6}, + D5 = {F5,97}, + DefAt_m3 = [D4,D5], + X_m3 = [F4], + % L_m3 = [F5], + XC_m3 = [UE2], + LC_m3 = [E5], + LCallAt_m3 = [{E5,19}], + XCallAt_m3 = [{UE2,22}], + Info3 = #xref_mod{name = m3, app_name = [a3]}, + ?line S3 = add_module(S2, Info3, DefAt_m3, X_m3, LCallAt_m3, XCallAt_m3, + XC_m3, LC_m3), + + Info4 = #xref_mod{name = m4, app_name = [a2]}, + ?line S4 = add_module(S3, Info4, [], [], [], [], [], []), + + AppInfo1 = #xref_app{name = a1, rel_name = [r1]}, + ?line S9 = add_application(S4, AppInfo1), + AppInfo2 = #xref_app{name = a2, rel_name = [r1]}, + ?line S10 = add_application(S9, AppInfo2), + AppInfo3 = #xref_app{name = a3, rel_name = [r2]}, + ?line S11 = add_application(S10, AppInfo3), + + RelInfo1 = #xref_rel{name = r1}, + ?line S12 = add_release(S11, RelInfo1), + RelInfo2 = #xref_rel{name = r2}, + ?line S13 = add_release(S12, RelInfo2), + + ?line S = set_up(S13), + + ?line {ok, _} = eval("[m1,m2] + m:f/1", unknown_constant, S), + ?line {ok, _} = eval("[m1, m2, m:f/1]", type_mismatch, S), + + ?line {ok, _} = eval("[m1, m1->m2]", type_mismatch, S), + ?line {ok, _} = eval("components:f/1", unknown_constant, S), + ?line {ok, _} = eval("'of':f/1", unknown_constant, S), + ?line {ok, _} = eval("of:f/1", parse_error, S), + ?line {ok, _} = eval("components", unknown_constant, S), + ?line {ok, _} = eval("[components, of, closure]", parse_error, S), + ?line {ok, _} = eval("[components, 'of', closure]", unknown_constant, S), + + ?line {ok, _} = eval("[a1->a2,m1->m2]", type_mismatch, S), + ?line {ok, _} = eval("a1->a2,m1->m2", parse_error, S), + + ?line {ok, _} = eval("m1->a1", type_mismatch, S), + ?line {ok, _} = eval("[{m1,f1,1}] : App", parse_error, S), + ?line {ok, _} = eval("[{m1,f1,1}] : Fun", [F1], S), + ?line {ok, _} = eval("range X", type_error, S), + ?line {ok, _} = eval("domain X", type_error, S), + ?line {ok, _} = eval("range M", type_error, S), + ?line {ok, _} = eval("domain M", type_error, S), + + % Misc. + ?line {ok, _} = eval("not_a_prefix_operator m1", parse_error, S), + ?line {ok, _} = eval(f("(Mod) ~p", [[F1,F6,F5]]), [m1,m3], S), + ?line {ok, _} = eval("(Lin) M - (Lin) m1", + [{F2,7},{F3,9},{F7,19},{F4,6},{F5,97},{UF2,0}], S), + ?line {ok, _} = eval(f("(Lin) M * (Lin) ~p", [[F1,F6]]), + [{F1,12},{F6,3}], S), + + ?line {ok, _} = eval(f("X * ~p", [[F1, F2, F3, F4, F5]]), [F3, F4], S), + ?line {ok, _} = eval("X", [F6,F3,F7,F4], S), + ?line {ok, _} = eval("X * AM", [F6,F3,F7,F4], S), + ?line {ok, _} = eval("X * a2", [F3,F7], S), + + ?line {ok, _} = eval("L * r1", [F1,F2], S), + ?line {ok, _} = eval("U", [UF1, UF2], S), + ?line {ok, _} = eval("U * AM", [UF1], S), + ?line {ok, _} = eval("U * UM", [UF2], S), + ?line {ok, _} = eval("XU * [m1, m2]", [F6,F3,F7,UF1], S), + ?line {ok, _} = eval("LU * [m3, m4]", [F5], S), + ?line {ok, _} = eval("UU", [F1,F2], S), + + ?line {ok, _} = eval("XC | m1", [E1,E2,E4], S), + ?line {ok, _} = eval(f("XC | ~p", [F1]), [E1,E4], S), + ?line {ok, _} = eval(f("(XXL) (Lin) (XC | ~p)", [F1]), + [{{D1,D3},[13]},{{D1,D4},[7]}],S), + ?line {ok, _} = eval(f("XC | (~p + ~p)", [F1, F2]), [E1,E4,E3,UE1], S), + ?line {ok, _} = eval(f("(XXL) (Lin) (XC | ~p)", [F1]), + [{{D1,D3},[13]},{{D1,D4},[7]}], S), + ?line {ok, _} = eval("LC | m3", [E5], S), + ?line {ok, _} = eval(f("LC | ~p", [F1]), [E7], S), + ?line {ok, _} = eval(f("LC | (~p + ~p)", [F1, F4]), [E7, E5], S), + ?line {ok, _} = eval("E | m1", [E1,E2,E4,E7], S), + ?line {ok, _} = eval(f("E | ~p", [F1]), [E1,E7,E4], S), + ?line {ok, _} = eval(f("E | (~p + ~p)", [F1, F2]), [E1,E7,E4,E3,UE1], S), + + ?line {ok, _} = eval("XC || m1", [E3,UE2], S), + ?line {ok, _} = eval(f("XC || ~p", [F6]), [E3], S), + ?line {ok, _} = eval(f("XC || (~p + ~p)", [F4, UF2]), [UE1,E4,E6], S), + ?line {ok, _} = eval("LC || m3", [E5], S), + ?line {ok, _} = eval(f("LC || ~p", [F1]), [], S), + ?line {ok, _} = eval(f("LC || ~p", [F6]), [E7], S), + ?line {ok, _} = eval(f("LC || (~p + ~p)", [F5, F6]), [E7,E5], S), + ?line {ok, _} = eval("E || m1", [E3,UE2,E7], S), + ?line {ok, _} = eval(f("E || ~p", [F6]), [E3,E7], S), + ?line {ok, _} = eval(f("E || (~p + ~p)", [F3,F4]), [E1,E4,E6], S), + + ?line {ok, _} = eval(f("~p + ~p", [F1,F2]), [F1,F2], S), + ?line {ok, _} = eval(f("~p * ~p", [m1,[F1,F6,F2]]), [F1,F6], S), + ?line {ok, _} = eval(f("~p * ~p", [F1,F2]), [], S), + + %% range, domain + ?line {ok, _} = eval("range (E || m1)", [F6,UF1], S), + ?line {ok, _} = eval("domain (E || m1)", [F1,F2,F5], S), + ?line {ok, _} = eval(f("E | domain ~p", [[E1, {F2,F4}]]), + [E1,E7,E4,E3,UE1], S), + + %% components, condensation, use, call + ?line {ok, _} = eval("(Lin) components E", type_error, S), + ?line {ok, _} = eval("components (Lin) E", type_error, S), + ?line {ok, _} = eval("components V", type_error, S), + ?line {ok, _} = eval("components E + components E", type_error, S), + + ?line {ok, _} = eval(f("range (closure E | ~p)", [[F1,F2]]), + [F6,F3,F7,F4,F5,UF1,UF2], S), + ?line {ok, _} = + eval(f("domain (closure E || ~p)", [[UF2,F7]]), [F1,F2,F6], S), + ?line {ok, _} = eval("components E", [], S), + ?line {ok, _} = eval("components (Mod) E", [[m1,m2,m3]], S), + ?line {ok, _} = eval("components closure (Mod) E", [[m1,m2,m3]], S), + ?line {ok, _} = eval("condensation (Mod) E", + [{[m1,m2,m3],[m1,m2,m3]},{[m1,m2,m3],[m17]}], S), + ?line {ok, _} = eval("condensation closure (Mod) E", + [{[m1,m2,m3],[m1,m2,m3]},{[m1,m2,m3],[m17]}], S), + ?line {ok, _} = eval("condensation closure closure closure (Mod) E", + [{[m1,m2,m3],[m1,m2,m3]},{[m1,m2,m3],[m17]}], S), + ?line {ok, _} = eval("weak condensation (Mod) E", + [{[m1,m2,m3],[m1,m2,m3]},{[m1,m2,m3],[m17]},{[m17],[m17]}], S), + ?line {ok, _} = eval("strict condensation (Mod) E", + [{[m1,m2,m3],[m17]}], S), + ?line {ok, _} = eval("range condensation (Mod) E", + [[m1,m2,m3],[m17]], S), + ?line {ok, _} = eval("domain condensation (Mod) E", + [[m1,m2,m3]], S), + + %% |, ||, ||| + ?line {ok, _} = eval("(Lin) E || V", type_error, S), + ?line {ok, _} = eval("E ||| (Lin) V", type_error, S), + ?line {ok, _} = eval("E ||| m1", [E7], S), + ?line {ok, _} = eval("closure E ||| m1", [E7,{F1,UF1},{F6,UF1}], S), + ?line {ok, _} = eval("closure E ||| [m1,m2]", + [{F1,UF1},{F2,F7},{F1,F7},{F6,UF1},{F2,UF1},{F7,UF1},E7,E1,E2,E3], S), + ?line {ok, _} = eval("AE | a1", [{a1,a1},{a1,a2},{a1,a3}], S), + + %% path ('of') + ?line {ok, _} = eval("(Lin) {m1,m2} of E", type_error, S), + ?line {ok, _} = eval("{m1,m2} of (Lin) E", type_error, S), + ?line [m1,m2] = eval("{m1,m2} of {m1,m2}", S), + ?line {ok, _} = eval("{m1,m2} of m1", type_error, S), + ?line {ok, _} = eval("{a3,m1} of ME", type_mismatch, S), + ?line [m1,m1] = eval("{m1} of ME", S), + ?line [m1,m1] = eval("{m1} of closure closure ME", S), + ?line false = eval("{m17} of ME", S), + ?line [m2,m1,m2] = eval("{m2} : Mod of ME", S), + ?line [m1,m2,m17] = eval("{m1, m17} of ME", S), + ?line [m1,m2,m17] = eval("m1 -> m17 of ME", S), + ?line {ok, _} = eval("[m1->m17,m17->m1] of ME", type_error, S), + ?line case eval(f("~p of E", [{F1,F7,UF1}]), S) of + [F1,F6,F7,F4,F5,UF1] -> ok + end, + ?line [a2,a1,a2] = eval("{a2} of AE", S), + + %% weak/strict + ?line {ok, _} = eval("weak {m1,m2}", [{m1,m1},{m1,m2},{m2,m2}], S), + ?line {ok, _} = eval("strict [{m1,m1},{m1,m2},{m2,m2}]", [{m1,m2}], S), + ?line {ok, _} = eval("range weak [{m1,m2}] : Mod", [m1,m2], S), + ?line {ok, _} = eval("domain strict [{m1,m1},{m1,m2},{m2,m2}]", [m1], S), + + %% #, number of + ?line {ok, _} = eval("# [{r1,r2}] : Rel", 1, S), + ?line {ok, _} = eval("# [{a3,a1}] : App", 1, S), + ?line {ok, _} = eval("# AE", 7, S), + ?line {ok, _} = eval("# ME", 8, S), + ?line {ok, _} = eval("# AE + # ME", 15, S), + ?line {ok, _} = eval("# AE * # ME", 56, S), + ?line {ok, _} = eval("# AE - # ME", -1, S), + ?line {ok, _} = eval("# E", 9, S), + ?line {ok, _} = eval("# V", 9, S), + ?line {ok, _} = eval("# (Lin) E", 9, S), + ?line {ok, _} = eval("# (ELin) E", 7, S), + ?line {ok, _} = eval("# closure E", type_error, S), + ?line {ok, _} = eval("# weak {m1,m2}", 3, S), + ?line {ok, _} = eval("#strict condensation (Mod) E", 1, S), + ?line {ok, _} = eval("#components closure (Mod) E", 1, S), + ?line {ok, _} = eval("# range strict condensation (Mod) E", 1, S), + ok. + +md(suite) -> []; +md(doc) -> ["The xref:m() and xref:d() functions"]; +md(Conf) when is_list(Conf) -> + CopyDir = ?copydir, + Dir = fname(CopyDir,"md"), + X = fname(Dir, "x__x.erl"), + Y = fname(Dir, "y__y.erl"), + Xbeam = fname(Dir, "x__x.beam"), + Ybeam = fname(Dir, "y__y.beam"), + + ?line {error, _, {invalid_filename,{foo,bar}}} = xref:m({foo,bar}), + ?line {error, _, {invalid_filename,{foo,bar}}} = xref:d({foo,bar}), + + ?line {ok, x__x} = compile:file(X, [debug_info, {outdir,Dir}]), + ?line {ok, y__y} = compile:file(Y, [debug_info, {outdir,Dir}]), + + ?line {error, _, {no_such_module, foo_bar}} = xref:m(foo_bar), + ?line OldPath = code:get_path(), + ?line true = code:set_path([Dir | OldPath]), + ?line MInfo = xref:m(x__x), + ?line [{{x__x,t,1},{y__y,t,2}}] = info_tag(MInfo, undefined), + ?line [] = info_tag(MInfo, unused), + ?line [] = info_tag(MInfo, deprecated), + ?line DInfo = xref:d(Dir), + ?line [{{x__x,t,1},{y__y,t,2}}] = info_tag(DInfo, undefined), + ?line [{y__y,l,0},{y__y,l1,0}] = info_tag(DInfo, unused), + ?line [] = info_tag(MInfo, deprecated), + + %% Switch from 'functions' mode to 'modules' mode. + ?line {ok, x__x} = compile:file(X, [no_debug_info, {outdir,Dir}]), + ?line {ok, y__y} = compile:file(Y, [no_debug_info, {outdir,Dir}]), + ?line MInfoMod = xref:m(x__x), + ?line [{y__y,t,2}] = info_tag(MInfoMod, undefined), + ?line [] = info_tag(MInfo, deprecated), + ?line DInfoMod = xref:d(Dir), + ?line [{y__y,t,2}] = info_tag(DInfoMod, undefined), + ?line [] = info_tag(MInfo, deprecated), + + ?line true = code:set_path(OldPath), + ?line ok = file:delete(Xbeam), + ?line ok = file:delete(Ybeam), + ok. + +q(suite) -> []; +q(doc) -> ["User queries"]; +q(Conf) when is_list(Conf) -> + ?line S0 = new(), + ?line {ok, _} = eval("'foo", parse_error, S0), + ?line {ok, _} = eval("TT = E, TT = V", variable_reassigned, S0), + ?line {ok, _} = eval("TT = E, TTT", unknown_variable, S0), + ?line {ok, S} = eval("TT := E", [], S0), + ?line {ok, S1} = eval("TT * TT * TT", [], S), + ?line {ok, _S2} = xref_base:forget(S1, 'TT'), + ok. + +variables(suite) -> []; +variables(doc) -> ["Setting and getting values of query variables"]; +variables(Conf) when is_list(Conf) -> + ?line Sa = new(), + ?line {{error, _, {invalid_options,[not_an_option]}}, _} = + xref_base:variables(Sa, [not_an_option]), + ?line {error, _, {not_user_variable,foo}} = xref_base:forget(Sa, foo), + ?line Sa1 = set_up(Sa), + ?line {error, _, {not_user_variable,foo}} = xref_base:forget(Sa1, foo), + ?line ok = xref_base:delete(Sa1), + + ?line S0 = new(), + + F1 = {m1,f1,1}, + F2 = {m2,f1,2}, + Lib = {lib1,f1,1}, % undefined + + E1 = {F1,F2}, + E2 = {F2,F1}, + E3 = {F1,Lib}, + + D1 = {F1,12}, + DefAt_m1 = [D1], + X_m1 = [F1], + % L_m1 = [], + XC_m1 = [E1,E3], + LC_m1 = [], + LCallAt_m1 = [], + XCallAt_m1 = [{E1,13},{E3,17}], + Info1 = #xref_mod{name = m1, app_name = [a1]}, + ?line S1 = add_module(S0, Info1, DefAt_m1, X_m1, LCallAt_m1, XCallAt_m1, + XC_m1, LC_m1), + + D2 = {F2,7}, + DefAt_m2 = [D2], + X_m2 = [F2], + % L_m2 = [], + XC_m2 = [E2], + LC_m2 = [], + LCallAt_m2 = [], + XCallAt_m2 = [{E2,96}], + Info2 = #xref_mod{name = m2, app_name = [a2]}, + ?line S2 = add_module(S1, Info2, DefAt_m2, X_m2, LCallAt_m2, XCallAt_m2, + XC_m2, LC_m2), + + ?line S = set_up(S2), + + ?line eval("T1=E, T2=E*T1, T3 = T2*T2, T4=range T3, T5=T3|T4, T5", + [E1,E2,E3], S), + ?line eval("((E*E)*(E*E)) | (range ((E*E)*(E*E)))", + [E1,E2,E3], S), + ?line eval("T1=V*V,T2=T1*V,T3=V*V*V,T3", + [F1,F2,Lib], S), + ?line eval("T1=V*V, T2=V*V, T1*T2", + [F1,F2,Lib], S), + + ?line {ok, S100} = eval("T0 := E", [E1, E2, E3], S), + ?line {ok, S101} = eval("T1 := E | m1", [E1, E3], S100), + ?line {ok, S102} = eval("T2 := E | m2", [E2], S101), + ?line {{ok, [{user, ['T0', 'T1', 'T2']}]}, _} = xref_base:variables(S102), + ?line {ok, S103} = xref_base:forget(S102, 'T0'), + ?line {{ok, [{user, ['T1', 'T2']}]}, S104} = + xref_base:variables(S103, [user]), + ?line {ok, S105} = xref_base:forget(S104), + ?line {{ok, [{user, []}]}, S106} = xref_base:variables(S105), + ?line {{ok, [{predefined,_}]}, S107_0} = + xref_base:variables(S106, [predefined]), + + ?line {ok, S107_1} = + eval("TT := E, TT2 := V, TT1 := TT * TT", [E1,E2,E3], S107_0), + ?line {{ok, [{user, ['TT', 'TT1', 'TT2']}]}, _} = + xref_base:variables(S107_1), + ?line {ok, S107} = xref_base:forget(S107_1), + + CopyDir = ?copydir, + ?line Dir = fname(CopyDir,"lib_test"), + Beam = fname(Dir, "lib1.beam"), + + ?line copy_file(fname(Dir, "lib1.erl"), Beam), + ?line {ok, S108} = + xref_base:set_library_path(S107, [Dir], [{verbose,false}]), + ?line {{error, _, _}, _} = xref_base:variables(S108, [{verbose,false}]), + ?line {ok, S109} = xref_base:set_library_path(S108, [], [{verbose,false}]), + + ?line Tabs = length(ets:all()), + + ?line {ok, S110} = eval("Eplus := closure E, TT := Eplus", + 'closure()', S109), + ?line {{ok, [{user, ['Eplus','TT']}]}, S111} = xref_base:variables(S110), + ?line {ok, S112} = xref_base:forget(S111, ['TT','Eplus']), + ?line true = Tabs =:= length(ets:all()), + + ?line {ok, NS0} = eval("Eplus := closure E", 'closure()', S112), + ?line {{ok, [{user, ['Eplus']}]}, NS} = xref_base:variables(NS0), + ?line ok = xref_base:delete(NS), + ?line true = Tabs =:= length(ets:all()), + + ?line ok = file:delete(Beam), + ok. + +unused_locals(suite) -> []; +unused_locals(doc) -> ["OTP-5071. Too many unused functions."]; +unused_locals(Conf) when is_list(Conf) -> + Dir = ?copydir, + + File1 = fname(Dir, "a.erl"), + MFile1 = fname(Dir, "a"), + Beam1 = fname(Dir, "a.beam"), + Test1 = <<"-module(a). + -export([f/1, g/2]). + + f(X) -> + Y = b:f(X), + Z = b:g(Y), + start(b, h, [Z]). + + g(X, Y) -> + ok. + + start(M, F, A) -> + spawn(M, F, A). + ">>, + ?line ok = file:write_file(File1, Test1), + ?line {ok, a} = compile:file(File1, [debug_info,{outdir,Dir}]), + + File2 = fname(Dir, "b.erl"), + MFile2 = fname(Dir, "b"), + Beam2 = fname(Dir, "b.beam"), + Test2 = <<"-module(b). + -export([f/1, g/2]). + + f(X) -> + io:write(\"~w\", [X]), + a:start(timer, sleep, [1000]). + + g(X, Y) -> + apply(a, g, [X, Y]). + ">>, + + ?line ok = file:write_file(File2, Test2), + ?line {ok, b} = compile:file(File2, [debug_info,{outdir,Dir}]), + + ?line {ok, _} = xref:start(s), + ?line {ok, a} = xref:add_module(s, MFile1), + ?line {ok, b} = xref:add_module(s, MFile2), + ?line {ok, []} = xref:analyse(s, locals_not_used), + ?line ok = check_state(s), + ?line xref:stop(s), + + ?line ok = file:delete(File1), + ?line ok = file:delete(Beam1), + ?line ok = file:delete(File2), + ?line ok = file:delete(Beam2), + ok. + +misc(suite) -> + [format_error, otp_7423, otp_7831]. + +format_error(suite) -> []; +format_error(doc) -> ["Format error messages"]; +format_error(Conf) when is_list(Conf) -> + ?line {ok, _Pid} = start(s), + ?line ok = xref:set_default(s, [{verbose,false}, {warnings, false}]), + + %% Parse error messages. + ?line 'Invalid regular expression "add(": unterminated \`(\'\n' + = fatom(xref:q(s,'"add("')), + ?line 'Invalid operator foo\n' = + fatom(xref:q(s,'foo E')), + ?line 'Invalid wildcard variable \'_Var\' (only \'_\' is allowed)\n' + = fatom(xref:q(s,"module:function/_Var")), + ?line 'Missing type of regular expression ".*"\n' + = fatom(xref:q(s,'".*"')), + ?line 'Type does not match structure of constant: \'M\' : Fun\n' + = fatom(xref:q(s,"'M' : Fun")), + ?line 'Type does not match structure of constant: ".*" : Fun\n' + = fatom(xref:q(s,'".*" : Fun')), + ?line 'Type does not match structure of constant: [m:f/1, m1:f2/3] : App\n' + = fatom(xref:q(s,"[m:f/1,m1:f2/3] : App")), + ?line 'Parse error on line 1: syntax error before: \'-\'\n' = + fatom(xref:q(s,"E + -")), + ?line "Parse error on line 1: unterminated atom starting with 'foo'\n" + = flatten(xref:format_error(xref:q(s,"'foo"))), + ?line 'Parse error at end of string: syntax error before: \n' = + fatom(xref:q(s,"E +")), + ?line 'Parse error on line 1: syntax error before: \'Lin\'\n' = + fatom(xref:q(s,"Lin")), + + %% Other messages + ?line 'Variable \'QQ\' used before set\n' = + fatom(xref:q(s,"QQ")), + ?line 'Unknown constant a\n' = + fatom(xref:q(s,"{a} of E")), + + %% Testing xref_parser:t2s/1. + ?line 'Variable assigned more than once: E := E + E\n' = + fatom(xref:q(s,"E:=E + E")), + ?line 'Variable assigned more than once: E = E + E\n' = + fatom(xref:q(s,"E=E + E")), + ?line "Operator applied to argument(s) of different or invalid type(s): " + "E + V * V\n" = + flatten(xref:format_error(xref:q(s,"E + (V * V)"))), + ?line {error,xref_compiler,{type_error,"(V + V) * E"}} = + xref:q(s,"(V + V) * E"), + ?line "Type does not match structure of constant: [m:f/3 -> g:h/17] : " + "App\n" = + flatten(xref:format_error(xref:q(s,"[{{m,f,3},{g,h,17}}] : App"))), + ?line 'Type does not match structure of constant: [m -> f, g -> h] : Fun\n' + = fatom(xref:q(s,"[{m,f},g->h] : Fun")), + ?line 'Type does not match structure of constant: {m, n, o} : Fun\n' = + fatom(xref:q(s,"{m,n,o} : Fun")), + ?line {error,xref_compiler,{type_error,"range (Lin) V"}} = + xref:q(s,"range ((Lin) V)"), + ?line {error,xref_compiler,{type_error,"condensation range E"}} = + xref:q(s,"condensation (range E)"), + ?line {error,xref_compiler,{type_error,"condensation (# E + # V)"}} = + xref:q(s,"condensation (# E + # V)"), + ?line {error,xref_compiler,{type_error,"range (# E + # E)"}} = + xref:q(s,"range (#E + #E)"), + ?line {error,xref_compiler,{type_error,"range (# E)"}} = + xref:q(s,"range #E"), % Hm... + ?line {error,xref_compiler,{type_error,"E + # E"}} = + xref:q(s,"E + #E + #E"), % Hm... + ?line {error,xref_compiler,{type_error,"V * E || V | V"}} = + xref:q(s,"V * (E || V) | V"), + ?line {error,xref_compiler,{type_error,"E || (E | V)"}} = + xref:q(s,"V * E || (E | V)"), + ?line {error,xref_compiler,{type_error,"E * \"m\" : Mod"}} = + xref:q(s,'E * "m" : Mod'), + ?line {error,xref_compiler,{type_error,"E * (\"m\":f/_ + m:\"f\"/3)"}} = + xref:q(s,'E * ("m":f/_ + m:"f"/3)'), + + ?line xref:stop(s), + ok. + +otp_7423(suite) -> []; +otp_7423(doc) -> ["OTP-7423. Xref scanner bug."]; +otp_7423(Conf) when is_list(Conf) -> + ?line {ok, _Pid} = start(s), + S = "E | [compiler] : App || [{erlang, + size, + 1}] : Fun", + ?line {error,xref_compiler,{unknown_constant,"compiler"}} = xref:q(s,S), + ?line xref:stop(s), + ok. + +otp_7831(suite) -> []; +otp_7831(doc) -> ["OTP-7831. Allow anonymous Xref processes."]; +otp_7831(Conf) when is_list(Conf) -> + ?line {ok, Pid1} = xref:start([]), + ?line xref:stop(Pid1), + ?line {ok, Pid2} = xref:start([{xref_mode, modules}]), + ?line xref:stop(Pid2), + ok. + +%%% +%%% Utilities +%%% + +copy_file(Src, Dest) -> + file:copy(Src, Dest). + +fname(N) -> + filename:join(N). + +fname(Dir, Basename) -> + filename:join(Dir, Basename). + +new() -> + ?line {ok, S} = xref_base:new(), + S. + +set_up(S) -> + ?line {ok, S1} = xref_base:set_up(S, [{verbose, false}]), + S1. + +eval(Query, E, S) -> + ?format("------------------------------~n", []), + ?format("Evaluating ~p~n", [Query]), + ?line {Answer, NewState} = xref_base:q(S, Query, [{verbose, false}]), + {Reply, Expected} = + case Answer of + {ok, R} when is_list(E) -> + {unsetify(R), sort(E)}; + {ok, R} -> + {unsetify(R), E}; + {error, _Module, Reason} -> + {element(1, Reason), E} + end, + if + Reply =:= Expected -> + ?format("As expected, got ~n~p~n", [Expected]), + {ok, NewState}; + true -> + ?format("Expected ~n~p~nbut got ~n~p~n", [Expected, Reply]), + not_ok + end. + +analyze(Query, E, S) -> + ?format("------------------------------~n", []), + ?format("Evaluating ~p~n", [Query]), + ?line {{ok, L}, NewState} = + xref_base:analyze(S, Query, [{verbose, false}]), + case {unsetify(L), sort(E)} of + {X,X} -> + ?format("As was expected, got ~n~p~n", [X]), + {ok, NewState}; + {_R,_X} -> + ?format("Expected ~n~p~nbut got ~n~p~n", [_X, _R]), + not_ok + end. + +unsetify(S) -> + case is_sofs_set(S) of + true -> to_external(S); + false -> S + end. + +%% Note: assumes S has been set up; the new state is not returned +eval(Query, S) -> + ?line {{ok, Answer}, _NewState} = + xref_base:q(S, Query, [{verbose, false}]), + unsetify(Answer). + +add_module(S, XMod, DefAt, X, LCallAt, XCallAt, XC, LC) -> + Attr = {[], [], []}, + Depr0 = {[], [], [], []}, + DBad = [], + Depr = {Depr0,DBad}, + Data = {DefAt, LCallAt, XCallAt, LC, XC, X, Attr, Depr}, + Unres = [], + ?line {ok, _Module, _Bad, State} = + xref_base:do_add_module(S, XMod, Unres, Data), + State. + +add_application(S, XApp) -> + ?line xref_base:do_add_application(S, XApp). + +add_release(S, XRel) -> + ?line xref_base:do_add_release(S, XRel). + +remove_module(S, M) -> + ?line xref_base:do_remove_module(S, M). + +info_tag(Info, Tag) -> + {value, {_Tag, Value}} = lists:keysearch(Tag, 1, Info), + Value. + +make_ufile(FileName) -> + ?line ok = file:write_file(FileName, term_to_binary(foo)), + ?line hide_file(FileName). + +make_udir(Dir) -> + ?line ok = file:make_dir(Dir), + ?line hide_file(Dir). + +hide_file(FileName) -> + ?line {ok, FileInfo} = file:read_file_info(FileName), + ?line NewFileInfo = FileInfo#file_info{mode = 0}, + ?line ok = file:write_file_info(FileName, NewFileInfo). + +%% Note that S has to be set up before calling this checking function. +check_state(S) -> + ?line Info = xref:info(S), + + ?line modules_mode_check(S, Info), + case info(Info, mode) of + modules -> + ok; + functions -> + functions_mode_check(S, Info) + end. + +%% The manual mentions some facts that should always hold. +%% Here they are again. +functions_mode_check(S, Info) -> + %% F = L + X, + ?line {ok, F} = xref:q(S, "F"), + ?line {ok, F} = xref:q(S, "L + X"), + + %% V = X + L + B + U, + ?line {ok, V} = xref:q(S, "V"), + ?line {ok, V} = xref:q(S, "X + L + B + U"), + + %% X, L, B and U are disjoint. + ?line {ok, []} = + xref:q(S, "X * L + X * B + X * U + L * B + L * U + B * U"), + + %% V = UU + XU + LU, + ?line {ok, V} = xref:q(S, "UU + XU + LU"), + + %% E = LC + XC + ?line {ok, E} = xref:q(S, "E"), + ?line {ok, E} = xref:q(S, "LC + XC"), + + %% U subset of XU, + ?line {ok, []} = xref:q(S, "U - XU"), + + %% LU = range LC + ?line {ok, []} = xref:q(S, "(LU - range LC) + (range LC - LU)"), + + %% XU = range XC + ?line {ok, []} = xref:q(S, "(XU - range XC) + (range XC - XU)"), + + %% LU subset F + ?line {ok, []} = xref:q(S, "LU - F"), + + %% UU subset F + ?line {ok, []} = xref:q(S, "UU - F"), + + %% ME = (Mod) E + ?line {ok, ME} = xref:q(S, "ME"), + ?line {ok, ME} = xref:q(S, "(Mod) E"), + + %% AE = (App) E + ?line {ok, AE} = xref:q(S, "AE"), + ?line {ok, AE} = xref:q(S, "(App) E"), + + %% RE = (Rel) E + ?line {ok, RE} = xref:q(S, "RE"), + ?line {ok, RE} = xref:q(S, "(Rel) E"), + + %% (Mod) V subset of M + ?line {ok, []} = xref:q(S, "(Mod) V - M"), + + %% range UC subset of U + ?line {ok, []} = xref:q(S, "range UC - U"), + + %% Some checks on the numbers returned by the info functions. + + ?line {Resolved, Unresolved} = info(Info, no_calls), + ?line AllCalls = Resolved + Unresolved, + ?line {ok, AllCalls} = xref:q(S, "# (XLin) E + # (LLin) E"), + + ?line {Local, Exported} = info(Info, no_functions), + ?line LX = Local+Exported, + ?line {ok, LXs} = xref:q(S, 'Extra = _:module_info/"(0|1)" + LM, + # (F - Extra)'), + ?line true = LX =:= LXs, + + ?line {LocalCalls, ExternalCalls, UnresCalls} = + info(Info, no_function_calls), + ?line LEU = LocalCalls + ExternalCalls + UnresCalls, + ?line {ok, LEU} = xref:q(S, "# LC + # XC"), + + ?line InterFunctionCalls = info(Info, no_inter_function_calls), + ?line {ok, InterFunctionCalls} = xref:q(S, "# EE"), + + %% And some more checks on counters... + ?line check_count(S), + + %% ... and more + ?line {ok, []} = xref:q(S, "LM - X - U - B"), + + ok. + +modules_mode_check(S, Info) -> + %% B subset of XU, + ?line {ok, []} = xref:q(S, "B - XU"), + + %% M = AM + LM + UM + ?line {ok, M} = xref:q(S, "M"), + ?line {ok, M} = xref:q(S, "AM + LM + UM"), + + %% DF is a subset of X U B, etc. + ?line {ok, []} = xref:q(S, "DF - X - B"), + ?line {ok, []} = xref:q(S, "DF_3 - DF"), + ?line {ok, []} = xref:q(S, "DF_2 - DF_3"), + ?line {ok, []} = xref:q(S, "DF_1 - DF_2"), + + %% AM, LM and UM are disjoint. + ?line {ok, []} = xref:q(S, "AM * LM + AM * UM + LM * UM"), + + %% (App) M subset of A + ?line {ok, []} = xref:q(S, "(App) M - A"), + + ?line AM = info(Info, no_analyzed_modules), + ?line {ok, AM} = xref:q(S, "# AM"), + + ?line A = info(Info, no_applications), + ?line {ok, A} = xref:q(S, "# A"), + + ?line NoR = info(Info, no_releases), + ?line {ok, NoR} = xref:q(S, "# R"), + + ok. + +%% Checks the counters of some of the overall and modules info functions. +%% (Applications and releases are not checked.) +check_count(S) -> + %%{ok, R} = xref:q(S, 'R'), + %% {ok, A} = xref:q(S, 'A'), + {ok, M} = xref:q(S, 'AM'), + + {ok, _} = xref:q(S, + "Extra := _:module_info/\"(0|1)\" + LM"), + + %% info/1: + {ok, NoR} = xref:q(S, '# R'), + {ok, NoA} = xref:q(S, '# A'), + {ok, NoM} = xref:q(S, '# AM'), + {ok, NoCalls} = xref:q(S, '# (XLin) E + # (LLin) E'), + {ok, NoFunCalls} = xref:q(S, '# E'), + {ok, NoXCalls} = xref:q(S, '# XC'), + {ok, NoLCalls} = xref:q(S, '# LC'), + {ok, NoLXCalls} = xref:q(S, '# (XC * LC)'), + NoAllCalls = NoXCalls + NoLCalls, + {ok, NoFun} = xref:q(S, '# (F - Extra)'), + {ok, NoICalls} = xref:q(S, '# EE'), + + Info = xref:info(S), + NoR = info(Info, no_releases), + NoA = info(Info, no_applications), + NoM = info(Info, no_analyzed_modules), + {NoResolved, NoUC} = info(Info, no_calls), + NoCalls = NoResolved + NoUC, + {NoLocal, NoExternal, NoUnres} = info(Info, no_function_calls), + NoAllCalls = NoLocal + NoExternal + NoUnres, + NoAllCalls = NoFunCalls + NoLXCalls, + {NoLocalFuns, NoExportedFuns} = info(Info, no_functions), + NoFun = NoLocalFuns + NoExportedFuns, + NoICalls = info(Info, no_inter_function_calls), + + %% per module + info_module(M, S), + + ok. + +info_module([M | Ms], S) -> + {ok, NoCalls} = per_module("T = (E | ~p : Mod), # (XLin) T + # (LLin) T", + M, S), + {ok, NoFunCalls} = per_module("# (E | ~p : Mod)", M, S), + {ok, NoXCalls} = per_module("# (XC | ~p : Mod)", M, S), + {ok, NoLCalls} = per_module("# (LC | ~p : Mod)", M, S), + {ok, NoLXCalls} = per_module("# ((XC * LC) | ~p : Mod)", M, S), + NoAllCalls = NoXCalls + NoLCalls, + {ok, NoFun} = per_module("# (F * ~p : Mod - Extra)", M, S), + {ok, NoICalls} = per_module("# (EE | ~p : Mod)", M, S), + + [{_M,Info}] = xref:info(S, modules, M), + {NoResolved, NoUC} = info(Info, no_calls), + NoCalls = NoResolved + NoUC, + {NoLocal, NoExternal, NoUnres} = info(Info, no_function_calls), + NoAllCalls = NoLocal + NoExternal + NoUnres, + NoAllCalls = NoFunCalls + NoLXCalls, + {NoLocalFuns, NoExportedFuns} = info(Info, no_functions), + NoFun = NoLocalFuns + NoExportedFuns, + NoICalls = info(Info, no_inter_function_calls), + + info_module(Ms, S); +info_module([], _S) -> + ok. + +per_module(Q, M, S) -> + xref:q(S, f(Q, [M])). + +info(Info, What) -> + {value, {What, Value}} = lists:keysearch(What, 1, Info), + Value. + +f(S, A) -> + flatten(io_lib:format(S, A)). + +fatom(R) -> + list_to_atom(flatten(xref:format_error(R))). + +start(Server) -> + ?line case xref:start(Server) of + {error, {already_started, _Pid}} -> + ?line xref:stop(Server), + ?line xref:start(Server); + R -> R + end. + +add_erts_code_path(KernelPath) -> + VersionDirs = + filelib:is_dir( + filename:join( + [code:lib_dir(), + lists:flatten( + ["kernel-", + [X || + {kernel,_,X} <- + application_controller:which_applications()]])])), + case VersionDirs of + true -> + case code:lib_dir(erts) of + String when is_list(String) -> + [KernelPath, fname(String,"ebin")]; + _Other1 -> + [KernelPath] + end; + false -> + % Clearcase? + PrelPath = filename:join([code:lib_dir(),"..","erts","preloaded"]), + case filelib:is_dir(PrelPath) of + true -> + [KernelPath, fname(PrelPath,"ebin")]; + false -> + [KernelPath] + end + end. + + diff --git a/lib/tools/test/xref_SUITE_data/depr_r9c.beam b/lib/tools/test/xref_SUITE_data/depr_r9c.beam Binary files differnew file mode 100644 index 0000000000..82f0eef5a1 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/depr_r9c.beam diff --git a/lib/tools/test/xref_SUITE_data/dir/dir/dummy b/lib/tools/test/xref_SUITE_data/dir/dir/dummy new file mode 100644 index 0000000000..7f62a93220 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/dir/dir/dummy @@ -0,0 +1,2 @@ +This directory is not empty. +Prevents winzip from removing the directory. diff --git a/lib/tools/test/xref_SUITE_data/dir/jam/x.jam b/lib/tools/test/xref_SUITE_data/dir/jam/x.jam new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/dir/jam/x.jam diff --git a/lib/tools/test/xref_SUITE_data/lib_test/cp.erl b/lib/tools/test/xref_SUITE_data/lib_test/cp.erl new file mode 100644 index 0000000000..efe5d77854 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/lib_test/cp.erl @@ -0,0 +1,6 @@ +-module(cp). + +-export([t/0]). + +t() -> + lists:sort(a). diff --git a/lib/tools/test/xref_SUITE_data/lib_test/lib1.erl b/lib/tools/test/xref_SUITE_data/lib_test/lib1.erl new file mode 100644 index 0000000000..7d50fcb1af --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/lib_test/lib1.erl @@ -0,0 +1,6 @@ +-module(lib1). + +-export([f/0]). + +f() -> + true. diff --git a/lib/tools/test/xref_SUITE_data/lib_test/lib2.erl b/lib/tools/test/xref_SUITE_data/lib_test/lib2.erl new file mode 100644 index 0000000000..ca505dfd4f --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/lib_test/lib2.erl @@ -0,0 +1,14 @@ +-module(lib2). + +-export([f/0, g/0]). + +-deprecated({f,0,next_major_release}). + +f() -> + local(). + +g() -> + true. + +local() -> + true. diff --git a/lib/tools/test/xref_SUITE_data/lib_test/lib3.erl b/lib/tools/test/xref_SUITE_data/lib_test/lib3.erl new file mode 100644 index 0000000000..8a900f8040 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/lib_test/lib3.erl @@ -0,0 +1,11 @@ +-module(lib3). + +-export([f/0, g/0]). + +-deprecated(module). + +f() -> + true. + +g() -> + true. diff --git a/lib/tools/test/xref_SUITE_data/lib_test/t.erl b/lib/tools/test/xref_SUITE_data/lib_test/t.erl new file mode 100644 index 0000000000..d2bd81110e --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/lib_test/t.erl @@ -0,0 +1,14 @@ +-module(t). + +-export([t/0]). + +t() -> + %% lib1: only unknown functions used + %% lib2: one known used, one unknown function used, one local used + %% lib3: one known function used + lib1:unknown(), + lib2:f(), %% known, g/0 not used + lib2:unknown(), + lib2:local(), + lib3:f(), + unknown:unknown(). diff --git a/lib/tools/test/xref_SUITE_data/md/x__x.erl b/lib/tools/test/xref_SUITE_data/md/x__x.erl new file mode 100644 index 0000000000..83234e1d3f --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/md/x__x.erl @@ -0,0 +1,7 @@ +-module(x__x). + +-export([t/1]). + +t(A) -> + y__y:t(A), + y__y:t(A,A). diff --git a/lib/tools/test/xref_SUITE_data/md/y__y.erl b/lib/tools/test/xref_SUITE_data/md/y__y.erl new file mode 100644 index 0000000000..b2bb783fd8 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/md/y__y.erl @@ -0,0 +1,12 @@ +-module(y__y). + +-export([t/1]). + +t(A) -> + x__x:t(A). + +l() -> + l1(). + +l1() -> + l(). diff --git a/lib/tools/test/xref_SUITE_data/read/read.beam.v1 b/lib/tools/test/xref_SUITE_data/read/read.beam.v1 Binary files differnew file mode 100644 index 0000000000..3b8e9c4c38 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/read/read.beam.v1 diff --git a/lib/tools/test/xref_SUITE_data/read/read.erl b/lib/tools/test/xref_SUITE_data/read/read.erl new file mode 100644 index 0000000000..4a0cc280c3 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/read/read.erl @@ -0,0 +1,175 @@ +-module(read). + +-export([lc/0, funfuns/0, bi/0]). + +-xref({xx,ff,22}). +-xref({{all,0},{no,0}}). +-xref([{{all,0},{i,0}},{{all,0},{x2,5}}]). +-xref([apa]). +-xref({all,0}). +-xref([{{{all},0},{no,0}},{{all,0},{m,x2,5}}]). +-xref([{{a,14},{q,f,17}}]). +-xref({{i,f,17},{g,18}}). +-xref({{j,f,17},{i,g,18}}). + +-xref({{funfuns,0},{'$F_EXPR',177}}). +-xref({{funfuns,0},{?MODULE,'$F_EXPR',178}}). +-xref({{funfuns,0},{modul,'$F_EXPR',179}}). + +lc() -> + Tab = ets:new(), + [Mt||{_M,Mt} <- ets:tab2list(Tab)]. + +funfuns() -> + A = variable, + + %% Spawn... + + %% Recognized. POS1=28. + spawn(fun() -> mod17:fun17() end), + spawn(fun local/0), + spawn(fun binary_to_term/1), % builtin, not collected + spawn({dist,func}), + spawn({dist,A}), % {dist,'$F_EXPR',0} + spawn_link(fun() -> mod17:fun17() end), + spawn_link({dist,func}), + spawn_link({dist,A}), % {dist,'$F_EXPR',0} + + %% POS2=POS1+10 + spawn({dist,func}(arg1,arg2), {d,f}), + spawn({dist,func}(arg1,arg2), fun() -> mod42:func() end), + spawn_link({dist,func}(arg1,arg2), {d,f}), + spawn_link({dist,func}(arg1,arg2), fun() -> mod42:func() end), + + %% POS3=POS2+6 + spawn(dist, func, [arg1,arg2]), % spawn/3 is builtin + spawn(expr, A, [arg1]), % {expr,'$F_EXPR',1} + spawn_link(dist, func, [arg1,arg2]), % spawn_link/3 is builtin + spawn_link(expr, A, [arg1,arg2]), % {expr,'$F_EXPR',2} + + %% POS4=POS3+6 + spawn(node, modul, function, []), + spawn(node, modul, A, [a]), % {modul,'$F_EXPR',1} + spawn({dist,func}(arg1,arg2), spm, spf, [a,b]), + spawn({dist,func}(arg1,arg2), spm, A, [a]), % {spm,'$F_EXPR',1} + spawn_link({dist,func}(arg1,arg2), spm, spf, [a,b]), + spawn_link({dist,func}(arg1,arg2), spm, A, [a]), % {spm,'$F_EXPR',1} + spawn_opt(spm, spf, [arg3, arg4], [opt1, bi()]), + spawn_opt(spm, A, [a], [opt1, bi()]), % {spm,'$F_EXPR',1} + + %% Not recognized or invalid. POS5=POS4+10 + spawn(A), % {'$M_EXPR','$F_EXPR',0} + spawn(17), % {'$M_EXPR','$F_EXPR',0} + spawn_link(A), % {'$M_EXPR','$F_EXPR',0} + + %% POS6=POS5+5 + spawn({a,b},[1008]), % {'$M_EXPR','$F_EXPR',0} + spawn_link({a,b},[1008]), % {'$M_EXPR','$F_EXPR',0} + + spawn(n, A, A), % {n,'$F_EXPR',-1} + + %% POS7=POS6+6 + spawn(n, A,f,[1007]), % {'$M_EXPR',f,1}, spawn/3 is builtin + spawn_opt(A,f,[1007],[]), % {'$M_EXPR',f,1} + + %% Apply... + + %% Recognized. POS8=POS7+6 + {hej,san}(1002), + {hej,A}(1002), % {hej,'$F_EXPR',1} + t:A(1003), % {t,'$F_EXPR',1} + apply({a,b},[1005]), + apply({a,A},[1005]), % {a,'$F_EXPR',1} + apply(m,f,[100011]), + apply(m,A,[100011]), % {m,'$F_EXPR',1} + %% POS9=POS8+8 + apply(A, f, [bi()]), % {'$M_EXPR',f,1} + {erlang,apply}({a,b},[8888]), + {erlang,apply}({a,A},[8888]), % {a,'$F_EXPR',1} + {erlang,apply}({erlang,apply},[{erlang,not_a_function},[7777]]), + apply(erlang, apply, [erlang, apply, [mod, func, [atom77,tjohej]]]), + erlang:apply(foo), % not an apply, but an unknown function + apply(fun(X) -> math:add3(X) end, [7]), + (fun(X) -> q:f(X) end)(3008), + + %% Not recognized or invalid. POS10=POS9+10 + A:foo(1000), % {'$M_EXPR',foo,1} + A(17), % {'$M_EXPR','$F_EXPR',1} + A(17,[one,two]), % {'$M_EXPR','$F_EXPR',2} + apply(apa,[1001]), % {'$M_EXPR','$F_EXPR',1} + {mod1:fun1(hej),san}(1017), % {'$M_EXPR',san,1} + A:A(1004), % {'$M_EXPR','$F_EXPR',1} + %% POS11=POS10+7 + apply(A,A,[1006]), % {'$M_EXPR','$F_EXPR',1} + apply(A,A,[1009 | 10010]), % {'$M_EXPR','$F_EXPR',-1} + apply(m,f,[10000 | 9999]), % {m,f,-1} + apply(m,f,a), % {m,f,-1} + 3(a), % {'$M_EXPR','$F_EXPR',1} + apply(3,[a]), % {'$M_EXPR','$F_EXPR',1} + + %% POS12=POS11+8 + apply(A, A), % number of arguments is not known, {'$M_EXPR','$F_EXPR',-1} + Args0 = [list], + Args = [a | Args0], % number of arguments is known + apply(A, Args), % {'$M_EXPR','$F_EXPR',2} + apply(m3, f3, Args), % + NotArgs = [is_not, a | list], % number of arguments is not known + apply(A, NotArgs), % {'$M_EXPR','$F_EXPR',-1} + apply(m4, f4, NotArgs), % {m4,f4,-1} + + %% OTP Internal. POS13=POS12+10 + erts_debug:apply(dm, df, [17], foobar), + erts_debug:apply(debug, A, [], A), % {debug,'$F_EXPR',0} + erts_debug:apply(A, A, A, A). % {'$M_EXPR','$F_EXPR',-1} + +bi() when length([]) > 17 -> + foo:module_info(), + module_info(), + A = tjo, + t:foo(A), + case true of + true when integer(1) -> + X = foo; + false -> + X = flopp + end, + X == A; +bi() -> + %% POS14=POS13+18 + Z = fun(Y) -> Y end, + case true of + true when length([a,b]) > 4 -> + F = fun(X) -> X end, + F(3); + false -> + F = 17, + F(3) % {'$M_EXPR','$F_EXPR',1} + end, + Z(apa), + erlang:module_info(); +bi() -> + Bin11 = <<1, 17, 42>>, + Bin12 = <<"abc">>, + false = (Bin11 == Bin12), + A = 1, B = 17, + Bin3 = <<A, B, (bi()):16>>, + <<D:16, E, F/binary>> = Bin3, + X = 9, <<(X+1):8>>, + _Fyy = <<X:4/little-signed-integer-unit:8>>, + D + E + F. +%bi() -> +% %% POS15=POS14+13 +% try +% foo:t(), +% bar:t() +% of +% {v,1} -> +% local(); +% {v,2} -> +% foo:t() +% catch +% {'EXIT',_} -> bar:t() +% end. + +local() -> + true. diff --git a/lib/tools/test/xref_SUITE_data/rel2/lib/app1-1.0/ebin/dummy b/lib/tools/test/xref_SUITE_data/rel2/lib/app1-1.0/ebin/dummy new file mode 100644 index 0000000000..7f62a93220 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/rel2/lib/app1-1.0/ebin/dummy @@ -0,0 +1,2 @@ +This directory is not empty. +Prevents winzip from removing the directory. diff --git a/lib/tools/test/xref_SUITE_data/rel2/lib/app1-1.1/ebin/dummy b/lib/tools/test/xref_SUITE_data/rel2/lib/app1-1.1/ebin/dummy new file mode 100644 index 0000000000..7f62a93220 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/rel2/lib/app1-1.1/ebin/dummy @@ -0,0 +1,2 @@ +This directory is not empty. +Prevents winzip from removing the directory. diff --git a/lib/tools/test/xref_SUITE_data/rel2/lib/app2-1.1/ebin/dummy b/lib/tools/test/xref_SUITE_data/rel2/lib/app2-1.1/ebin/dummy new file mode 100644 index 0000000000..7f62a93220 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/rel2/lib/app2-1.1/ebin/dummy @@ -0,0 +1,2 @@ +This directory is not empty. +Prevents winzip from removing the directory. diff --git a/lib/tools/test/xref_SUITE_data/rel2/x.erl b/lib/tools/test/xref_SUITE_data/rel2/x.erl new file mode 100644 index 0000000000..2125760776 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/rel2/x.erl @@ -0,0 +1,16 @@ +-module(x). + +-export([t/0, xx/0]). +-deprecated({t,0,eventually}). + +t() -> + true. + +xx() -> + x:undef(). + +l() -> + l1(). + +l1() -> + l(). diff --git a/lib/tools/test/xref_SUITE_data/rel2/y.erl b/lib/tools/test/xref_SUITE_data/rel2/y.erl new file mode 100644 index 0000000000..2a6e65e78f --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/rel2/y.erl @@ -0,0 +1,6 @@ +-module(y). + +-export([t/0]). + +t() -> + x:t(). diff --git a/lib/tools/test/xref_SUITE_data/update/x.erl.1 b/lib/tools/test/xref_SUITE_data/update/x.erl.1 new file mode 100644 index 0000000000..6af13329a2 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/update/x.erl.1 @@ -0,0 +1,6 @@ +-module(x). + +-export([t/0]). + +t() -> + erlang:atom_to_list(tjohoo). diff --git a/lib/tools/test/xref_SUITE_data/update/x.erl.2 b/lib/tools/test/xref_SUITE_data/update/x.erl.2 new file mode 100644 index 0000000000..e303a758d2 --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/update/x.erl.2 @@ -0,0 +1,6 @@ +-module(x). + +-export([t/0]). + +t() -> + erlang:list_to_atom("tjohoo"). diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl index 50dd2d6f51..780bb2e741 100644 --- a/lib/wx/api_gen/wx_gen.erl +++ b/lib/wx/api_gen/wx_gen.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% Api wrapper generator @@ -699,10 +699,12 @@ parse_type2([N="wxArrayInt"|R],Info,Opts,T) -> parse_type2(R,Info,Opts,T#type{name=N,base=int,single=array}); parse_type2([N="wxArrayDouble"|R],Info,Opts,T) -> parse_type2(R,Info,Opts,T#type{name=N,base=double,single=array}); -parse_type2([N="wxTreeItemId"|R],Info,Opts,T) -> - parse_type2(R,Info,Opts,T#type{name=N,base={ref,N}}); +parse_type2([N="wxTreeItemId"|R],Info,Opts,T) -> %% Use Pointer as Ids + parse_type2(R,Info,Opts,T#type{name=N,base=int64}); +parse_type2([N="wxTreeItemIdValue"|R],Info,Opts,T) -> %% Use Pointer as Ids + parse_type2(R,Info,Opts,T#type{name=N,base=int64}); parse_type2([N="wxArrayTreeItemIds"|R],Info,Opts,T) -> - parse_type2(R,Info,Opts,T#type{name=N,base={ref,"wxTreeItemId"},single=array}); + parse_type2(R,Info,Opts,T#type{name=N,base=int64,single=array}); parse_type2([N="wxTreeItemData"|R],Info,Opts,T) -> parse_type2(R,Info,Opts,T#type{name="wxETreeItemData",base={term,N}}); parse_type2([N="wxClientData"|R],Info,Opts,T) -> @@ -1082,6 +1084,7 @@ type_foot_print(#type{base=long}) -> int; type_foot_print(#type{base=binary}) -> binary; type_foot_print(#type{base={binary,_}}) -> binary; type_foot_print(#type{base=int}) -> int; +type_foot_print(#type{base=int64}) -> int; type_foot_print(#type{base=bool}) -> bool; %%type_foot_print(#type{base=datetime}) -> datetime; type_foot_print(#type{base=float}) -> float; diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl index fd0bea04ae..423dcd0179 100644 --- a/lib/wx/api_gen/wx_gen_cpp.erl +++ b/lib/wx/api_gen/wx_gen_cpp.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %%%------------------------------------------------------------------- @@ -309,6 +309,8 @@ declare_type(N,false,_,#type{name="wxArrayTreeItemIds",ref=reference}) -> w(" wxArrayTreeItemIds ~s;~n", [N]); declare_type(N,false,_,#type{name="wxDateTime"}) -> w(" wxDateTime ~s;~n", [N]); +declare_type(N,false,_,#type{name=Type, base=int64, ref=reference}) -> + w(" ~s ~s;~n", [Type,N]); declare_type(N,true,Def,#type{base=Base,single=true,name=Type,by_val=true}) when Base =:= int; Base =:= long; Base =:= float; Base =:= double; Base =:= bool -> w(" ~s ~s=~s;~n", [Type,N,Def]); @@ -478,9 +480,13 @@ decode_arg(N,#type{base={comp,_,List},single=true,name=Type,ref=Ref},Arg,A0) -> {double, _} -> 0 end; -decode_arg(N,#type{name=Class,base={ref,"wxTreeItemId"},single=true},Arg,A0) -> - A = align(A0,32), - wa(" ~s ",[Class],"~s = wxTreeItemId(getPtr(bp,memenv)); bp += 4;~n",[N],Arg), +decode_arg(N,#type{name=Class="wxTreeItemId",single=true},Arg,A0) -> + A = align(A0,64), + wa(" ~s ",[Class],"~s = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8;~n",[N],Arg), + A; +decode_arg(N,#type{name=Class="wxTreeItemIdValue",single=true},Arg,A0) -> + A = align(A0,64), + wa(" ~s ",[Class],"~s = (~s) * (wxUint64 *) bp; bp += 8;~n",[N,Class],Arg), A; decode_arg(N,#type{name="wxChar", single=S},Arg,A0) when S =/= true -> @@ -851,8 +857,10 @@ build_ret_types(Type,Ps) -> build_ret(Name,_,#type{base={class,Class},single=true}) -> w(" rt.addRef(getRef((void *)~s,memenv), \"~s\");~n",[Name,Class]); -build_ret(Name,_,#type{base={ref,"wxTreeItemId"=Class},single=true}) -> - w(" rt.addRef(getRef((void *)~s.m_pItem,memenv), \"~s\");~n",[Name,Class]); +build_ret(Name,_,#type{name="wxTreeItemId",single=true}) -> + w(" rt.add((wxUIntPtr *) ~s.m_pItem);~n",[Name]); +build_ret(Name,_,#type{name="wxTreeItemIdValue",single=true}) -> + w(" rt.add((wxUIntPtr *) ~s);~n",[Name]); build_ret(Name,_,#type{base={term,_},single=true}) -> w(" rt.addExt2Term(~s);~n", [Name]); build_ret(Name,_,#type{base={binary,Size},single=true}) -> @@ -897,7 +905,7 @@ build_ret(Name,_,#type{name=List,single=list,base={class,Class}}) -> build_ret(Name,_,#type{name="wxArrayTreeItemIds"}) -> w(" for(unsigned int i=0; i < ~s.GetCount(); i++) {~n", [Name]), - w(" rt.addRef(getRef((void *)~s[i].m_pItem,memenv), \"wxTreeItemId\");}~n",[Name]), + w(" rt.add((wxUIntPtr *)~s[i].m_pItem);}~n",[Name]), w(" rt.endList(~s.GetCount());~n",[Name]); build_ret(Name,_,#type{base=float,single=true}) -> diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index 64c11baec1..c31d7d2a92 100644 --- a/lib/wx/api_gen/wx_gen_erl.erl +++ b/lib/wx/api_gen/wx_gen_erl.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %%%------------------------------------------------------------------- @@ -575,6 +575,8 @@ guard_test(#param{name=Name,type=#type{single=Single}}) "is_list(" ++ erl_arg_name(Name) ++ ")"; guard_test(#param{name=N,type=#type{base=int}}) -> "is_integer(" ++ erl_arg_name(N) ++ ")"; +guard_test(#param{name=N,type=#type{base=int64}}) -> + "is_integer(" ++ erl_arg_name(N) ++ ")"; guard_test(#param{name=N,type=#type{base=long}}) -> "is_integer(" ++ erl_arg_name(N) ++ ")"; guard_test(#param{name=N,type=#type{base=float}}) -> @@ -603,6 +605,7 @@ guard_test(#param{name=N,type=#type{base={comp,"wxColour",_Tup}}}) -> "tuple_size(" ++ erl_arg_name(N) ++ ") =:= 3; tuple_size(" ++ erl_arg_name(N) ++ ") =:= 4"; guard_test(#param{name=N,type=#type{base={comp,_,Tup}}}) -> Doc = fun({int,V}) -> "is_integer("++erl_arg_name(N)++V ++")"; + ({int64,V}) -> "is_integer("++erl_arg_name(N)++V ++")"; ({double,V}) -> "is_number("++erl_arg_name(N)++V ++")" end, args(Doc, ",", Tup); @@ -768,7 +771,9 @@ doc_arg_type3(#type{name="wxArrayString"}) -> "[string()]"; doc_arg_type3(#type{name="wxDateTime"}) -> "wx:datetime()"; doc_arg_type3(#type{name="wxArtClient"}) -> "string()"; doc_arg_type3(#type{base=int}) -> "integer()"; +doc_arg_type3(#type{base=int64}) -> "integer()"; doc_arg_type3(#type{base=long}) -> "integer()"; +doc_arg_type3(#type{name="wxTreeItemId"}) -> "wxTreeCtrl:treeItemId()"; doc_arg_type3(#type{base=bool}) -> "bool()"; doc_arg_type3(#type{base=float}) -> "float()"; doc_arg_type3(#type{base=double}) -> "float()"; @@ -851,7 +856,7 @@ doc_enum_desc([{Enum,Vs}|R]) -> doc_enum_desc(R). %% Misc functions prefixed with wx -erl_func_name("wx" ++ Name, undefined) -> check_name(lowercase(Name)); +erl_func_name("wx" ++ Name, undefined) -> check_name(lowercase(Name)); erl_func_name(Name, undefined) -> check_name(lowercase(Name)); erl_func_name(_, Alias) -> check_name(lowercase(Alias)). @@ -926,6 +931,8 @@ marshal_arg(#type{single=true,base=float}, Name, Align) -> align(32, Align, Name ++ ":32/?F"); marshal_arg(#type{single=true,base=double}, Name, Align) -> align(64, Align, Name ++ ":64/?F"); +marshal_arg(#type{single=true,base=int64}, Name, Align) -> + align(64, Align, Name ++ ":64/?UI"); marshal_arg(#type{single=true,base=int}, Name, Align) -> align(32, Align, Name ++ ":32/?UI"); marshal_arg(#type{single=true,base={enum,_Enum}}, Name, Align) -> diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index 4a646650ea..4bb358ebc9 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -1,20 +1,20 @@ %% -*- erlang -*- %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% % %% Api defs file, defines the classes and members we want. @@ -889,7 +889,12 @@ {enum, wxTreeItemIcon, "wxTreeItemIcon_"}. -{class, wxTreeCtrl, wxControl, [], +{class, wxTreeCtrl, wxControl, + [{doc, + "Note: The representation of treeItemId() have changed " + "from the original class implementation to be an semi-opaque type," + "Equality between TreeItemId's can be tested and zero means that the TreeItem is invalid." + }], ['wxTreeCtrl','~wxTreeCtrl','AddRoot','AppendItem', %% Not on Windows 'AssignButtonsImageList','GetButtonsImageList','SetButtonsImageList' 'AssignImageList','AssignStateImageList','Collapse','CollapseAndReset', @@ -897,10 +902,10 @@ %'EndEditLabel', 'EnsureVisible','Expand','GetBoundingRect', 'GetChildrenCount','GetCount','GetEditControl', - %'GetFirstChild', + {'GetFirstChild',[{"cookie", out}]}, {'GetNextChild',[{"cookie", [both]}]}, 'GetFirstVisibleItem',{'GetImageList',0},'GetIndent', 'GetItemBackgroundColour','GetItemData','GetItemFont','GetItemImage', - 'GetItemText','GetItemTextColour','GetLastChild', % 'GetNextChild', + 'GetItemText','GetItemTextColour','GetLastChild', 'GetNextSibling','GetNextVisible','GetItemParent',%'GetParent', 'GetPrevSibling','GetPrevVisible','GetRootItem', 'GetSelection',{'GetSelections', [{return, nowhere},{"val",out}]}, diff --git a/lib/wx/c_src/gen/wxe_events.cpp b/lib/wx/c_src/gen/wxe_events.cpp index f15754a072..de55f9d8da 100644 --- a/lib/wx/c_src/gen/wxe_events.cpp +++ b/lib/wx/c_src/gen/wxe_events.cpp @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2008-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2008-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -740,8 +740,8 @@ case 208: {// wxTreeEvent evClass = (char*)"wxTreeEvent"; rt.addAtom((char*)"wxTree"); rt.addAtom(Etype->eName); - rt.addRef(getRef((void *)ev->GetItem().m_pItem,memenv), "wxTreeItemId"); - rt.addRef(getRef((void *)ev->GetOldItem().m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) ev->GetItem().m_pItem); + rt.add((wxUIntPtr *) ev->GetOldItem().m_pItem); rt.add(ev->GetPoint()); rt.addTupleCount(5); break; diff --git a/lib/wx/c_src/gen/wxe_funcs.cpp b/lib/wx/c_src/gen/wxe_funcs.cpp index ccbacce9b9..532fee24b2 100644 --- a/lib/wx/c_src/gen/wxe_funcs.cpp +++ b/lib/wx/c_src/gen/wxe_funcs.cpp @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2008-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2008-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -14763,7 +14763,7 @@ case wxGenericDirCtrl_GetRootId: { // wxGenericDirCtrl::GetRootId wxGenericDirCtrl *This = (wxGenericDirCtrl *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetRootId(); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxGenericDirCtrl_GetTreeCtrl: { // wxGenericDirCtrl::GetTreeCtrl @@ -18376,7 +18376,7 @@ case wxTreeCtrl_AddRoot: { // wxTreeCtrl::AddRoot }}; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->AddRoot(text,image,selectedImage,data); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_AppendItem: { // wxTreeCtrl::AppendItem @@ -18384,7 +18384,8 @@ case wxTreeCtrl_AppendItem: { // wxTreeCtrl::AppendItem int selectedImage=-1; wxETreeItemData * data= NULL; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId parent = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId parent = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * textLen = (int *) bp; bp += 4; wxString text = wxString(bp, wxConvUTF8); bp += *textLen+((8-((4+ *textLen) & 7)) & 7); @@ -18402,7 +18403,7 @@ case wxTreeCtrl_AppendItem: { // wxTreeCtrl::AppendItem }}; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->AppendItem(parent,text,image,selectedImage,data); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_AssignImageList: { // wxTreeCtrl::AssignImageList @@ -18421,14 +18422,16 @@ case wxTreeCtrl_AssignStateImageList: { // wxTreeCtrl::AssignStateImageList } case wxTreeCtrl_Collapse: { // wxTreeCtrl::Collapse wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->Collapse(item); break; } case wxTreeCtrl_CollapseAndReset: { // wxTreeCtrl::CollapseAndReset wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->CollapseAndReset(item); break; @@ -18471,7 +18474,8 @@ validator = (wxValidator *) getPtr(bp,memenv); bp += 4; } case wxTreeCtrl_Delete: { // wxTreeCtrl::Delete wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->Delete(item); break; @@ -18484,21 +18488,24 @@ case wxTreeCtrl_DeleteAllItems: { // wxTreeCtrl::DeleteAllItems } case wxTreeCtrl_DeleteChildren: { // wxTreeCtrl::DeleteChildren wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->DeleteChildren(item); break; } case wxTreeCtrl_EnsureVisible: { // wxTreeCtrl::EnsureVisible wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->EnsureVisible(item); break; } case wxTreeCtrl_Expand: { // wxTreeCtrl::Expand wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->Expand(item); break; @@ -18506,7 +18513,8 @@ case wxTreeCtrl_Expand: { // wxTreeCtrl::Expand case wxTreeCtrl_GetBoundingRect: { // wxTreeCtrl::GetBoundingRect bool textOnly=false; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * rectX = (int *) bp; bp += 4; int * rectY = (int *) bp; bp += 4; int * rectW = (int *) bp; bp += 4; @@ -18525,7 +18533,8 @@ case wxTreeCtrl_GetBoundingRect: { // wxTreeCtrl::GetBoundingRect case wxTreeCtrl_GetChildrenCount: { // wxTreeCtrl::GetChildrenCount bool recursively=true; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; while( * (int*) bp) { switch (* (int*) bp) { case 1: {bp += 4; recursively = *(bool *) bp; bp += 4; @@ -18550,11 +18559,35 @@ case wxTreeCtrl_GetEditControl: { // wxTreeCtrl::GetEditControl rt.addRef(getRef((void *)Result,memenv), "wxTextCtrl"); break; } +case wxTreeCtrl_GetFirstChild: { // wxTreeCtrl::GetFirstChild + wxTreeItemIdValue cookie; + wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; + if(!This) throw wxe_badarg(0); + wxTreeItemId Result = This->GetFirstChild(item,cookie); + rt.add((wxUIntPtr *) Result.m_pItem); + rt.add((wxUIntPtr *) cookie); + rt.addTupleCount(2); + break; +} +case wxTreeCtrl_GetNextChild: { // wxTreeCtrl::GetNextChild + wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; + wxTreeItemIdValue cookie = (wxTreeItemIdValue) * (wxUint64 *) bp; bp += 8; + if(!This) throw wxe_badarg(0); + wxTreeItemId Result = This->GetNextChild(item,cookie); + rt.add((wxUIntPtr *) Result.m_pItem); + rt.add((wxUIntPtr *) cookie); + rt.addTupleCount(2); + break; +} case wxTreeCtrl_GetFirstVisibleItem: { // wxTreeCtrl::GetFirstVisibleItem wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetFirstVisibleItem(); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetImageList: { // wxTreeCtrl::GetImageList @@ -18573,7 +18606,8 @@ case wxTreeCtrl_GetIndent: { // wxTreeCtrl::GetIndent } case wxTreeCtrl_GetItemBackgroundColour: { // wxTreeCtrl::GetItemBackgroundColour wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxColour Result = This->GetItemBackgroundColour(item); rt.add(Result); @@ -18581,7 +18615,8 @@ case wxTreeCtrl_GetItemBackgroundColour: { // wxTreeCtrl::GetItemBackgroundColou } case wxTreeCtrl_GetItemData: { // wxTreeCtrl::GetItemData wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxETreeItemData * Result = (wxETreeItemData*)This->GetItemData(item); rt.addExt2Term(Result); @@ -18589,7 +18624,8 @@ case wxTreeCtrl_GetItemData: { // wxTreeCtrl::GetItemData } case wxTreeCtrl_GetItemFont: { // wxTreeCtrl::GetItemFont wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxFont * Result = new wxFont(This->GetItemFont(item)); newPtr((void *) Result,3, memenv);; rt.addRef(getRef((void *)Result,memenv), "wxFont"); @@ -18597,7 +18633,8 @@ case wxTreeCtrl_GetItemFont: { // wxTreeCtrl::GetItemFont } case wxTreeCtrl_GetItemImage_1: { // wxTreeCtrl::GetItemImage wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); int Result = This->GetItemImage(item); rt.addInt(Result); @@ -18606,7 +18643,8 @@ case wxTreeCtrl_GetItemImage_1: { // wxTreeCtrl::GetItemImage case wxTreeCtrl_GetItemImage_2: { // wxTreeCtrl::GetItemImage wxTreeItemIcon which=wxTreeItemIcon_Normal; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; while( * (int*) bp) { switch (* (int*) bp) { case 1: {bp += 4; which = *(wxTreeItemIcon *) bp; bp += 4;; @@ -18619,7 +18657,8 @@ which = *(wxTreeItemIcon *) bp; bp += 4;; } case wxTreeCtrl_GetItemText: { // wxTreeCtrl::GetItemText wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxString Result = This->GetItemText(item); rt.add(Result); @@ -18627,7 +18666,8 @@ case wxTreeCtrl_GetItemText: { // wxTreeCtrl::GetItemText } case wxTreeCtrl_GetItemTextColour: { // wxTreeCtrl::GetItemTextColour wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxColour Result = This->GetItemTextColour(item); rt.add(Result); @@ -18635,64 +18675,70 @@ case wxTreeCtrl_GetItemTextColour: { // wxTreeCtrl::GetItemTextColour } case wxTreeCtrl_GetLastChild: { // wxTreeCtrl::GetLastChild wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetLastChild(item); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetNextSibling: { // wxTreeCtrl::GetNextSibling wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetNextSibling(item); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetNextVisible: { // wxTreeCtrl::GetNextVisible wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetNextVisible(item); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetItemParent: { // wxTreeCtrl::GetItemParent wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetItemParent(item); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetPrevSibling: { // wxTreeCtrl::GetPrevSibling wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetPrevSibling(item); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetPrevVisible: { // wxTreeCtrl::GetPrevVisible wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetPrevVisible(item); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetRootItem: { // wxTreeCtrl::GetRootItem wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetRootItem(); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetSelection: { // wxTreeCtrl::GetSelection wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetSelection(); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_GetSelections: { // wxTreeCtrl::GetSelections @@ -18702,7 +18748,7 @@ case wxTreeCtrl_GetSelections: { // wxTreeCtrl::GetSelections size_t Result = This->GetSelections(val); rt.addInt(Result); for(unsigned int i=0; i < val.GetCount(); i++) { - rt.addRef(getRef((void *)val[i].m_pItem,memenv), "wxTreeItemId");} + rt.add((wxUIntPtr *)val[i].m_pItem);} rt.endList(val.GetCount()); rt.addTupleCount(2); break; @@ -18721,42 +18767,16 @@ case wxTreeCtrl_HitTest: { // wxTreeCtrl::HitTest wxPoint point = wxPoint(*pointX,*pointY); if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->HitTest(point); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); - break; -} -case wxTreeCtrl_InsertItem_4_1: { // wxTreeCtrl::InsertItem - int image=-1; - int selectedImage=-1; - wxETreeItemData * data= NULL; - wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId parent = wxTreeItemId(getPtr(bp,memenv)); bp += 4; - wxTreeItemId idPrevious = wxTreeItemId(getPtr(bp,memenv)); bp += 4; - int * textLen = (int *) bp; bp += 4; - wxString text = wxString(bp, wxConvUTF8); - bp += *textLen+((8-((0+ *textLen) & 7)) & 7); - while( * (int*) bp) { switch (* (int*) bp) { - case 1: {bp += 4; - image = (int)*(int *) bp; bp += 4; - } break; - case 2: {bp += 4; - selectedImage = (int)*(int *) bp; bp += 4; - } break; - case 3: {bp += 4; - data = new wxETreeItemData(Ecmd.bin[0]->size, Ecmd.bin[0]->base); - bp += 4; /* Align */ - } break; - }}; - if(!This) throw wxe_badarg(0); - wxTreeItemId Result = This->InsertItem(parent,idPrevious,text,image,selectedImage,data); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } -case wxTreeCtrl_InsertItem_4_0: { // wxTreeCtrl::InsertItem +case wxTreeCtrl_InsertItem: { // wxTreeCtrl::InsertItem int image=-1; int selImage=-1; wxETreeItemData * data= NULL; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId parent = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId parent = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * pos = (int *) bp; bp += 4; int * textLen = (int *) bp; bp += 4; wxString text = wxString(bp, wxConvUTF8); @@ -18775,12 +18795,13 @@ case wxTreeCtrl_InsertItem_4_0: { // wxTreeCtrl::InsertItem }}; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->InsertItem(parent,(size_t) *pos,text,image,selImage,data); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_IsBold: { // wxTreeCtrl::IsBold wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); bool Result = This->IsBold(item); rt.addBool(Result); @@ -18788,7 +18809,8 @@ case wxTreeCtrl_IsBold: { // wxTreeCtrl::IsBold } case wxTreeCtrl_IsExpanded: { // wxTreeCtrl::IsExpanded wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); bool Result = This->IsExpanded(item); rt.addBool(Result); @@ -18796,7 +18818,8 @@ case wxTreeCtrl_IsExpanded: { // wxTreeCtrl::IsExpanded } case wxTreeCtrl_IsSelected: { // wxTreeCtrl::IsSelected wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); bool Result = This->IsSelected(item); rt.addBool(Result); @@ -18804,7 +18827,8 @@ case wxTreeCtrl_IsSelected: { // wxTreeCtrl::IsSelected } case wxTreeCtrl_IsVisible: { // wxTreeCtrl::IsVisible wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); bool Result = This->IsVisible(item); rt.addBool(Result); @@ -18812,7 +18836,8 @@ case wxTreeCtrl_IsVisible: { // wxTreeCtrl::IsVisible } case wxTreeCtrl_ItemHasChildren: { // wxTreeCtrl::ItemHasChildren wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); bool Result = This->ItemHasChildren(item); rt.addBool(Result); @@ -18823,7 +18848,8 @@ case wxTreeCtrl_PrependItem: { // wxTreeCtrl::PrependItem int selectedImage=-1; wxETreeItemData * data= NULL; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId parent = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId parent = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * textLen = (int *) bp; bp += 4; wxString text = wxString(bp, wxConvUTF8); bp += *textLen+((8-((4+ *textLen) & 7)) & 7); @@ -18841,19 +18867,21 @@ case wxTreeCtrl_PrependItem: { // wxTreeCtrl::PrependItem }}; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->PrependItem(parent,text,image,selectedImage,data); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeCtrl_ScrollTo: { // wxTreeCtrl::ScrollTo wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->ScrollTo(item); break; } case wxTreeCtrl_SelectItem_1: { // wxTreeCtrl::SelectItem wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->SelectItem(item); break; @@ -18861,7 +18889,8 @@ case wxTreeCtrl_SelectItem_1: { // wxTreeCtrl::SelectItem case wxTreeCtrl_SelectItem_2: { // wxTreeCtrl::SelectItem bool select=true; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; while( * (int*) bp) { switch (* (int*) bp) { case 1: {bp += 4; select = *(bool *) bp; bp += 4; @@ -18887,7 +18916,8 @@ case wxTreeCtrl_SetImageList: { // wxTreeCtrl::SetImageList } case wxTreeCtrl_SetItemBackgroundColour: { // wxTreeCtrl::SetItemBackgroundColour wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * colR = (int *) bp; bp += 4; int * colG = (int *) bp; bp += 4; int * colB = (int *) bp; bp += 4; @@ -18900,7 +18930,8 @@ case wxTreeCtrl_SetItemBackgroundColour: { // wxTreeCtrl::SetItemBackgroundColou case wxTreeCtrl_SetItemBold: { // wxTreeCtrl::SetItemBold bool bold=true; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; while( * (int*) bp) { switch (* (int*) bp) { case 1: {bp += 4; bold = *(bool *) bp; bp += 4; @@ -18912,7 +18943,8 @@ case wxTreeCtrl_SetItemBold: { // wxTreeCtrl::SetItemBold } case wxTreeCtrl_SetItemData: { // wxTreeCtrl::SetItemData wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; wxETreeItemData * data = new wxETreeItemData(Ecmd.bin[0]->size, Ecmd.bin[0]->base); if(!This) throw wxe_badarg(0); This->SetItemData(item,data); @@ -18921,7 +18953,8 @@ case wxTreeCtrl_SetItemData: { // wxTreeCtrl::SetItemData case wxTreeCtrl_SetItemDropHighlight: { // wxTreeCtrl::SetItemDropHighlight bool highlight=true; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; while( * (int*) bp) { switch (* (int*) bp) { case 1: {bp += 4; highlight = *(bool *) bp; bp += 4; @@ -18933,7 +18966,8 @@ case wxTreeCtrl_SetItemDropHighlight: { // wxTreeCtrl::SetItemDropHighlight } case wxTreeCtrl_SetItemFont: { // wxTreeCtrl::SetItemFont wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; wxFont *font = (wxFont *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); This->SetItemFont(item,*font); @@ -18942,7 +18976,8 @@ case wxTreeCtrl_SetItemFont: { // wxTreeCtrl::SetItemFont case wxTreeCtrl_SetItemHasChildren: { // wxTreeCtrl::SetItemHasChildren bool has=true; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; while( * (int*) bp) { switch (* (int*) bp) { case 1: {bp += 4; has = *(bool *) bp; bp += 4; @@ -18954,7 +18989,8 @@ case wxTreeCtrl_SetItemHasChildren: { // wxTreeCtrl::SetItemHasChildren } case wxTreeCtrl_SetItemImage_2: { // wxTreeCtrl::SetItemImage wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * image = (int *) bp; bp += 4; if(!This) throw wxe_badarg(0); This->SetItemImage(item,(int) *image); @@ -18963,7 +18999,8 @@ case wxTreeCtrl_SetItemImage_2: { // wxTreeCtrl::SetItemImage case wxTreeCtrl_SetItemImage_3: { // wxTreeCtrl::SetItemImage wxTreeItemIcon which=wxTreeItemIcon_Normal; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * image = (int *) bp; bp += 4; bp += 4; /* Align */ while( * (int*) bp) { switch (* (int*) bp) { @@ -18977,7 +19014,8 @@ which = *(wxTreeItemIcon *) bp; bp += 4;; } case wxTreeCtrl_SetItemText: { // wxTreeCtrl::SetItemText wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * textLen = (int *) bp; bp += 4; wxString text = wxString(bp, wxConvUTF8); bp += *textLen+((8-((4+ *textLen) & 7)) & 7); @@ -18987,7 +19025,8 @@ case wxTreeCtrl_SetItemText: { // wxTreeCtrl::SetItemText } case wxTreeCtrl_SetItemTextColour: { // wxTreeCtrl::SetItemTextColour wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; int * colR = (int *) bp; bp += 4; int * colG = (int *) bp; bp += 4; int * colB = (int *) bp; bp += 4; @@ -19013,21 +19052,24 @@ case wxTreeCtrl_SetWindowStyle: { // wxTreeCtrl::SetWindowStyle } case wxTreeCtrl_SortChildren: { // wxTreeCtrl::SortChildren wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->SortChildren(item); break; } case wxTreeCtrl_Toggle: { // wxTreeCtrl::Toggle wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->Toggle(item); break; } case wxTreeCtrl_ToggleItemSelection: { // wxTreeCtrl::ToggleItemSelection wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->ToggleItemSelection(item); break; @@ -19046,7 +19088,8 @@ case wxTreeCtrl_UnselectAll: { // wxTreeCtrl::UnselectAll } case wxTreeCtrl_UnselectItem: { // wxTreeCtrl::UnselectItem wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; - wxTreeItemId item = wxTreeItemId(getPtr(bp,memenv)); bp += 4; + bp += 4; /* Align */ + wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; if(!This) throw wxe_badarg(0); This->UnselectItem(item); break; @@ -30146,7 +30189,7 @@ case wxTreeEvent_GetItem: { // wxTreeEvent::GetItem wxTreeEvent *This = (wxTreeEvent *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetItem(); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeEvent_GetKeyEvent: { // wxTreeEvent::GetKeyEvent @@ -30167,7 +30210,7 @@ case wxTreeEvent_GetOldItem: { // wxTreeEvent::GetOldItem wxTreeEvent *This = (wxTreeEvent *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); wxTreeItemId Result = This->GetOldItem(); - rt.addRef(getRef((void *)Result.m_pItem,memenv), "wxTreeItemId"); + rt.add((wxUIntPtr *) Result.m_pItem); break; } case wxTreeEvent_GetPoint: { // wxTreeEvent::GetPoint diff --git a/lib/wx/c_src/gen/wxe_macros.h b/lib/wx/c_src/gen/wxe_macros.h index 5e4b4deb9c..74d82a54f3 100644 --- a/lib/wx/c_src/gen/wxe_macros.h +++ b/lib/wx/c_src/gen/wxe_macros.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2008-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2008-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ #include <wx/caret.h> @@ -1882,1437 +1882,1438 @@ #define wxTreeCtrl_GetChildrenCount 2015 #define wxTreeCtrl_GetCount 2016 #define wxTreeCtrl_GetEditControl 2017 -#define wxTreeCtrl_GetFirstVisibleItem 2018 -#define wxTreeCtrl_GetImageList 2019 -#define wxTreeCtrl_GetIndent 2020 -#define wxTreeCtrl_GetItemBackgroundColour 2021 -#define wxTreeCtrl_GetItemData 2022 -#define wxTreeCtrl_GetItemFont 2023 -#define wxTreeCtrl_GetItemImage_1 2024 -#define wxTreeCtrl_GetItemImage_2 2025 -#define wxTreeCtrl_GetItemText 2026 -#define wxTreeCtrl_GetItemTextColour 2027 -#define wxTreeCtrl_GetLastChild 2028 -#define wxTreeCtrl_GetNextSibling 2029 -#define wxTreeCtrl_GetNextVisible 2030 -#define wxTreeCtrl_GetItemParent 2031 -#define wxTreeCtrl_GetPrevSibling 2032 -#define wxTreeCtrl_GetPrevVisible 2033 -#define wxTreeCtrl_GetRootItem 2034 -#define wxTreeCtrl_GetSelection 2035 -#define wxTreeCtrl_GetSelections 2036 -#define wxTreeCtrl_GetStateImageList 2037 -#define wxTreeCtrl_HitTest 2038 -#define wxTreeCtrl_InsertItem_4_1 2039 -#define wxTreeCtrl_InsertItem_4_0 2040 -#define wxTreeCtrl_IsBold 2041 -#define wxTreeCtrl_IsExpanded 2042 -#define wxTreeCtrl_IsSelected 2043 -#define wxTreeCtrl_IsVisible 2044 -#define wxTreeCtrl_ItemHasChildren 2045 -#define wxTreeCtrl_PrependItem 2046 -#define wxTreeCtrl_ScrollTo 2047 -#define wxTreeCtrl_SelectItem_1 2048 -#define wxTreeCtrl_SelectItem_2 2049 -#define wxTreeCtrl_SetIndent 2050 -#define wxTreeCtrl_SetImageList 2051 -#define wxTreeCtrl_SetItemBackgroundColour 2052 -#define wxTreeCtrl_SetItemBold 2053 -#define wxTreeCtrl_SetItemData 2054 -#define wxTreeCtrl_SetItemDropHighlight 2055 -#define wxTreeCtrl_SetItemFont 2056 -#define wxTreeCtrl_SetItemHasChildren 2057 -#define wxTreeCtrl_SetItemImage_2 2058 -#define wxTreeCtrl_SetItemImage_3 2059 -#define wxTreeCtrl_SetItemText 2060 -#define wxTreeCtrl_SetItemTextColour 2061 -#define wxTreeCtrl_SetStateImageList 2062 -#define wxTreeCtrl_SetWindowStyle 2063 -#define wxTreeCtrl_SortChildren 2064 -#define wxTreeCtrl_Toggle 2065 -#define wxTreeCtrl_ToggleItemSelection 2066 -#define wxTreeCtrl_Unselect 2067 -#define wxTreeCtrl_UnselectAll 2068 -#define wxTreeCtrl_UnselectItem 2069 -#define wxScrollBar_new_0 2070 -#define wxScrollBar_new_3 2071 -#define wxScrollBar_destruct 2072 -#define wxScrollBar_Create 2073 -#define wxScrollBar_GetRange 2074 -#define wxScrollBar_GetPageSize 2075 -#define wxScrollBar_GetThumbPosition 2076 -#define wxScrollBar_GetThumbSize 2077 -#define wxScrollBar_SetThumbPosition 2078 -#define wxScrollBar_SetScrollbar 2079 -#define wxSpinButton_new_2 2081 -#define wxSpinButton_new_0 2082 -#define wxSpinButton_Create 2083 -#define wxSpinButton_GetMax 2084 -#define wxSpinButton_GetMin 2085 -#define wxSpinButton_GetValue 2086 -#define wxSpinButton_SetRange 2087 -#define wxSpinButton_SetValue 2088 -#define wxSpinButton_destroy 2089 -#define wxSpinCtrl_new_0 2090 -#define wxSpinCtrl_new_2 2091 -#define wxSpinCtrl_Create 2093 -#define wxSpinCtrl_SetValue_1_1 2096 -#define wxSpinCtrl_SetValue_1_0 2097 -#define wxSpinCtrl_GetValue 2099 -#define wxSpinCtrl_SetRange 2101 -#define wxSpinCtrl_SetSelection 2102 -#define wxSpinCtrl_GetMin 2104 -#define wxSpinCtrl_GetMax 2106 -#define wxSpinCtrl_destroy 2107 -#define wxStaticText_new_0 2108 -#define wxStaticText_new_4 2109 -#define wxStaticText_Create 2110 -#define wxStaticText_GetLabel 2111 -#define wxStaticText_SetLabel 2112 -#define wxStaticText_Wrap 2113 -#define wxStaticText_destroy 2114 -#define wxStaticBitmap_new_0 2115 -#define wxStaticBitmap_new_4 2116 -#define wxStaticBitmap_Create 2117 -#define wxStaticBitmap_GetBitmap 2118 -#define wxStaticBitmap_SetBitmap 2119 -#define wxStaticBitmap_destroy 2120 -#define wxRadioBox_new 2121 -#define wxRadioBox_destruct 2123 -#define wxRadioBox_Create 2124 -#define wxRadioBox_Enable_2 2125 -#define wxRadioBox_Enable_1 2126 -#define wxRadioBox_GetSelection 2127 -#define wxRadioBox_GetString 2128 -#define wxRadioBox_SetSelection 2129 -#define wxRadioBox_Show_2 2130 -#define wxRadioBox_Show_1 2131 -#define wxRadioBox_GetColumnCount 2132 -#define wxRadioBox_GetItemHelpText 2133 -#define wxRadioBox_GetItemToolTip 2134 -#define wxRadioBox_GetItemFromPoint 2136 -#define wxRadioBox_GetRowCount 2137 -#define wxRadioBox_IsItemEnabled 2138 -#define wxRadioBox_IsItemShown 2139 -#define wxRadioBox_SetItemHelpText 2140 -#define wxRadioBox_SetItemToolTip 2141 -#define wxRadioButton_new_0 2142 -#define wxRadioButton_new_4 2143 -#define wxRadioButton_Create 2144 -#define wxRadioButton_GetValue 2145 -#define wxRadioButton_SetValue 2146 -#define wxRadioButton_destroy 2147 -#define wxSlider_new_6 2149 -#define wxSlider_new_0 2150 -#define wxSlider_Create 2151 -#define wxSlider_GetLineSize 2152 -#define wxSlider_GetMax 2153 -#define wxSlider_GetMin 2154 -#define wxSlider_GetPageSize 2155 -#define wxSlider_GetThumbLength 2156 -#define wxSlider_GetValue 2157 -#define wxSlider_SetLineSize 2158 -#define wxSlider_SetPageSize 2159 -#define wxSlider_SetRange 2160 -#define wxSlider_SetThumbLength 2161 -#define wxSlider_SetValue 2162 -#define wxSlider_destroy 2163 -#define wxDialog_new_4 2165 -#define wxDialog_new_0 2166 -#define wxDialog_destruct 2168 -#define wxDialog_Create 2169 -#define wxDialog_CreateButtonSizer 2170 -#define wxDialog_CreateStdDialogButtonSizer 2171 -#define wxDialog_EndModal 2172 -#define wxDialog_GetAffirmativeId 2173 -#define wxDialog_GetReturnCode 2174 -#define wxDialog_IsModal 2175 -#define wxDialog_SetAffirmativeId 2176 -#define wxDialog_SetReturnCode 2177 -#define wxDialog_Show 2178 -#define wxDialog_ShowModal 2179 -#define wxColourDialog_new_0 2180 -#define wxColourDialog_new_2 2181 -#define wxColourDialog_destruct 2182 -#define wxColourDialog_Create 2183 -#define wxColourDialog_GetColourData 2184 -#define wxColourData_new_0 2185 -#define wxColourData_new_1 2186 -#define wxColourData_destruct 2187 -#define wxColourData_GetChooseFull 2188 -#define wxColourData_GetColour 2189 -#define wxColourData_GetCustomColour 2191 -#define wxColourData_SetChooseFull 2192 -#define wxColourData_SetColour 2193 -#define wxColourData_SetCustomColour 2194 -#define wxPalette_new_0 2195 -#define wxPalette_new_4 2196 -#define wxPalette_destruct 2198 -#define wxPalette_Create 2199 -#define wxPalette_GetColoursCount 2200 -#define wxPalette_GetPixel 2201 -#define wxPalette_GetRGB 2202 -#define wxPalette_IsOk 2203 -#define wxDirDialog_new 2207 -#define wxDirDialog_destruct 2208 -#define wxDirDialog_GetPath 2209 -#define wxDirDialog_GetMessage 2210 -#define wxDirDialog_SetMessage 2211 -#define wxDirDialog_SetPath 2212 -#define wxFileDialog_new 2216 -#define wxFileDialog_destruct 2217 -#define wxFileDialog_GetDirectory 2218 -#define wxFileDialog_GetFilename 2219 -#define wxFileDialog_GetFilenames 2220 -#define wxFileDialog_GetFilterIndex 2221 -#define wxFileDialog_GetMessage 2222 -#define wxFileDialog_GetPath 2223 -#define wxFileDialog_GetPaths 2224 -#define wxFileDialog_GetWildcard 2225 -#define wxFileDialog_SetDirectory 2226 -#define wxFileDialog_SetFilename 2227 -#define wxFileDialog_SetFilterIndex 2228 -#define wxFileDialog_SetMessage 2229 -#define wxFileDialog_SetPath 2230 -#define wxFileDialog_SetWildcard 2231 -#define wxPickerBase_SetInternalMargin 2232 -#define wxPickerBase_GetInternalMargin 2233 -#define wxPickerBase_SetTextCtrlProportion 2234 -#define wxPickerBase_SetPickerCtrlProportion 2235 -#define wxPickerBase_GetTextCtrlProportion 2236 -#define wxPickerBase_GetPickerCtrlProportion 2237 -#define wxPickerBase_HasTextCtrl 2238 -#define wxPickerBase_GetTextCtrl 2239 -#define wxPickerBase_IsTextCtrlGrowable 2240 -#define wxPickerBase_SetPickerCtrlGrowable 2241 -#define wxPickerBase_SetTextCtrlGrowable 2242 -#define wxPickerBase_IsPickerCtrlGrowable 2243 -#define wxFilePickerCtrl_new_0 2244 -#define wxFilePickerCtrl_new_3 2245 -#define wxFilePickerCtrl_Create 2246 -#define wxFilePickerCtrl_GetPath 2247 -#define wxFilePickerCtrl_SetPath 2248 -#define wxFilePickerCtrl_destroy 2249 -#define wxDirPickerCtrl_new_0 2250 -#define wxDirPickerCtrl_new_3 2251 -#define wxDirPickerCtrl_Create 2252 -#define wxDirPickerCtrl_GetPath 2253 -#define wxDirPickerCtrl_SetPath 2254 -#define wxDirPickerCtrl_destroy 2255 -#define wxColourPickerCtrl_new_0 2256 -#define wxColourPickerCtrl_new_3 2257 -#define wxColourPickerCtrl_Create 2258 -#define wxColourPickerCtrl_GetColour 2259 -#define wxColourPickerCtrl_SetColour_1_1 2260 -#define wxColourPickerCtrl_SetColour_1_0 2261 -#define wxColourPickerCtrl_destroy 2262 -#define wxDatePickerCtrl_new_0 2263 -#define wxDatePickerCtrl_new_3 2264 -#define wxDatePickerCtrl_GetRange 2265 -#define wxDatePickerCtrl_GetValue 2266 -#define wxDatePickerCtrl_SetRange 2267 -#define wxDatePickerCtrl_SetValue 2268 -#define wxDatePickerCtrl_destroy 2269 -#define wxFontPickerCtrl_new_0 2270 -#define wxFontPickerCtrl_new_3 2271 -#define wxFontPickerCtrl_Create 2272 -#define wxFontPickerCtrl_GetSelectedFont 2273 -#define wxFontPickerCtrl_SetSelectedFont 2274 -#define wxFontPickerCtrl_GetMaxPointSize 2275 -#define wxFontPickerCtrl_SetMaxPointSize 2276 -#define wxFontPickerCtrl_destroy 2277 -#define wxFindReplaceDialog_new_0 2280 -#define wxFindReplaceDialog_new_4 2281 -#define wxFindReplaceDialog_destruct 2282 -#define wxFindReplaceDialog_Create 2283 -#define wxFindReplaceDialog_GetData 2284 -#define wxFindReplaceData_new_0 2285 -#define wxFindReplaceData_new_1 2286 -#define wxFindReplaceData_GetFindString 2287 -#define wxFindReplaceData_GetReplaceString 2288 -#define wxFindReplaceData_GetFlags 2289 -#define wxFindReplaceData_SetFlags 2290 -#define wxFindReplaceData_SetFindString 2291 -#define wxFindReplaceData_SetReplaceString 2292 -#define wxFindReplaceData_destroy 2293 -#define wxMultiChoiceDialog_new_0 2294 -#define wxMultiChoiceDialog_new_5 2296 -#define wxMultiChoiceDialog_GetSelections 2297 -#define wxMultiChoiceDialog_SetSelections 2298 -#define wxMultiChoiceDialog_destroy 2299 -#define wxSingleChoiceDialog_new_0 2300 -#define wxSingleChoiceDialog_new_5 2302 -#define wxSingleChoiceDialog_GetSelection 2303 -#define wxSingleChoiceDialog_GetStringSelection 2304 -#define wxSingleChoiceDialog_SetSelection 2305 -#define wxSingleChoiceDialog_destroy 2306 -#define wxTextEntryDialog_new 2307 -#define wxTextEntryDialog_GetValue 2308 -#define wxTextEntryDialog_SetValue 2309 -#define wxTextEntryDialog_destroy 2310 -#define wxPasswordEntryDialog_new 2311 -#define wxPasswordEntryDialog_destroy 2312 -#define wxFontData_new_0 2313 -#define wxFontData_new_1 2314 -#define wxFontData_destruct 2315 -#define wxFontData_EnableEffects 2316 -#define wxFontData_GetAllowSymbols 2317 -#define wxFontData_GetColour 2318 -#define wxFontData_GetChosenFont 2319 -#define wxFontData_GetEnableEffects 2320 -#define wxFontData_GetInitialFont 2321 -#define wxFontData_GetShowHelp 2322 -#define wxFontData_SetAllowSymbols 2323 -#define wxFontData_SetChosenFont 2324 -#define wxFontData_SetColour 2325 -#define wxFontData_SetInitialFont 2326 -#define wxFontData_SetRange 2327 -#define wxFontData_SetShowHelp 2328 -#define wxFontDialog_new_0 2332 -#define wxFontDialog_new_2 2334 -#define wxFontDialog_Create 2336 -#define wxFontDialog_GetFontData 2337 -#define wxFontDialog_destroy 2339 -#define wxProgressDialog_new 2340 -#define wxProgressDialog_destruct 2341 -#define wxProgressDialog_Resume 2342 -#define wxProgressDialog_Update_2 2343 -#define wxProgressDialog_Update_0 2344 -#define wxMessageDialog_new 2345 -#define wxMessageDialog_destruct 2346 -#define wxPageSetupDialog_new 2347 -#define wxPageSetupDialog_destruct 2348 -#define wxPageSetupDialog_GetPageSetupData 2349 -#define wxPageSetupDialog_ShowModal 2350 -#define wxPageSetupDialogData_new_0 2351 -#define wxPageSetupDialogData_new_1_0 2352 -#define wxPageSetupDialogData_new_1_1 2353 -#define wxPageSetupDialogData_destruct 2354 -#define wxPageSetupDialogData_EnableHelp 2355 -#define wxPageSetupDialogData_EnableMargins 2356 -#define wxPageSetupDialogData_EnableOrientation 2357 -#define wxPageSetupDialogData_EnablePaper 2358 -#define wxPageSetupDialogData_EnablePrinter 2359 -#define wxPageSetupDialogData_GetDefaultMinMargins 2360 -#define wxPageSetupDialogData_GetEnableMargins 2361 -#define wxPageSetupDialogData_GetEnableOrientation 2362 -#define wxPageSetupDialogData_GetEnablePaper 2363 -#define wxPageSetupDialogData_GetEnablePrinter 2364 -#define wxPageSetupDialogData_GetEnableHelp 2365 -#define wxPageSetupDialogData_GetDefaultInfo 2366 -#define wxPageSetupDialogData_GetMarginTopLeft 2367 -#define wxPageSetupDialogData_GetMarginBottomRight 2368 -#define wxPageSetupDialogData_GetMinMarginTopLeft 2369 -#define wxPageSetupDialogData_GetMinMarginBottomRight 2370 -#define wxPageSetupDialogData_GetPaperId 2371 -#define wxPageSetupDialogData_GetPaperSize 2372 -#define wxPageSetupDialogData_GetPrintData 2374 -#define wxPageSetupDialogData_IsOk 2375 -#define wxPageSetupDialogData_SetDefaultInfo 2376 -#define wxPageSetupDialogData_SetDefaultMinMargins 2377 -#define wxPageSetupDialogData_SetMarginTopLeft 2378 -#define wxPageSetupDialogData_SetMarginBottomRight 2379 -#define wxPageSetupDialogData_SetMinMarginTopLeft 2380 -#define wxPageSetupDialogData_SetMinMarginBottomRight 2381 -#define wxPageSetupDialogData_SetPaperId 2382 -#define wxPageSetupDialogData_SetPaperSize_1_1 2383 -#define wxPageSetupDialogData_SetPaperSize_1_0 2384 -#define wxPageSetupDialogData_SetPrintData 2385 -#define wxPrintDialog_new_2_0 2386 -#define wxPrintDialog_new_2_1 2387 -#define wxPrintDialog_destruct 2388 -#define wxPrintDialog_GetPrintDialogData 2389 -#define wxPrintDialog_GetPrintDC 2390 -#define wxPrintDialogData_new_0 2391 -#define wxPrintDialogData_new_1_1 2392 -#define wxPrintDialogData_new_1_0 2393 -#define wxPrintDialogData_destruct 2394 -#define wxPrintDialogData_EnableHelp 2395 -#define wxPrintDialogData_EnablePageNumbers 2396 -#define wxPrintDialogData_EnablePrintToFile 2397 -#define wxPrintDialogData_EnableSelection 2398 -#define wxPrintDialogData_GetAllPages 2399 -#define wxPrintDialogData_GetCollate 2400 -#define wxPrintDialogData_GetFromPage 2401 -#define wxPrintDialogData_GetMaxPage 2402 -#define wxPrintDialogData_GetMinPage 2403 -#define wxPrintDialogData_GetNoCopies 2404 -#define wxPrintDialogData_GetPrintData 2405 -#define wxPrintDialogData_GetPrintToFile 2406 -#define wxPrintDialogData_GetSelection 2407 -#define wxPrintDialogData_GetToPage 2408 -#define wxPrintDialogData_IsOk 2409 -#define wxPrintDialogData_SetCollate 2410 -#define wxPrintDialogData_SetFromPage 2411 -#define wxPrintDialogData_SetMaxPage 2412 -#define wxPrintDialogData_SetMinPage 2413 -#define wxPrintDialogData_SetNoCopies 2414 -#define wxPrintDialogData_SetPrintData 2415 -#define wxPrintDialogData_SetPrintToFile 2416 -#define wxPrintDialogData_SetSelection 2417 -#define wxPrintDialogData_SetToPage 2418 -#define wxPrintData_new_0 2419 -#define wxPrintData_new_1 2420 -#define wxPrintData_destruct 2421 -#define wxPrintData_GetCollate 2422 -#define wxPrintData_GetBin 2423 -#define wxPrintData_GetColour 2424 -#define wxPrintData_GetDuplex 2425 -#define wxPrintData_GetNoCopies 2426 -#define wxPrintData_GetOrientation 2427 -#define wxPrintData_GetPaperId 2428 -#define wxPrintData_GetPrinterName 2429 -#define wxPrintData_GetQuality 2430 -#define wxPrintData_IsOk 2431 -#define wxPrintData_SetBin 2432 -#define wxPrintData_SetCollate 2433 -#define wxPrintData_SetColour 2434 -#define wxPrintData_SetDuplex 2435 -#define wxPrintData_SetNoCopies 2436 -#define wxPrintData_SetOrientation 2437 -#define wxPrintData_SetPaperId 2438 -#define wxPrintData_SetPrinterName 2439 -#define wxPrintData_SetQuality 2440 -#define wxPrintPreview_new_2 2443 -#define wxPrintPreview_new_3 2444 -#define wxPrintPreview_destruct 2446 -#define wxPrintPreview_GetCanvas 2447 -#define wxPrintPreview_GetCurrentPage 2448 -#define wxPrintPreview_GetFrame 2449 -#define wxPrintPreview_GetMaxPage 2450 -#define wxPrintPreview_GetMinPage 2451 -#define wxPrintPreview_GetPrintout 2452 -#define wxPrintPreview_GetPrintoutForPrinting 2453 -#define wxPrintPreview_IsOk 2454 -#define wxPrintPreview_PaintPage 2455 -#define wxPrintPreview_Print 2456 -#define wxPrintPreview_RenderPage 2457 -#define wxPrintPreview_SetCanvas 2458 -#define wxPrintPreview_SetCurrentPage 2459 -#define wxPrintPreview_SetFrame 2460 -#define wxPrintPreview_SetPrintout 2461 -#define wxPrintPreview_SetZoom 2462 -#define wxPreviewFrame_new 2463 -#define wxPreviewFrame_destruct 2464 -#define wxPreviewFrame_CreateControlBar 2465 -#define wxPreviewFrame_CreateCanvas 2466 -#define wxPreviewFrame_Initialize 2467 -#define wxPreviewFrame_OnCloseWindow 2468 -#define wxPreviewControlBar_new 2469 -#define wxPreviewControlBar_destruct 2470 -#define wxPreviewControlBar_CreateButtons 2471 -#define wxPreviewControlBar_GetPrintPreview 2472 -#define wxPreviewControlBar_GetZoomControl 2473 -#define wxPreviewControlBar_SetZoomControl 2474 -#define wxPrinter_new 2476 -#define wxPrinter_CreateAbortWindow 2477 -#define wxPrinter_GetAbort 2478 -#define wxPrinter_GetLastError 2479 -#define wxPrinter_GetPrintDialogData 2480 -#define wxPrinter_Print 2481 -#define wxPrinter_PrintDialog 2482 -#define wxPrinter_ReportError 2483 -#define wxPrinter_Setup 2484 -#define wxPrinter_destroy 2485 -#define wxXmlResource_new_1 2486 -#define wxXmlResource_new_2 2487 -#define wxXmlResource_destruct 2488 -#define wxXmlResource_AttachUnknownControl 2489 -#define wxXmlResource_ClearHandlers 2490 -#define wxXmlResource_CompareVersion 2491 -#define wxXmlResource_Get 2492 -#define wxXmlResource_GetFlags 2493 -#define wxXmlResource_GetVersion 2494 -#define wxXmlResource_GetXRCID 2495 -#define wxXmlResource_InitAllHandlers 2496 -#define wxXmlResource_Load 2497 -#define wxXmlResource_LoadBitmap 2498 -#define wxXmlResource_LoadDialog_2 2499 -#define wxXmlResource_LoadDialog_3 2500 -#define wxXmlResource_LoadFrame_2 2501 -#define wxXmlResource_LoadFrame_3 2502 -#define wxXmlResource_LoadIcon 2503 -#define wxXmlResource_LoadMenu 2504 -#define wxXmlResource_LoadMenuBar_2 2505 -#define wxXmlResource_LoadMenuBar_1 2506 -#define wxXmlResource_LoadPanel_2 2507 -#define wxXmlResource_LoadPanel_3 2508 -#define wxXmlResource_LoadToolBar 2509 -#define wxXmlResource_Set 2510 -#define wxXmlResource_SetFlags 2511 -#define wxXmlResource_Unload 2512 -#define wxXmlResource_xrcctrl 2513 -#define wxHtmlEasyPrinting_new 2514 -#define wxHtmlEasyPrinting_destruct 2515 -#define wxHtmlEasyPrinting_GetPrintData 2516 -#define wxHtmlEasyPrinting_GetPageSetupData 2517 -#define wxHtmlEasyPrinting_PreviewFile 2518 -#define wxHtmlEasyPrinting_PreviewText 2519 -#define wxHtmlEasyPrinting_PrintFile 2520 -#define wxHtmlEasyPrinting_PrintText 2521 -#define wxHtmlEasyPrinting_PageSetup 2522 -#define wxHtmlEasyPrinting_SetFonts 2523 -#define wxHtmlEasyPrinting_SetHeader 2524 -#define wxHtmlEasyPrinting_SetFooter 2525 -#define wxGLCanvas_new_2 2527 -#define wxGLCanvas_new_3_1 2528 -#define wxGLCanvas_new_3_0 2529 -#define wxGLCanvas_GetContext 2530 -#define wxGLCanvas_SetCurrent 2532 -#define wxGLCanvas_SwapBuffers 2533 -#define wxGLCanvas_destroy 2534 -#define wxAuiManager_new 2535 -#define wxAuiManager_destruct 2536 -#define wxAuiManager_AddPane_2_1 2537 -#define wxAuiManager_AddPane_3 2538 -#define wxAuiManager_AddPane_2_0 2539 -#define wxAuiManager_DetachPane 2540 -#define wxAuiManager_GetAllPanes 2541 -#define wxAuiManager_GetArtProvider 2542 -#define wxAuiManager_GetDockSizeConstraint 2543 -#define wxAuiManager_GetFlags 2544 -#define wxAuiManager_GetManagedWindow 2545 -#define wxAuiManager_GetManager 2546 -#define wxAuiManager_GetPane_1_1 2547 -#define wxAuiManager_GetPane_1_0 2548 -#define wxAuiManager_HideHint 2549 -#define wxAuiManager_InsertPane 2550 -#define wxAuiManager_LoadPaneInfo 2551 -#define wxAuiManager_LoadPerspective 2552 -#define wxAuiManager_SavePaneInfo 2553 -#define wxAuiManager_SavePerspective 2554 -#define wxAuiManager_SetArtProvider 2555 -#define wxAuiManager_SetDockSizeConstraint 2556 -#define wxAuiManager_SetFlags 2557 -#define wxAuiManager_SetManagedWindow 2558 -#define wxAuiManager_ShowHint 2559 -#define wxAuiManager_UnInit 2560 -#define wxAuiManager_Update 2561 -#define wxAuiPaneInfo_new_0 2562 -#define wxAuiPaneInfo_new_1 2563 -#define wxAuiPaneInfo_destruct 2564 -#define wxAuiPaneInfo_BestSize_1 2565 -#define wxAuiPaneInfo_BestSize_2 2566 -#define wxAuiPaneInfo_Bottom 2567 -#define wxAuiPaneInfo_BottomDockable 2568 -#define wxAuiPaneInfo_Caption 2569 -#define wxAuiPaneInfo_CaptionVisible 2570 -#define wxAuiPaneInfo_Centre 2571 -#define wxAuiPaneInfo_CentrePane 2572 -#define wxAuiPaneInfo_CloseButton 2573 -#define wxAuiPaneInfo_DefaultPane 2574 -#define wxAuiPaneInfo_DestroyOnClose 2575 -#define wxAuiPaneInfo_Direction 2576 -#define wxAuiPaneInfo_Dock 2577 -#define wxAuiPaneInfo_Dockable 2578 -#define wxAuiPaneInfo_Fixed 2579 -#define wxAuiPaneInfo_Float 2580 -#define wxAuiPaneInfo_Floatable 2581 -#define wxAuiPaneInfo_FloatingPosition_1 2582 -#define wxAuiPaneInfo_FloatingPosition_2 2583 -#define wxAuiPaneInfo_FloatingSize_1 2584 -#define wxAuiPaneInfo_FloatingSize_2 2585 -#define wxAuiPaneInfo_Gripper 2586 -#define wxAuiPaneInfo_GripperTop 2587 -#define wxAuiPaneInfo_HasBorder 2588 -#define wxAuiPaneInfo_HasCaption 2589 -#define wxAuiPaneInfo_HasCloseButton 2590 -#define wxAuiPaneInfo_HasFlag 2591 -#define wxAuiPaneInfo_HasGripper 2592 -#define wxAuiPaneInfo_HasGripperTop 2593 -#define wxAuiPaneInfo_HasMaximizeButton 2594 -#define wxAuiPaneInfo_HasMinimizeButton 2595 -#define wxAuiPaneInfo_HasPinButton 2596 -#define wxAuiPaneInfo_Hide 2597 -#define wxAuiPaneInfo_IsBottomDockable 2598 -#define wxAuiPaneInfo_IsDocked 2599 -#define wxAuiPaneInfo_IsFixed 2600 -#define wxAuiPaneInfo_IsFloatable 2601 -#define wxAuiPaneInfo_IsFloating 2602 -#define wxAuiPaneInfo_IsLeftDockable 2603 -#define wxAuiPaneInfo_IsMovable 2604 -#define wxAuiPaneInfo_IsOk 2605 -#define wxAuiPaneInfo_IsResizable 2606 -#define wxAuiPaneInfo_IsRightDockable 2607 -#define wxAuiPaneInfo_IsShown 2608 -#define wxAuiPaneInfo_IsToolbar 2609 -#define wxAuiPaneInfo_IsTopDockable 2610 -#define wxAuiPaneInfo_Layer 2611 -#define wxAuiPaneInfo_Left 2612 -#define wxAuiPaneInfo_LeftDockable 2613 -#define wxAuiPaneInfo_MaxSize_1 2614 -#define wxAuiPaneInfo_MaxSize_2 2615 -#define wxAuiPaneInfo_MaximizeButton 2616 -#define wxAuiPaneInfo_MinSize_1 2617 -#define wxAuiPaneInfo_MinSize_2 2618 -#define wxAuiPaneInfo_MinimizeButton 2619 -#define wxAuiPaneInfo_Movable 2620 -#define wxAuiPaneInfo_Name 2621 -#define wxAuiPaneInfo_PaneBorder 2622 -#define wxAuiPaneInfo_PinButton 2623 -#define wxAuiPaneInfo_Position 2624 -#define wxAuiPaneInfo_Resizable 2625 -#define wxAuiPaneInfo_Right 2626 -#define wxAuiPaneInfo_RightDockable 2627 -#define wxAuiPaneInfo_Row 2628 -#define wxAuiPaneInfo_SafeSet 2629 -#define wxAuiPaneInfo_SetFlag 2630 -#define wxAuiPaneInfo_Show 2631 -#define wxAuiPaneInfo_ToolbarPane 2632 -#define wxAuiPaneInfo_Top 2633 -#define wxAuiPaneInfo_TopDockable 2634 -#define wxAuiPaneInfo_Window 2635 -#define wxAuiNotebook_new_0 2636 -#define wxAuiNotebook_new_2 2637 -#define wxAuiNotebook_AddPage 2638 -#define wxAuiNotebook_Create 2639 -#define wxAuiNotebook_DeletePage 2640 -#define wxAuiNotebook_GetArtProvider 2641 -#define wxAuiNotebook_GetPage 2642 -#define wxAuiNotebook_GetPageBitmap 2643 -#define wxAuiNotebook_GetPageCount 2644 -#define wxAuiNotebook_GetPageIndex 2645 -#define wxAuiNotebook_GetPageText 2646 -#define wxAuiNotebook_GetSelection 2647 -#define wxAuiNotebook_InsertPage 2648 -#define wxAuiNotebook_RemovePage 2649 -#define wxAuiNotebook_SetArtProvider 2650 -#define wxAuiNotebook_SetFont 2651 -#define wxAuiNotebook_SetPageBitmap 2652 -#define wxAuiNotebook_SetPageText 2653 -#define wxAuiNotebook_SetSelection 2654 -#define wxAuiNotebook_SetTabCtrlHeight 2655 -#define wxAuiNotebook_SetUniformBitmapSize 2656 -#define wxAuiNotebook_destroy 2657 -#define wxMDIParentFrame_new_0 2658 -#define wxMDIParentFrame_new_4 2659 -#define wxMDIParentFrame_destruct 2660 -#define wxMDIParentFrame_ActivateNext 2661 -#define wxMDIParentFrame_ActivatePrevious 2662 -#define wxMDIParentFrame_ArrangeIcons 2663 -#define wxMDIParentFrame_Cascade 2664 -#define wxMDIParentFrame_Create 2665 -#define wxMDIParentFrame_GetActiveChild 2666 -#define wxMDIParentFrame_GetClientWindow 2667 -#define wxMDIParentFrame_Tile 2668 -#define wxMDIChildFrame_new_0 2669 -#define wxMDIChildFrame_new_4 2670 -#define wxMDIChildFrame_destruct 2671 -#define wxMDIChildFrame_Activate 2672 -#define wxMDIChildFrame_Create 2673 -#define wxMDIChildFrame_Maximize 2674 -#define wxMDIChildFrame_Restore 2675 -#define wxMDIClientWindow_new_0 2676 -#define wxMDIClientWindow_new_2 2677 -#define wxMDIClientWindow_destruct 2678 -#define wxMDIClientWindow_CreateClient 2679 -#define wxLayoutAlgorithm_new 2680 -#define wxLayoutAlgorithm_LayoutFrame 2681 -#define wxLayoutAlgorithm_LayoutMDIFrame 2682 -#define wxLayoutAlgorithm_LayoutWindow 2683 -#define wxLayoutAlgorithm_destroy 2684 -#define wxEvent_GetId 2685 -#define wxEvent_GetSkipped 2686 -#define wxEvent_GetTimestamp 2687 -#define wxEvent_IsCommandEvent 2688 -#define wxEvent_ResumePropagation 2689 -#define wxEvent_ShouldPropagate 2690 -#define wxEvent_Skip 2691 -#define wxEvent_StopPropagation 2692 -#define wxCommandEvent_getClientData 2693 -#define wxCommandEvent_GetExtraLong 2694 -#define wxCommandEvent_GetInt 2695 -#define wxCommandEvent_GetSelection 2696 -#define wxCommandEvent_GetString 2697 -#define wxCommandEvent_IsChecked 2698 -#define wxCommandEvent_IsSelection 2699 -#define wxCommandEvent_SetInt 2700 -#define wxCommandEvent_SetString 2701 -#define wxScrollEvent_GetOrientation 2702 -#define wxScrollEvent_GetPosition 2703 -#define wxScrollWinEvent_GetOrientation 2704 -#define wxScrollWinEvent_GetPosition 2705 -#define wxMouseEvent_AltDown 2706 -#define wxMouseEvent_Button 2707 -#define wxMouseEvent_ButtonDClick 2708 -#define wxMouseEvent_ButtonDown 2709 -#define wxMouseEvent_ButtonUp 2710 -#define wxMouseEvent_CmdDown 2711 -#define wxMouseEvent_ControlDown 2712 -#define wxMouseEvent_Dragging 2713 -#define wxMouseEvent_Entering 2714 -#define wxMouseEvent_GetButton 2715 -#define wxMouseEvent_GetPosition 2718 -#define wxMouseEvent_GetLogicalPosition 2719 -#define wxMouseEvent_GetLinesPerAction 2720 -#define wxMouseEvent_GetWheelRotation 2721 -#define wxMouseEvent_GetWheelDelta 2722 -#define wxMouseEvent_GetX 2723 -#define wxMouseEvent_GetY 2724 -#define wxMouseEvent_IsButton 2725 -#define wxMouseEvent_IsPageScroll 2726 -#define wxMouseEvent_Leaving 2727 -#define wxMouseEvent_LeftDClick 2728 -#define wxMouseEvent_LeftDown 2729 -#define wxMouseEvent_LeftIsDown 2730 -#define wxMouseEvent_LeftUp 2731 -#define wxMouseEvent_MetaDown 2732 -#define wxMouseEvent_MiddleDClick 2733 -#define wxMouseEvent_MiddleDown 2734 -#define wxMouseEvent_MiddleIsDown 2735 -#define wxMouseEvent_MiddleUp 2736 -#define wxMouseEvent_Moving 2737 -#define wxMouseEvent_RightDClick 2738 -#define wxMouseEvent_RightDown 2739 -#define wxMouseEvent_RightIsDown 2740 -#define wxMouseEvent_RightUp 2741 -#define wxMouseEvent_ShiftDown 2742 -#define wxSetCursorEvent_GetCursor 2743 -#define wxSetCursorEvent_GetX 2744 -#define wxSetCursorEvent_GetY 2745 -#define wxSetCursorEvent_HasCursor 2746 -#define wxSetCursorEvent_SetCursor 2747 -#define wxKeyEvent_AltDown 2748 -#define wxKeyEvent_CmdDown 2749 -#define wxKeyEvent_ControlDown 2750 -#define wxKeyEvent_GetKeyCode 2751 -#define wxKeyEvent_GetModifiers 2752 -#define wxKeyEvent_GetPosition 2755 -#define wxKeyEvent_GetRawKeyCode 2756 -#define wxKeyEvent_GetRawKeyFlags 2757 -#define wxKeyEvent_GetUnicodeKey 2758 -#define wxKeyEvent_GetX 2759 -#define wxKeyEvent_GetY 2760 -#define wxKeyEvent_HasModifiers 2761 -#define wxKeyEvent_MetaDown 2762 -#define wxKeyEvent_ShiftDown 2763 -#define wxSizeEvent_GetSize 2764 -#define wxMoveEvent_GetPosition 2765 -#define wxEraseEvent_GetDC 2766 -#define wxFocusEvent_GetWindow 2767 -#define wxChildFocusEvent_GetWindow 2768 -#define wxMenuEvent_GetMenu 2769 -#define wxMenuEvent_GetMenuId 2770 -#define wxMenuEvent_IsPopup 2771 -#define wxCloseEvent_CanVeto 2772 -#define wxCloseEvent_GetLoggingOff 2773 -#define wxCloseEvent_SetCanVeto 2774 -#define wxCloseEvent_SetLoggingOff 2775 -#define wxCloseEvent_Veto 2776 -#define wxShowEvent_SetShow 2777 -#define wxShowEvent_GetShow 2778 -#define wxIconizeEvent_Iconized 2779 -#define wxJoystickEvent_ButtonDown 2780 -#define wxJoystickEvent_ButtonIsDown 2781 -#define wxJoystickEvent_ButtonUp 2782 -#define wxJoystickEvent_GetButtonChange 2783 -#define wxJoystickEvent_GetButtonState 2784 -#define wxJoystickEvent_GetJoystick 2785 -#define wxJoystickEvent_GetPosition 2786 -#define wxJoystickEvent_GetZPosition 2787 -#define wxJoystickEvent_IsButton 2788 -#define wxJoystickEvent_IsMove 2789 -#define wxJoystickEvent_IsZMove 2790 -#define wxUpdateUIEvent_CanUpdate 2791 -#define wxUpdateUIEvent_Check 2792 -#define wxUpdateUIEvent_Enable 2793 -#define wxUpdateUIEvent_Show 2794 -#define wxUpdateUIEvent_GetChecked 2795 -#define wxUpdateUIEvent_GetEnabled 2796 -#define wxUpdateUIEvent_GetShown 2797 -#define wxUpdateUIEvent_GetSetChecked 2798 -#define wxUpdateUIEvent_GetSetEnabled 2799 -#define wxUpdateUIEvent_GetSetShown 2800 -#define wxUpdateUIEvent_GetSetText 2801 -#define wxUpdateUIEvent_GetText 2802 -#define wxUpdateUIEvent_GetMode 2803 -#define wxUpdateUIEvent_GetUpdateInterval 2804 -#define wxUpdateUIEvent_ResetUpdateTime 2805 -#define wxUpdateUIEvent_SetMode 2806 -#define wxUpdateUIEvent_SetText 2807 -#define wxUpdateUIEvent_SetUpdateInterval 2808 -#define wxMouseCaptureChangedEvent_GetCapturedWindow 2809 -#define wxPaletteChangedEvent_SetChangedWindow 2810 -#define wxPaletteChangedEvent_GetChangedWindow 2811 -#define wxQueryNewPaletteEvent_SetPaletteRealized 2812 -#define wxQueryNewPaletteEvent_GetPaletteRealized 2813 -#define wxNavigationKeyEvent_GetDirection 2814 -#define wxNavigationKeyEvent_SetDirection 2815 -#define wxNavigationKeyEvent_IsWindowChange 2816 -#define wxNavigationKeyEvent_SetWindowChange 2817 -#define wxNavigationKeyEvent_IsFromTab 2818 -#define wxNavigationKeyEvent_SetFromTab 2819 -#define wxNavigationKeyEvent_GetCurrentFocus 2820 -#define wxNavigationKeyEvent_SetCurrentFocus 2821 -#define wxHelpEvent_GetOrigin 2822 -#define wxHelpEvent_GetPosition 2823 -#define wxHelpEvent_SetOrigin 2824 -#define wxHelpEvent_SetPosition 2825 -#define wxContextMenuEvent_GetPosition 2826 -#define wxContextMenuEvent_SetPosition 2827 -#define wxIdleEvent_CanSend 2828 -#define wxIdleEvent_GetMode 2829 -#define wxIdleEvent_RequestMore 2830 -#define wxIdleEvent_MoreRequested 2831 -#define wxIdleEvent_SetMode 2832 -#define wxGridEvent_AltDown 2833 -#define wxGridEvent_ControlDown 2834 -#define wxGridEvent_GetCol 2835 -#define wxGridEvent_GetPosition 2836 -#define wxGridEvent_GetRow 2837 -#define wxGridEvent_MetaDown 2838 -#define wxGridEvent_Selecting 2839 -#define wxGridEvent_ShiftDown 2840 -#define wxNotifyEvent_Allow 2841 -#define wxNotifyEvent_IsAllowed 2842 -#define wxNotifyEvent_Veto 2843 -#define wxSashEvent_GetEdge 2844 -#define wxSashEvent_GetDragRect 2845 -#define wxSashEvent_GetDragStatus 2846 -#define wxListEvent_GetCacheFrom 2847 -#define wxListEvent_GetCacheTo 2848 -#define wxListEvent_GetKeyCode 2849 -#define wxListEvent_GetIndex 2850 -#define wxListEvent_GetColumn 2851 -#define wxListEvent_GetPoint 2852 -#define wxListEvent_GetLabel 2853 -#define wxListEvent_GetText 2854 -#define wxListEvent_GetImage 2855 -#define wxListEvent_GetData 2856 -#define wxListEvent_GetMask 2857 -#define wxListEvent_GetItem 2858 -#define wxListEvent_IsEditCancelled 2859 -#define wxDateEvent_GetDate 2860 -#define wxCalendarEvent_GetWeekDay 2861 -#define wxFileDirPickerEvent_GetPath 2862 -#define wxColourPickerEvent_GetColour 2863 -#define wxFontPickerEvent_GetFont 2864 -#define wxStyledTextEvent_GetPosition 2865 -#define wxStyledTextEvent_GetKey 2866 -#define wxStyledTextEvent_GetModifiers 2867 -#define wxStyledTextEvent_GetModificationType 2868 -#define wxStyledTextEvent_GetText 2869 -#define wxStyledTextEvent_GetLength 2870 -#define wxStyledTextEvent_GetLinesAdded 2871 -#define wxStyledTextEvent_GetLine 2872 -#define wxStyledTextEvent_GetFoldLevelNow 2873 -#define wxStyledTextEvent_GetFoldLevelPrev 2874 -#define wxStyledTextEvent_GetMargin 2875 -#define wxStyledTextEvent_GetMessage 2876 -#define wxStyledTextEvent_GetWParam 2877 -#define wxStyledTextEvent_GetLParam 2878 -#define wxStyledTextEvent_GetListType 2879 -#define wxStyledTextEvent_GetX 2880 -#define wxStyledTextEvent_GetY 2881 -#define wxStyledTextEvent_GetDragText 2882 -#define wxStyledTextEvent_GetDragAllowMove 2883 -#define wxStyledTextEvent_GetDragResult 2884 -#define wxStyledTextEvent_GetShift 2885 -#define wxStyledTextEvent_GetControl 2886 -#define wxStyledTextEvent_GetAlt 2887 -#define utils_wxGetKeyState 2888 -#define utils_wxGetMousePosition 2889 -#define utils_wxGetMouseState 2890 -#define utils_wxSetDetectableAutoRepeat 2891 -#define utils_wxBell 2892 -#define utils_wxFindMenuItemId 2893 -#define utils_wxGenericFindWindowAtPoint 2894 -#define utils_wxFindWindowAtPoint 2895 -#define utils_wxBeginBusyCursor 2896 -#define utils_wxEndBusyCursor 2897 -#define utils_wxIsBusy 2898 -#define utils_wxShutdown 2899 -#define utils_wxShell 2900 -#define utils_wxLaunchDefaultBrowser 2901 -#define utils_wxGetEmailAddress 2902 -#define utils_wxGetUserId 2903 -#define utils_wxGetHomeDir 2904 -#define utils_wxNewId 2905 -#define utils_wxRegisterId 2906 -#define utils_wxGetCurrentId 2907 -#define utils_wxGetOsDescription 2908 -#define utils_wxIsPlatformLittleEndian 2909 -#define utils_wxIsPlatform64Bit 2910 -#define wxPrintout_new 2911 -#define wxPrintout_destruct 2912 -#define wxPrintout_GetDC 2913 -#define wxPrintout_GetPageSizeMM 2914 -#define wxPrintout_GetPageSizePixels 2915 -#define wxPrintout_GetPaperRectPixels 2916 -#define wxPrintout_GetPPIPrinter 2917 -#define wxPrintout_GetPPIScreen 2918 -#define wxPrintout_GetTitle 2919 -#define wxPrintout_IsPreview 2920 -#define wxPrintout_FitThisSizeToPaper 2921 -#define wxPrintout_FitThisSizeToPage 2922 -#define wxPrintout_FitThisSizeToPageMargins 2923 -#define wxPrintout_MapScreenSizeToPaper 2924 -#define wxPrintout_MapScreenSizeToPage 2925 -#define wxPrintout_MapScreenSizeToPageMargins 2926 -#define wxPrintout_MapScreenSizeToDevice 2927 -#define wxPrintout_GetLogicalPaperRect 2928 -#define wxPrintout_GetLogicalPageRect 2929 -#define wxPrintout_GetLogicalPageMarginsRect 2930 -#define wxPrintout_SetLogicalOrigin 2931 -#define wxPrintout_OffsetLogicalOrigin 2932 -#define wxStyledTextCtrl_new_2 2933 -#define wxStyledTextCtrl_new_0 2934 -#define wxStyledTextCtrl_destruct 2935 -#define wxStyledTextCtrl_Create 2936 -#define wxStyledTextCtrl_AddText 2937 -#define wxStyledTextCtrl_AddStyledText 2938 -#define wxStyledTextCtrl_InsertText 2939 -#define wxStyledTextCtrl_ClearAll 2940 -#define wxStyledTextCtrl_ClearDocumentStyle 2941 -#define wxStyledTextCtrl_GetLength 2942 -#define wxStyledTextCtrl_GetCharAt 2943 -#define wxStyledTextCtrl_GetCurrentPos 2944 -#define wxStyledTextCtrl_GetAnchor 2945 -#define wxStyledTextCtrl_GetStyleAt 2946 -#define wxStyledTextCtrl_Redo 2947 -#define wxStyledTextCtrl_SetUndoCollection 2948 -#define wxStyledTextCtrl_SelectAll 2949 -#define wxStyledTextCtrl_SetSavePoint 2950 -#define wxStyledTextCtrl_GetStyledText 2951 -#define wxStyledTextCtrl_CanRedo 2952 -#define wxStyledTextCtrl_MarkerLineFromHandle 2953 -#define wxStyledTextCtrl_MarkerDeleteHandle 2954 -#define wxStyledTextCtrl_GetUndoCollection 2955 -#define wxStyledTextCtrl_GetViewWhiteSpace 2956 -#define wxStyledTextCtrl_SetViewWhiteSpace 2957 -#define wxStyledTextCtrl_PositionFromPoint 2958 -#define wxStyledTextCtrl_PositionFromPointClose 2959 -#define wxStyledTextCtrl_GotoLine 2960 -#define wxStyledTextCtrl_GotoPos 2961 -#define wxStyledTextCtrl_SetAnchor 2962 -#define wxStyledTextCtrl_GetCurLine 2963 -#define wxStyledTextCtrl_GetEndStyled 2964 -#define wxStyledTextCtrl_ConvertEOLs 2965 -#define wxStyledTextCtrl_GetEOLMode 2966 -#define wxStyledTextCtrl_SetEOLMode 2967 -#define wxStyledTextCtrl_StartStyling 2968 -#define wxStyledTextCtrl_SetStyling 2969 -#define wxStyledTextCtrl_GetBufferedDraw 2970 -#define wxStyledTextCtrl_SetBufferedDraw 2971 -#define wxStyledTextCtrl_SetTabWidth 2972 -#define wxStyledTextCtrl_GetTabWidth 2973 -#define wxStyledTextCtrl_SetCodePage 2974 -#define wxStyledTextCtrl_MarkerDefine 2975 -#define wxStyledTextCtrl_MarkerSetForeground 2976 -#define wxStyledTextCtrl_MarkerSetBackground 2977 -#define wxStyledTextCtrl_MarkerAdd 2978 -#define wxStyledTextCtrl_MarkerDelete 2979 -#define wxStyledTextCtrl_MarkerDeleteAll 2980 -#define wxStyledTextCtrl_MarkerGet 2981 -#define wxStyledTextCtrl_MarkerNext 2982 -#define wxStyledTextCtrl_MarkerPrevious 2983 -#define wxStyledTextCtrl_MarkerDefineBitmap 2984 -#define wxStyledTextCtrl_MarkerAddSet 2985 -#define wxStyledTextCtrl_MarkerSetAlpha 2986 -#define wxStyledTextCtrl_SetMarginType 2987 -#define wxStyledTextCtrl_GetMarginType 2988 -#define wxStyledTextCtrl_SetMarginWidth 2989 -#define wxStyledTextCtrl_GetMarginWidth 2990 -#define wxStyledTextCtrl_SetMarginMask 2991 -#define wxStyledTextCtrl_GetMarginMask 2992 -#define wxStyledTextCtrl_SetMarginSensitive 2993 -#define wxStyledTextCtrl_GetMarginSensitive 2994 -#define wxStyledTextCtrl_StyleClearAll 2995 -#define wxStyledTextCtrl_StyleSetForeground 2996 -#define wxStyledTextCtrl_StyleSetBackground 2997 -#define wxStyledTextCtrl_StyleSetBold 2998 -#define wxStyledTextCtrl_StyleSetItalic 2999 -#define wxStyledTextCtrl_StyleSetSize 3000 -#define wxStyledTextCtrl_StyleSetFaceName 3001 -#define wxStyledTextCtrl_StyleSetEOLFilled 3002 -#define wxStyledTextCtrl_StyleResetDefault 3003 -#define wxStyledTextCtrl_StyleSetUnderline 3004 -#define wxStyledTextCtrl_StyleSetCase 3005 -#define wxStyledTextCtrl_StyleSetHotSpot 3006 -#define wxStyledTextCtrl_SetSelForeground 3007 -#define wxStyledTextCtrl_SetSelBackground 3008 -#define wxStyledTextCtrl_GetSelAlpha 3009 -#define wxStyledTextCtrl_SetSelAlpha 3010 -#define wxStyledTextCtrl_SetCaretForeground 3011 -#define wxStyledTextCtrl_CmdKeyAssign 3012 -#define wxStyledTextCtrl_CmdKeyClear 3013 -#define wxStyledTextCtrl_CmdKeyClearAll 3014 -#define wxStyledTextCtrl_SetStyleBytes 3015 -#define wxStyledTextCtrl_StyleSetVisible 3016 -#define wxStyledTextCtrl_GetCaretPeriod 3017 -#define wxStyledTextCtrl_SetCaretPeriod 3018 -#define wxStyledTextCtrl_SetWordChars 3019 -#define wxStyledTextCtrl_BeginUndoAction 3020 -#define wxStyledTextCtrl_EndUndoAction 3021 -#define wxStyledTextCtrl_IndicatorSetStyle 3022 -#define wxStyledTextCtrl_IndicatorGetStyle 3023 -#define wxStyledTextCtrl_IndicatorSetForeground 3024 -#define wxStyledTextCtrl_IndicatorGetForeground 3025 -#define wxStyledTextCtrl_SetWhitespaceForeground 3026 -#define wxStyledTextCtrl_SetWhitespaceBackground 3027 -#define wxStyledTextCtrl_GetStyleBits 3028 -#define wxStyledTextCtrl_SetLineState 3029 -#define wxStyledTextCtrl_GetLineState 3030 -#define wxStyledTextCtrl_GetMaxLineState 3031 -#define wxStyledTextCtrl_GetCaretLineVisible 3032 -#define wxStyledTextCtrl_SetCaretLineVisible 3033 -#define wxStyledTextCtrl_GetCaretLineBackground 3034 -#define wxStyledTextCtrl_SetCaretLineBackground 3035 -#define wxStyledTextCtrl_AutoCompShow 3036 -#define wxStyledTextCtrl_AutoCompCancel 3037 -#define wxStyledTextCtrl_AutoCompActive 3038 -#define wxStyledTextCtrl_AutoCompPosStart 3039 -#define wxStyledTextCtrl_AutoCompComplete 3040 -#define wxStyledTextCtrl_AutoCompStops 3041 -#define wxStyledTextCtrl_AutoCompSetSeparator 3042 -#define wxStyledTextCtrl_AutoCompGetSeparator 3043 -#define wxStyledTextCtrl_AutoCompSelect 3044 -#define wxStyledTextCtrl_AutoCompSetCancelAtStart 3045 -#define wxStyledTextCtrl_AutoCompGetCancelAtStart 3046 -#define wxStyledTextCtrl_AutoCompSetFillUps 3047 -#define wxStyledTextCtrl_AutoCompSetChooseSingle 3048 -#define wxStyledTextCtrl_AutoCompGetChooseSingle 3049 -#define wxStyledTextCtrl_AutoCompSetIgnoreCase 3050 -#define wxStyledTextCtrl_AutoCompGetIgnoreCase 3051 -#define wxStyledTextCtrl_UserListShow 3052 -#define wxStyledTextCtrl_AutoCompSetAutoHide 3053 -#define wxStyledTextCtrl_AutoCompGetAutoHide 3054 -#define wxStyledTextCtrl_AutoCompSetDropRestOfWord 3055 -#define wxStyledTextCtrl_AutoCompGetDropRestOfWord 3056 -#define wxStyledTextCtrl_RegisterImage 3057 -#define wxStyledTextCtrl_ClearRegisteredImages 3058 -#define wxStyledTextCtrl_AutoCompGetTypeSeparator 3059 -#define wxStyledTextCtrl_AutoCompSetTypeSeparator 3060 -#define wxStyledTextCtrl_AutoCompSetMaxWidth 3061 -#define wxStyledTextCtrl_AutoCompGetMaxWidth 3062 -#define wxStyledTextCtrl_AutoCompSetMaxHeight 3063 -#define wxStyledTextCtrl_AutoCompGetMaxHeight 3064 -#define wxStyledTextCtrl_SetIndent 3065 -#define wxStyledTextCtrl_GetIndent 3066 -#define wxStyledTextCtrl_SetUseTabs 3067 -#define wxStyledTextCtrl_GetUseTabs 3068 -#define wxStyledTextCtrl_SetLineIndentation 3069 -#define wxStyledTextCtrl_GetLineIndentation 3070 -#define wxStyledTextCtrl_GetLineIndentPosition 3071 -#define wxStyledTextCtrl_GetColumn 3072 -#define wxStyledTextCtrl_SetUseHorizontalScrollBar 3073 -#define wxStyledTextCtrl_GetUseHorizontalScrollBar 3074 -#define wxStyledTextCtrl_SetIndentationGuides 3075 -#define wxStyledTextCtrl_GetIndentationGuides 3076 -#define wxStyledTextCtrl_SetHighlightGuide 3077 -#define wxStyledTextCtrl_GetHighlightGuide 3078 -#define wxStyledTextCtrl_GetLineEndPosition 3079 -#define wxStyledTextCtrl_GetCodePage 3080 -#define wxStyledTextCtrl_GetCaretForeground 3081 -#define wxStyledTextCtrl_GetReadOnly 3082 -#define wxStyledTextCtrl_SetCurrentPos 3083 -#define wxStyledTextCtrl_SetSelectionStart 3084 -#define wxStyledTextCtrl_GetSelectionStart 3085 -#define wxStyledTextCtrl_SetSelectionEnd 3086 -#define wxStyledTextCtrl_GetSelectionEnd 3087 -#define wxStyledTextCtrl_SetPrintMagnification 3088 -#define wxStyledTextCtrl_GetPrintMagnification 3089 -#define wxStyledTextCtrl_SetPrintColourMode 3090 -#define wxStyledTextCtrl_GetPrintColourMode 3091 -#define wxStyledTextCtrl_FindText 3092 -#define wxStyledTextCtrl_FormatRange 3093 -#define wxStyledTextCtrl_GetFirstVisibleLine 3094 -#define wxStyledTextCtrl_GetLine 3095 -#define wxStyledTextCtrl_GetLineCount 3096 -#define wxStyledTextCtrl_SetMarginLeft 3097 -#define wxStyledTextCtrl_GetMarginLeft 3098 -#define wxStyledTextCtrl_SetMarginRight 3099 -#define wxStyledTextCtrl_GetMarginRight 3100 -#define wxStyledTextCtrl_GetModify 3101 -#define wxStyledTextCtrl_SetSelection 3102 -#define wxStyledTextCtrl_GetSelectedText 3103 -#define wxStyledTextCtrl_GetTextRange 3104 -#define wxStyledTextCtrl_HideSelection 3105 -#define wxStyledTextCtrl_LineFromPosition 3106 -#define wxStyledTextCtrl_PositionFromLine 3107 -#define wxStyledTextCtrl_LineScroll 3108 -#define wxStyledTextCtrl_EnsureCaretVisible 3109 -#define wxStyledTextCtrl_ReplaceSelection 3110 -#define wxStyledTextCtrl_SetReadOnly 3111 -#define wxStyledTextCtrl_CanPaste 3112 -#define wxStyledTextCtrl_CanUndo 3113 -#define wxStyledTextCtrl_EmptyUndoBuffer 3114 -#define wxStyledTextCtrl_Undo 3115 -#define wxStyledTextCtrl_Cut 3116 -#define wxStyledTextCtrl_Copy 3117 -#define wxStyledTextCtrl_Paste 3118 -#define wxStyledTextCtrl_Clear 3119 -#define wxStyledTextCtrl_SetText 3120 -#define wxStyledTextCtrl_GetText 3121 -#define wxStyledTextCtrl_GetTextLength 3122 -#define wxStyledTextCtrl_GetOvertype 3123 -#define wxStyledTextCtrl_SetCaretWidth 3124 -#define wxStyledTextCtrl_GetCaretWidth 3125 -#define wxStyledTextCtrl_SetTargetStart 3126 -#define wxStyledTextCtrl_GetTargetStart 3127 -#define wxStyledTextCtrl_SetTargetEnd 3128 -#define wxStyledTextCtrl_GetTargetEnd 3129 -#define wxStyledTextCtrl_ReplaceTarget 3130 -#define wxStyledTextCtrl_SearchInTarget 3131 -#define wxStyledTextCtrl_SetSearchFlags 3132 -#define wxStyledTextCtrl_GetSearchFlags 3133 -#define wxStyledTextCtrl_CallTipShow 3134 -#define wxStyledTextCtrl_CallTipCancel 3135 -#define wxStyledTextCtrl_CallTipActive 3136 -#define wxStyledTextCtrl_CallTipPosAtStart 3137 -#define wxStyledTextCtrl_CallTipSetHighlight 3138 -#define wxStyledTextCtrl_CallTipSetBackground 3139 -#define wxStyledTextCtrl_CallTipSetForeground 3140 -#define wxStyledTextCtrl_CallTipSetForegroundHighlight 3141 -#define wxStyledTextCtrl_CallTipUseStyle 3142 -#define wxStyledTextCtrl_VisibleFromDocLine 3143 -#define wxStyledTextCtrl_DocLineFromVisible 3144 -#define wxStyledTextCtrl_WrapCount 3145 -#define wxStyledTextCtrl_SetFoldLevel 3146 -#define wxStyledTextCtrl_GetFoldLevel 3147 -#define wxStyledTextCtrl_GetLastChild 3148 -#define wxStyledTextCtrl_GetFoldParent 3149 -#define wxStyledTextCtrl_ShowLines 3150 -#define wxStyledTextCtrl_HideLines 3151 -#define wxStyledTextCtrl_GetLineVisible 3152 -#define wxStyledTextCtrl_SetFoldExpanded 3153 -#define wxStyledTextCtrl_GetFoldExpanded 3154 -#define wxStyledTextCtrl_ToggleFold 3155 -#define wxStyledTextCtrl_EnsureVisible 3156 -#define wxStyledTextCtrl_SetFoldFlags 3157 -#define wxStyledTextCtrl_EnsureVisibleEnforcePolicy 3158 -#define wxStyledTextCtrl_SetTabIndents 3159 -#define wxStyledTextCtrl_GetTabIndents 3160 -#define wxStyledTextCtrl_SetBackSpaceUnIndents 3161 -#define wxStyledTextCtrl_GetBackSpaceUnIndents 3162 -#define wxStyledTextCtrl_SetMouseDwellTime 3163 -#define wxStyledTextCtrl_GetMouseDwellTime 3164 -#define wxStyledTextCtrl_WordStartPosition 3165 -#define wxStyledTextCtrl_WordEndPosition 3166 -#define wxStyledTextCtrl_SetWrapMode 3167 -#define wxStyledTextCtrl_GetWrapMode 3168 -#define wxStyledTextCtrl_SetWrapVisualFlags 3169 -#define wxStyledTextCtrl_GetWrapVisualFlags 3170 -#define wxStyledTextCtrl_SetWrapVisualFlagsLocation 3171 -#define wxStyledTextCtrl_GetWrapVisualFlagsLocation 3172 -#define wxStyledTextCtrl_SetWrapStartIndent 3173 -#define wxStyledTextCtrl_GetWrapStartIndent 3174 -#define wxStyledTextCtrl_SetLayoutCache 3175 -#define wxStyledTextCtrl_GetLayoutCache 3176 -#define wxStyledTextCtrl_SetScrollWidth 3177 -#define wxStyledTextCtrl_GetScrollWidth 3178 -#define wxStyledTextCtrl_TextWidth 3179 -#define wxStyledTextCtrl_GetEndAtLastLine 3180 -#define wxStyledTextCtrl_TextHeight 3181 -#define wxStyledTextCtrl_SetUseVerticalScrollBar 3182 -#define wxStyledTextCtrl_GetUseVerticalScrollBar 3183 -#define wxStyledTextCtrl_AppendText 3184 -#define wxStyledTextCtrl_GetTwoPhaseDraw 3185 -#define wxStyledTextCtrl_SetTwoPhaseDraw 3186 -#define wxStyledTextCtrl_TargetFromSelection 3187 -#define wxStyledTextCtrl_LinesJoin 3188 -#define wxStyledTextCtrl_LinesSplit 3189 -#define wxStyledTextCtrl_SetFoldMarginColour 3190 -#define wxStyledTextCtrl_SetFoldMarginHiColour 3191 -#define wxStyledTextCtrl_LineDown 3192 -#define wxStyledTextCtrl_LineDownExtend 3193 -#define wxStyledTextCtrl_LineUp 3194 -#define wxStyledTextCtrl_LineUpExtend 3195 -#define wxStyledTextCtrl_CharLeft 3196 -#define wxStyledTextCtrl_CharLeftExtend 3197 -#define wxStyledTextCtrl_CharRight 3198 -#define wxStyledTextCtrl_CharRightExtend 3199 -#define wxStyledTextCtrl_WordLeft 3200 -#define wxStyledTextCtrl_WordLeftExtend 3201 -#define wxStyledTextCtrl_WordRight 3202 -#define wxStyledTextCtrl_WordRightExtend 3203 -#define wxStyledTextCtrl_Home 3204 -#define wxStyledTextCtrl_HomeExtend 3205 -#define wxStyledTextCtrl_LineEnd 3206 -#define wxStyledTextCtrl_LineEndExtend 3207 -#define wxStyledTextCtrl_DocumentStart 3208 -#define wxStyledTextCtrl_DocumentStartExtend 3209 -#define wxStyledTextCtrl_DocumentEnd 3210 -#define wxStyledTextCtrl_DocumentEndExtend 3211 -#define wxStyledTextCtrl_PageUp 3212 -#define wxStyledTextCtrl_PageUpExtend 3213 -#define wxStyledTextCtrl_PageDown 3214 -#define wxStyledTextCtrl_PageDownExtend 3215 -#define wxStyledTextCtrl_EditToggleOvertype 3216 -#define wxStyledTextCtrl_Cancel 3217 -#define wxStyledTextCtrl_DeleteBack 3218 -#define wxStyledTextCtrl_Tab 3219 -#define wxStyledTextCtrl_BackTab 3220 -#define wxStyledTextCtrl_NewLine 3221 -#define wxStyledTextCtrl_FormFeed 3222 -#define wxStyledTextCtrl_VCHome 3223 -#define wxStyledTextCtrl_VCHomeExtend 3224 -#define wxStyledTextCtrl_ZoomIn 3225 -#define wxStyledTextCtrl_ZoomOut 3226 -#define wxStyledTextCtrl_DelWordLeft 3227 -#define wxStyledTextCtrl_DelWordRight 3228 -#define wxStyledTextCtrl_LineCut 3229 -#define wxStyledTextCtrl_LineDelete 3230 -#define wxStyledTextCtrl_LineTranspose 3231 -#define wxStyledTextCtrl_LineDuplicate 3232 -#define wxStyledTextCtrl_LowerCase 3233 -#define wxStyledTextCtrl_UpperCase 3234 -#define wxStyledTextCtrl_LineScrollDown 3235 -#define wxStyledTextCtrl_LineScrollUp 3236 -#define wxStyledTextCtrl_DeleteBackNotLine 3237 -#define wxStyledTextCtrl_HomeDisplay 3238 -#define wxStyledTextCtrl_HomeDisplayExtend 3239 -#define wxStyledTextCtrl_LineEndDisplay 3240 -#define wxStyledTextCtrl_LineEndDisplayExtend 3241 -#define wxStyledTextCtrl_HomeWrapExtend 3242 -#define wxStyledTextCtrl_LineEndWrap 3243 -#define wxStyledTextCtrl_LineEndWrapExtend 3244 -#define wxStyledTextCtrl_VCHomeWrap 3245 -#define wxStyledTextCtrl_VCHomeWrapExtend 3246 -#define wxStyledTextCtrl_LineCopy 3247 -#define wxStyledTextCtrl_MoveCaretInsideView 3248 -#define wxStyledTextCtrl_LineLength 3249 -#define wxStyledTextCtrl_BraceHighlight 3250 -#define wxStyledTextCtrl_BraceBadLight 3251 -#define wxStyledTextCtrl_BraceMatch 3252 -#define wxStyledTextCtrl_GetViewEOL 3253 -#define wxStyledTextCtrl_SetViewEOL 3254 -#define wxStyledTextCtrl_SetModEventMask 3255 -#define wxStyledTextCtrl_GetEdgeColumn 3256 -#define wxStyledTextCtrl_SetEdgeColumn 3257 -#define wxStyledTextCtrl_GetEdgeMode 3258 -#define wxStyledTextCtrl_GetEdgeColour 3259 -#define wxStyledTextCtrl_SetEdgeColour 3260 -#define wxStyledTextCtrl_SearchAnchor 3261 -#define wxStyledTextCtrl_SearchNext 3262 -#define wxStyledTextCtrl_SearchPrev 3263 -#define wxStyledTextCtrl_LinesOnScreen 3264 -#define wxStyledTextCtrl_UsePopUp 3265 -#define wxStyledTextCtrl_SelectionIsRectangle 3266 -#define wxStyledTextCtrl_SetZoom 3267 -#define wxStyledTextCtrl_GetZoom 3268 -#define wxStyledTextCtrl_GetModEventMask 3269 -#define wxStyledTextCtrl_SetSTCFocus 3270 -#define wxStyledTextCtrl_GetSTCFocus 3271 -#define wxStyledTextCtrl_SetStatus 3272 -#define wxStyledTextCtrl_GetStatus 3273 -#define wxStyledTextCtrl_SetMouseDownCaptures 3274 -#define wxStyledTextCtrl_GetMouseDownCaptures 3275 -#define wxStyledTextCtrl_SetSTCCursor 3276 -#define wxStyledTextCtrl_GetSTCCursor 3277 -#define wxStyledTextCtrl_SetControlCharSymbol 3278 -#define wxStyledTextCtrl_GetControlCharSymbol 3279 -#define wxStyledTextCtrl_WordPartLeft 3280 -#define wxStyledTextCtrl_WordPartLeftExtend 3281 -#define wxStyledTextCtrl_WordPartRight 3282 -#define wxStyledTextCtrl_WordPartRightExtend 3283 -#define wxStyledTextCtrl_SetVisiblePolicy 3284 -#define wxStyledTextCtrl_DelLineLeft 3285 -#define wxStyledTextCtrl_DelLineRight 3286 -#define wxStyledTextCtrl_GetXOffset 3287 -#define wxStyledTextCtrl_ChooseCaretX 3288 -#define wxStyledTextCtrl_SetXCaretPolicy 3289 -#define wxStyledTextCtrl_SetYCaretPolicy 3290 -#define wxStyledTextCtrl_GetPrintWrapMode 3291 -#define wxStyledTextCtrl_SetHotspotActiveForeground 3292 -#define wxStyledTextCtrl_SetHotspotActiveBackground 3293 -#define wxStyledTextCtrl_SetHotspotActiveUnderline 3294 -#define wxStyledTextCtrl_SetHotspotSingleLine 3295 -#define wxStyledTextCtrl_ParaDownExtend 3296 -#define wxStyledTextCtrl_ParaUp 3297 -#define wxStyledTextCtrl_ParaUpExtend 3298 -#define wxStyledTextCtrl_PositionBefore 3299 -#define wxStyledTextCtrl_PositionAfter 3300 -#define wxStyledTextCtrl_CopyRange 3301 -#define wxStyledTextCtrl_CopyText 3302 -#define wxStyledTextCtrl_SetSelectionMode 3303 -#define wxStyledTextCtrl_GetSelectionMode 3304 -#define wxStyledTextCtrl_LineDownRectExtend 3305 -#define wxStyledTextCtrl_LineUpRectExtend 3306 -#define wxStyledTextCtrl_CharLeftRectExtend 3307 -#define wxStyledTextCtrl_CharRightRectExtend 3308 -#define wxStyledTextCtrl_HomeRectExtend 3309 -#define wxStyledTextCtrl_VCHomeRectExtend 3310 -#define wxStyledTextCtrl_LineEndRectExtend 3311 -#define wxStyledTextCtrl_PageUpRectExtend 3312 -#define wxStyledTextCtrl_PageDownRectExtend 3313 -#define wxStyledTextCtrl_StutteredPageUp 3314 -#define wxStyledTextCtrl_StutteredPageUpExtend 3315 -#define wxStyledTextCtrl_StutteredPageDown 3316 -#define wxStyledTextCtrl_StutteredPageDownExtend 3317 -#define wxStyledTextCtrl_WordLeftEnd 3318 -#define wxStyledTextCtrl_WordLeftEndExtend 3319 -#define wxStyledTextCtrl_WordRightEnd 3320 -#define wxStyledTextCtrl_WordRightEndExtend 3321 -#define wxStyledTextCtrl_SetWhitespaceChars 3322 -#define wxStyledTextCtrl_SetCharsDefault 3323 -#define wxStyledTextCtrl_AutoCompGetCurrent 3324 -#define wxStyledTextCtrl_Allocate 3325 -#define wxStyledTextCtrl_FindColumn 3326 -#define wxStyledTextCtrl_GetCaretSticky 3327 -#define wxStyledTextCtrl_SetCaretSticky 3328 -#define wxStyledTextCtrl_ToggleCaretSticky 3329 -#define wxStyledTextCtrl_SetPasteConvertEndings 3330 -#define wxStyledTextCtrl_GetPasteConvertEndings 3331 -#define wxStyledTextCtrl_SelectionDuplicate 3332 -#define wxStyledTextCtrl_SetCaretLineBackAlpha 3333 -#define wxStyledTextCtrl_GetCaretLineBackAlpha 3334 -#define wxStyledTextCtrl_StartRecord 3335 -#define wxStyledTextCtrl_StopRecord 3336 -#define wxStyledTextCtrl_SetLexer 3337 -#define wxStyledTextCtrl_GetLexer 3338 -#define wxStyledTextCtrl_Colourise 3339 -#define wxStyledTextCtrl_SetProperty 3340 -#define wxStyledTextCtrl_SetKeyWords 3341 -#define wxStyledTextCtrl_SetLexerLanguage 3342 -#define wxStyledTextCtrl_GetProperty 3343 -#define wxStyledTextCtrl_GetStyleBitsNeeded 3344 -#define wxStyledTextCtrl_GetCurrentLine 3345 -#define wxStyledTextCtrl_StyleSetSpec 3346 -#define wxStyledTextCtrl_StyleSetFont 3347 -#define wxStyledTextCtrl_StyleSetFontAttr 3348 -#define wxStyledTextCtrl_StyleSetCharacterSet 3349 -#define wxStyledTextCtrl_StyleSetFontEncoding 3350 -#define wxStyledTextCtrl_CmdKeyExecute 3351 -#define wxStyledTextCtrl_SetMargins 3352 -#define wxStyledTextCtrl_GetSelection 3353 -#define wxStyledTextCtrl_PointFromPosition 3354 -#define wxStyledTextCtrl_ScrollToLine 3355 -#define wxStyledTextCtrl_ScrollToColumn 3356 -#define wxStyledTextCtrl_SendMsg 3357 -#define wxStyledTextCtrl_SetVScrollBar 3358 -#define wxStyledTextCtrl_SetHScrollBar 3359 -#define wxStyledTextCtrl_GetLastKeydownProcessed 3360 -#define wxStyledTextCtrl_SetLastKeydownProcessed 3361 -#define wxStyledTextCtrl_SaveFile 3362 -#define wxStyledTextCtrl_LoadFile 3363 -#define wxStyledTextCtrl_DoDragOver 3364 -#define wxStyledTextCtrl_DoDropText 3365 -#define wxStyledTextCtrl_GetUseAntiAliasing 3366 -#define wxStyledTextCtrl_AddTextRaw 3367 -#define wxStyledTextCtrl_InsertTextRaw 3368 -#define wxStyledTextCtrl_GetCurLineRaw 3369 -#define wxStyledTextCtrl_GetLineRaw 3370 -#define wxStyledTextCtrl_GetSelectedTextRaw 3371 -#define wxStyledTextCtrl_GetTextRangeRaw 3372 -#define wxStyledTextCtrl_SetTextRaw 3373 -#define wxStyledTextCtrl_GetTextRaw 3374 -#define wxStyledTextCtrl_AppendTextRaw 3375 -#define wxArtProvider_GetBitmap 3376 -#define wxArtProvider_GetIcon 3377 -#define wxTreeEvent_GetKeyCode 3378 -#define wxTreeEvent_GetItem 3379 -#define wxTreeEvent_GetKeyEvent 3380 -#define wxTreeEvent_GetLabel 3381 -#define wxTreeEvent_GetOldItem 3382 -#define wxTreeEvent_GetPoint 3383 -#define wxTreeEvent_IsEditCancelled 3384 -#define wxTreeEvent_SetToolTip 3385 -#define wxNotebookEvent_GetOldSelection 3386 -#define wxNotebookEvent_GetSelection 3387 -#define wxNotebookEvent_SetOldSelection 3388 -#define wxNotebookEvent_SetSelection 3389 -#define wxFileDataObject_new 3390 -#define wxFileDataObject_AddFile 3391 -#define wxFileDataObject_GetFilenames 3392 -#define wxFileDataObject_destroy 3393 -#define wxTextDataObject_new 3394 -#define wxTextDataObject_GetTextLength 3395 -#define wxTextDataObject_GetText 3396 -#define wxTextDataObject_SetText 3397 -#define wxTextDataObject_destroy 3398 -#define wxBitmapDataObject_new_1_1 3399 -#define wxBitmapDataObject_new_1_0 3400 -#define wxBitmapDataObject_GetBitmap 3401 -#define wxBitmapDataObject_SetBitmap 3402 -#define wxBitmapDataObject_destroy 3403 -#define wxClipboard_new 3405 -#define wxClipboard_destruct 3406 -#define wxClipboard_AddData 3407 -#define wxClipboard_Clear 3408 -#define wxClipboard_Close 3409 -#define wxClipboard_Flush 3410 -#define wxClipboard_GetData 3411 -#define wxClipboard_IsOpened 3412 -#define wxClipboard_Open 3413 -#define wxClipboard_SetData 3414 -#define wxClipboard_UsePrimarySelection 3416 -#define wxClipboard_IsSupported 3417 -#define wxClipboard_Get 3418 -#define wxSpinEvent_GetPosition 3419 -#define wxSpinEvent_SetPosition 3420 -#define wxSplitterWindow_new_0 3421 -#define wxSplitterWindow_new_2 3422 -#define wxSplitterWindow_destruct 3423 -#define wxSplitterWindow_Create 3424 -#define wxSplitterWindow_GetMinimumPaneSize 3425 -#define wxSplitterWindow_GetSashGravity 3426 -#define wxSplitterWindow_GetSashPosition 3427 -#define wxSplitterWindow_GetSplitMode 3428 -#define wxSplitterWindow_GetWindow1 3429 -#define wxSplitterWindow_GetWindow2 3430 -#define wxSplitterWindow_Initialize 3431 -#define wxSplitterWindow_IsSplit 3432 -#define wxSplitterWindow_ReplaceWindow 3433 -#define wxSplitterWindow_SetSashGravity 3434 -#define wxSplitterWindow_SetSashPosition 3435 -#define wxSplitterWindow_SetSashSize 3436 -#define wxSplitterWindow_SetMinimumPaneSize 3437 -#define wxSplitterWindow_SetSplitMode 3438 -#define wxSplitterWindow_SplitHorizontally 3439 -#define wxSplitterWindow_SplitVertically 3440 -#define wxSplitterWindow_Unsplit 3441 -#define wxSplitterWindow_UpdateSize 3442 -#define wxSplitterEvent_GetSashPosition 3443 -#define wxSplitterEvent_GetX 3444 -#define wxSplitterEvent_GetY 3445 -#define wxSplitterEvent_GetWindowBeingRemoved 3446 -#define wxSplitterEvent_SetSashPosition 3447 -#define wxHtmlWindow_new_0 3448 -#define wxHtmlWindow_new_2 3449 -#define wxHtmlWindow_AppendToPage 3450 -#define wxHtmlWindow_GetOpenedAnchor 3451 -#define wxHtmlWindow_GetOpenedPage 3452 -#define wxHtmlWindow_GetOpenedPageTitle 3453 -#define wxHtmlWindow_GetRelatedFrame 3454 -#define wxHtmlWindow_HistoryBack 3455 -#define wxHtmlWindow_HistoryCanBack 3456 -#define wxHtmlWindow_HistoryCanForward 3457 -#define wxHtmlWindow_HistoryClear 3458 -#define wxHtmlWindow_HistoryForward 3459 -#define wxHtmlWindow_LoadFile 3460 -#define wxHtmlWindow_LoadPage 3461 -#define wxHtmlWindow_SelectAll 3462 -#define wxHtmlWindow_SelectionToText 3463 -#define wxHtmlWindow_SelectLine 3464 -#define wxHtmlWindow_SelectWord 3465 -#define wxHtmlWindow_SetBorders 3466 -#define wxHtmlWindow_SetFonts 3467 -#define wxHtmlWindow_SetPage 3468 -#define wxHtmlWindow_SetRelatedFrame 3469 -#define wxHtmlWindow_SetRelatedStatusBar 3470 -#define wxHtmlWindow_ToText 3471 -#define wxHtmlWindow_destroy 3472 -#define wxHtmlLinkEvent_GetLinkInfo 3473 -#define wxAuiNotebookEvent_SetSelection 3474 -#define wxAuiNotebookEvent_GetSelection 3475 -#define wxAuiNotebookEvent_SetOldSelection 3476 -#define wxAuiNotebookEvent_GetOldSelection 3477 -#define wxAuiNotebookEvent_SetDragSource 3478 -#define wxAuiNotebookEvent_GetDragSource 3479 -#define wxAuiManagerEvent_SetManager 3480 -#define wxAuiManagerEvent_GetManager 3481 -#define wxAuiManagerEvent_SetPane 3482 -#define wxAuiManagerEvent_GetPane 3483 -#define wxAuiManagerEvent_SetButton 3484 -#define wxAuiManagerEvent_GetButton 3485 -#define wxAuiManagerEvent_SetDC 3486 -#define wxAuiManagerEvent_GetDC 3487 -#define wxAuiManagerEvent_Veto 3488 -#define wxAuiManagerEvent_GetVeto 3489 -#define wxAuiManagerEvent_SetCanVeto 3490 -#define wxAuiManagerEvent_CanVeto 3491 -#define wxLogNull_new 3492 -#define wxLogNull_destroy 3493 +#define wxTreeCtrl_GetFirstChild 2018 +#define wxTreeCtrl_GetNextChild 2019 +#define wxTreeCtrl_GetFirstVisibleItem 2020 +#define wxTreeCtrl_GetImageList 2021 +#define wxTreeCtrl_GetIndent 2022 +#define wxTreeCtrl_GetItemBackgroundColour 2023 +#define wxTreeCtrl_GetItemData 2024 +#define wxTreeCtrl_GetItemFont 2025 +#define wxTreeCtrl_GetItemImage_1 2026 +#define wxTreeCtrl_GetItemImage_2 2027 +#define wxTreeCtrl_GetItemText 2028 +#define wxTreeCtrl_GetItemTextColour 2029 +#define wxTreeCtrl_GetLastChild 2030 +#define wxTreeCtrl_GetNextSibling 2031 +#define wxTreeCtrl_GetNextVisible 2032 +#define wxTreeCtrl_GetItemParent 2033 +#define wxTreeCtrl_GetPrevSibling 2034 +#define wxTreeCtrl_GetPrevVisible 2035 +#define wxTreeCtrl_GetRootItem 2036 +#define wxTreeCtrl_GetSelection 2037 +#define wxTreeCtrl_GetSelections 2038 +#define wxTreeCtrl_GetStateImageList 2039 +#define wxTreeCtrl_HitTest 2040 +#define wxTreeCtrl_InsertItem 2042 +#define wxTreeCtrl_IsBold 2043 +#define wxTreeCtrl_IsExpanded 2044 +#define wxTreeCtrl_IsSelected 2045 +#define wxTreeCtrl_IsVisible 2046 +#define wxTreeCtrl_ItemHasChildren 2047 +#define wxTreeCtrl_PrependItem 2048 +#define wxTreeCtrl_ScrollTo 2049 +#define wxTreeCtrl_SelectItem_1 2050 +#define wxTreeCtrl_SelectItem_2 2051 +#define wxTreeCtrl_SetIndent 2052 +#define wxTreeCtrl_SetImageList 2053 +#define wxTreeCtrl_SetItemBackgroundColour 2054 +#define wxTreeCtrl_SetItemBold 2055 +#define wxTreeCtrl_SetItemData 2056 +#define wxTreeCtrl_SetItemDropHighlight 2057 +#define wxTreeCtrl_SetItemFont 2058 +#define wxTreeCtrl_SetItemHasChildren 2059 +#define wxTreeCtrl_SetItemImage_2 2060 +#define wxTreeCtrl_SetItemImage_3 2061 +#define wxTreeCtrl_SetItemText 2062 +#define wxTreeCtrl_SetItemTextColour 2063 +#define wxTreeCtrl_SetStateImageList 2064 +#define wxTreeCtrl_SetWindowStyle 2065 +#define wxTreeCtrl_SortChildren 2066 +#define wxTreeCtrl_Toggle 2067 +#define wxTreeCtrl_ToggleItemSelection 2068 +#define wxTreeCtrl_Unselect 2069 +#define wxTreeCtrl_UnselectAll 2070 +#define wxTreeCtrl_UnselectItem 2071 +#define wxScrollBar_new_0 2072 +#define wxScrollBar_new_3 2073 +#define wxScrollBar_destruct 2074 +#define wxScrollBar_Create 2075 +#define wxScrollBar_GetRange 2076 +#define wxScrollBar_GetPageSize 2077 +#define wxScrollBar_GetThumbPosition 2078 +#define wxScrollBar_GetThumbSize 2079 +#define wxScrollBar_SetThumbPosition 2080 +#define wxScrollBar_SetScrollbar 2081 +#define wxSpinButton_new_2 2083 +#define wxSpinButton_new_0 2084 +#define wxSpinButton_Create 2085 +#define wxSpinButton_GetMax 2086 +#define wxSpinButton_GetMin 2087 +#define wxSpinButton_GetValue 2088 +#define wxSpinButton_SetRange 2089 +#define wxSpinButton_SetValue 2090 +#define wxSpinButton_destroy 2091 +#define wxSpinCtrl_new_0 2092 +#define wxSpinCtrl_new_2 2093 +#define wxSpinCtrl_Create 2095 +#define wxSpinCtrl_SetValue_1_1 2098 +#define wxSpinCtrl_SetValue_1_0 2099 +#define wxSpinCtrl_GetValue 2101 +#define wxSpinCtrl_SetRange 2103 +#define wxSpinCtrl_SetSelection 2104 +#define wxSpinCtrl_GetMin 2106 +#define wxSpinCtrl_GetMax 2108 +#define wxSpinCtrl_destroy 2109 +#define wxStaticText_new_0 2110 +#define wxStaticText_new_4 2111 +#define wxStaticText_Create 2112 +#define wxStaticText_GetLabel 2113 +#define wxStaticText_SetLabel 2114 +#define wxStaticText_Wrap 2115 +#define wxStaticText_destroy 2116 +#define wxStaticBitmap_new_0 2117 +#define wxStaticBitmap_new_4 2118 +#define wxStaticBitmap_Create 2119 +#define wxStaticBitmap_GetBitmap 2120 +#define wxStaticBitmap_SetBitmap 2121 +#define wxStaticBitmap_destroy 2122 +#define wxRadioBox_new 2123 +#define wxRadioBox_destruct 2125 +#define wxRadioBox_Create 2126 +#define wxRadioBox_Enable_2 2127 +#define wxRadioBox_Enable_1 2128 +#define wxRadioBox_GetSelection 2129 +#define wxRadioBox_GetString 2130 +#define wxRadioBox_SetSelection 2131 +#define wxRadioBox_Show_2 2132 +#define wxRadioBox_Show_1 2133 +#define wxRadioBox_GetColumnCount 2134 +#define wxRadioBox_GetItemHelpText 2135 +#define wxRadioBox_GetItemToolTip 2136 +#define wxRadioBox_GetItemFromPoint 2138 +#define wxRadioBox_GetRowCount 2139 +#define wxRadioBox_IsItemEnabled 2140 +#define wxRadioBox_IsItemShown 2141 +#define wxRadioBox_SetItemHelpText 2142 +#define wxRadioBox_SetItemToolTip 2143 +#define wxRadioButton_new_0 2144 +#define wxRadioButton_new_4 2145 +#define wxRadioButton_Create 2146 +#define wxRadioButton_GetValue 2147 +#define wxRadioButton_SetValue 2148 +#define wxRadioButton_destroy 2149 +#define wxSlider_new_6 2151 +#define wxSlider_new_0 2152 +#define wxSlider_Create 2153 +#define wxSlider_GetLineSize 2154 +#define wxSlider_GetMax 2155 +#define wxSlider_GetMin 2156 +#define wxSlider_GetPageSize 2157 +#define wxSlider_GetThumbLength 2158 +#define wxSlider_GetValue 2159 +#define wxSlider_SetLineSize 2160 +#define wxSlider_SetPageSize 2161 +#define wxSlider_SetRange 2162 +#define wxSlider_SetThumbLength 2163 +#define wxSlider_SetValue 2164 +#define wxSlider_destroy 2165 +#define wxDialog_new_4 2167 +#define wxDialog_new_0 2168 +#define wxDialog_destruct 2170 +#define wxDialog_Create 2171 +#define wxDialog_CreateButtonSizer 2172 +#define wxDialog_CreateStdDialogButtonSizer 2173 +#define wxDialog_EndModal 2174 +#define wxDialog_GetAffirmativeId 2175 +#define wxDialog_GetReturnCode 2176 +#define wxDialog_IsModal 2177 +#define wxDialog_SetAffirmativeId 2178 +#define wxDialog_SetReturnCode 2179 +#define wxDialog_Show 2180 +#define wxDialog_ShowModal 2181 +#define wxColourDialog_new_0 2182 +#define wxColourDialog_new_2 2183 +#define wxColourDialog_destruct 2184 +#define wxColourDialog_Create 2185 +#define wxColourDialog_GetColourData 2186 +#define wxColourData_new_0 2187 +#define wxColourData_new_1 2188 +#define wxColourData_destruct 2189 +#define wxColourData_GetChooseFull 2190 +#define wxColourData_GetColour 2191 +#define wxColourData_GetCustomColour 2193 +#define wxColourData_SetChooseFull 2194 +#define wxColourData_SetColour 2195 +#define wxColourData_SetCustomColour 2196 +#define wxPalette_new_0 2197 +#define wxPalette_new_4 2198 +#define wxPalette_destruct 2200 +#define wxPalette_Create 2201 +#define wxPalette_GetColoursCount 2202 +#define wxPalette_GetPixel 2203 +#define wxPalette_GetRGB 2204 +#define wxPalette_IsOk 2205 +#define wxDirDialog_new 2209 +#define wxDirDialog_destruct 2210 +#define wxDirDialog_GetPath 2211 +#define wxDirDialog_GetMessage 2212 +#define wxDirDialog_SetMessage 2213 +#define wxDirDialog_SetPath 2214 +#define wxFileDialog_new 2218 +#define wxFileDialog_destruct 2219 +#define wxFileDialog_GetDirectory 2220 +#define wxFileDialog_GetFilename 2221 +#define wxFileDialog_GetFilenames 2222 +#define wxFileDialog_GetFilterIndex 2223 +#define wxFileDialog_GetMessage 2224 +#define wxFileDialog_GetPath 2225 +#define wxFileDialog_GetPaths 2226 +#define wxFileDialog_GetWildcard 2227 +#define wxFileDialog_SetDirectory 2228 +#define wxFileDialog_SetFilename 2229 +#define wxFileDialog_SetFilterIndex 2230 +#define wxFileDialog_SetMessage 2231 +#define wxFileDialog_SetPath 2232 +#define wxFileDialog_SetWildcard 2233 +#define wxPickerBase_SetInternalMargin 2234 +#define wxPickerBase_GetInternalMargin 2235 +#define wxPickerBase_SetTextCtrlProportion 2236 +#define wxPickerBase_SetPickerCtrlProportion 2237 +#define wxPickerBase_GetTextCtrlProportion 2238 +#define wxPickerBase_GetPickerCtrlProportion 2239 +#define wxPickerBase_HasTextCtrl 2240 +#define wxPickerBase_GetTextCtrl 2241 +#define wxPickerBase_IsTextCtrlGrowable 2242 +#define wxPickerBase_SetPickerCtrlGrowable 2243 +#define wxPickerBase_SetTextCtrlGrowable 2244 +#define wxPickerBase_IsPickerCtrlGrowable 2245 +#define wxFilePickerCtrl_new_0 2246 +#define wxFilePickerCtrl_new_3 2247 +#define wxFilePickerCtrl_Create 2248 +#define wxFilePickerCtrl_GetPath 2249 +#define wxFilePickerCtrl_SetPath 2250 +#define wxFilePickerCtrl_destroy 2251 +#define wxDirPickerCtrl_new_0 2252 +#define wxDirPickerCtrl_new_3 2253 +#define wxDirPickerCtrl_Create 2254 +#define wxDirPickerCtrl_GetPath 2255 +#define wxDirPickerCtrl_SetPath 2256 +#define wxDirPickerCtrl_destroy 2257 +#define wxColourPickerCtrl_new_0 2258 +#define wxColourPickerCtrl_new_3 2259 +#define wxColourPickerCtrl_Create 2260 +#define wxColourPickerCtrl_GetColour 2261 +#define wxColourPickerCtrl_SetColour_1_1 2262 +#define wxColourPickerCtrl_SetColour_1_0 2263 +#define wxColourPickerCtrl_destroy 2264 +#define wxDatePickerCtrl_new_0 2265 +#define wxDatePickerCtrl_new_3 2266 +#define wxDatePickerCtrl_GetRange 2267 +#define wxDatePickerCtrl_GetValue 2268 +#define wxDatePickerCtrl_SetRange 2269 +#define wxDatePickerCtrl_SetValue 2270 +#define wxDatePickerCtrl_destroy 2271 +#define wxFontPickerCtrl_new_0 2272 +#define wxFontPickerCtrl_new_3 2273 +#define wxFontPickerCtrl_Create 2274 +#define wxFontPickerCtrl_GetSelectedFont 2275 +#define wxFontPickerCtrl_SetSelectedFont 2276 +#define wxFontPickerCtrl_GetMaxPointSize 2277 +#define wxFontPickerCtrl_SetMaxPointSize 2278 +#define wxFontPickerCtrl_destroy 2279 +#define wxFindReplaceDialog_new_0 2282 +#define wxFindReplaceDialog_new_4 2283 +#define wxFindReplaceDialog_destruct 2284 +#define wxFindReplaceDialog_Create 2285 +#define wxFindReplaceDialog_GetData 2286 +#define wxFindReplaceData_new_0 2287 +#define wxFindReplaceData_new_1 2288 +#define wxFindReplaceData_GetFindString 2289 +#define wxFindReplaceData_GetReplaceString 2290 +#define wxFindReplaceData_GetFlags 2291 +#define wxFindReplaceData_SetFlags 2292 +#define wxFindReplaceData_SetFindString 2293 +#define wxFindReplaceData_SetReplaceString 2294 +#define wxFindReplaceData_destroy 2295 +#define wxMultiChoiceDialog_new_0 2296 +#define wxMultiChoiceDialog_new_5 2298 +#define wxMultiChoiceDialog_GetSelections 2299 +#define wxMultiChoiceDialog_SetSelections 2300 +#define wxMultiChoiceDialog_destroy 2301 +#define wxSingleChoiceDialog_new_0 2302 +#define wxSingleChoiceDialog_new_5 2304 +#define wxSingleChoiceDialog_GetSelection 2305 +#define wxSingleChoiceDialog_GetStringSelection 2306 +#define wxSingleChoiceDialog_SetSelection 2307 +#define wxSingleChoiceDialog_destroy 2308 +#define wxTextEntryDialog_new 2309 +#define wxTextEntryDialog_GetValue 2310 +#define wxTextEntryDialog_SetValue 2311 +#define wxTextEntryDialog_destroy 2312 +#define wxPasswordEntryDialog_new 2313 +#define wxPasswordEntryDialog_destroy 2314 +#define wxFontData_new_0 2315 +#define wxFontData_new_1 2316 +#define wxFontData_destruct 2317 +#define wxFontData_EnableEffects 2318 +#define wxFontData_GetAllowSymbols 2319 +#define wxFontData_GetColour 2320 +#define wxFontData_GetChosenFont 2321 +#define wxFontData_GetEnableEffects 2322 +#define wxFontData_GetInitialFont 2323 +#define wxFontData_GetShowHelp 2324 +#define wxFontData_SetAllowSymbols 2325 +#define wxFontData_SetChosenFont 2326 +#define wxFontData_SetColour 2327 +#define wxFontData_SetInitialFont 2328 +#define wxFontData_SetRange 2329 +#define wxFontData_SetShowHelp 2330 +#define wxFontDialog_new_0 2334 +#define wxFontDialog_new_2 2336 +#define wxFontDialog_Create 2338 +#define wxFontDialog_GetFontData 2339 +#define wxFontDialog_destroy 2341 +#define wxProgressDialog_new 2342 +#define wxProgressDialog_destruct 2343 +#define wxProgressDialog_Resume 2344 +#define wxProgressDialog_Update_2 2345 +#define wxProgressDialog_Update_0 2346 +#define wxMessageDialog_new 2347 +#define wxMessageDialog_destruct 2348 +#define wxPageSetupDialog_new 2349 +#define wxPageSetupDialog_destruct 2350 +#define wxPageSetupDialog_GetPageSetupData 2351 +#define wxPageSetupDialog_ShowModal 2352 +#define wxPageSetupDialogData_new_0 2353 +#define wxPageSetupDialogData_new_1_0 2354 +#define wxPageSetupDialogData_new_1_1 2355 +#define wxPageSetupDialogData_destruct 2356 +#define wxPageSetupDialogData_EnableHelp 2357 +#define wxPageSetupDialogData_EnableMargins 2358 +#define wxPageSetupDialogData_EnableOrientation 2359 +#define wxPageSetupDialogData_EnablePaper 2360 +#define wxPageSetupDialogData_EnablePrinter 2361 +#define wxPageSetupDialogData_GetDefaultMinMargins 2362 +#define wxPageSetupDialogData_GetEnableMargins 2363 +#define wxPageSetupDialogData_GetEnableOrientation 2364 +#define wxPageSetupDialogData_GetEnablePaper 2365 +#define wxPageSetupDialogData_GetEnablePrinter 2366 +#define wxPageSetupDialogData_GetEnableHelp 2367 +#define wxPageSetupDialogData_GetDefaultInfo 2368 +#define wxPageSetupDialogData_GetMarginTopLeft 2369 +#define wxPageSetupDialogData_GetMarginBottomRight 2370 +#define wxPageSetupDialogData_GetMinMarginTopLeft 2371 +#define wxPageSetupDialogData_GetMinMarginBottomRight 2372 +#define wxPageSetupDialogData_GetPaperId 2373 +#define wxPageSetupDialogData_GetPaperSize 2374 +#define wxPageSetupDialogData_GetPrintData 2376 +#define wxPageSetupDialogData_IsOk 2377 +#define wxPageSetupDialogData_SetDefaultInfo 2378 +#define wxPageSetupDialogData_SetDefaultMinMargins 2379 +#define wxPageSetupDialogData_SetMarginTopLeft 2380 +#define wxPageSetupDialogData_SetMarginBottomRight 2381 +#define wxPageSetupDialogData_SetMinMarginTopLeft 2382 +#define wxPageSetupDialogData_SetMinMarginBottomRight 2383 +#define wxPageSetupDialogData_SetPaperId 2384 +#define wxPageSetupDialogData_SetPaperSize_1_1 2385 +#define wxPageSetupDialogData_SetPaperSize_1_0 2386 +#define wxPageSetupDialogData_SetPrintData 2387 +#define wxPrintDialog_new_2_0 2388 +#define wxPrintDialog_new_2_1 2389 +#define wxPrintDialog_destruct 2390 +#define wxPrintDialog_GetPrintDialogData 2391 +#define wxPrintDialog_GetPrintDC 2392 +#define wxPrintDialogData_new_0 2393 +#define wxPrintDialogData_new_1_1 2394 +#define wxPrintDialogData_new_1_0 2395 +#define wxPrintDialogData_destruct 2396 +#define wxPrintDialogData_EnableHelp 2397 +#define wxPrintDialogData_EnablePageNumbers 2398 +#define wxPrintDialogData_EnablePrintToFile 2399 +#define wxPrintDialogData_EnableSelection 2400 +#define wxPrintDialogData_GetAllPages 2401 +#define wxPrintDialogData_GetCollate 2402 +#define wxPrintDialogData_GetFromPage 2403 +#define wxPrintDialogData_GetMaxPage 2404 +#define wxPrintDialogData_GetMinPage 2405 +#define wxPrintDialogData_GetNoCopies 2406 +#define wxPrintDialogData_GetPrintData 2407 +#define wxPrintDialogData_GetPrintToFile 2408 +#define wxPrintDialogData_GetSelection 2409 +#define wxPrintDialogData_GetToPage 2410 +#define wxPrintDialogData_IsOk 2411 +#define wxPrintDialogData_SetCollate 2412 +#define wxPrintDialogData_SetFromPage 2413 +#define wxPrintDialogData_SetMaxPage 2414 +#define wxPrintDialogData_SetMinPage 2415 +#define wxPrintDialogData_SetNoCopies 2416 +#define wxPrintDialogData_SetPrintData 2417 +#define wxPrintDialogData_SetPrintToFile 2418 +#define wxPrintDialogData_SetSelection 2419 +#define wxPrintDialogData_SetToPage 2420 +#define wxPrintData_new_0 2421 +#define wxPrintData_new_1 2422 +#define wxPrintData_destruct 2423 +#define wxPrintData_GetCollate 2424 +#define wxPrintData_GetBin 2425 +#define wxPrintData_GetColour 2426 +#define wxPrintData_GetDuplex 2427 +#define wxPrintData_GetNoCopies 2428 +#define wxPrintData_GetOrientation 2429 +#define wxPrintData_GetPaperId 2430 +#define wxPrintData_GetPrinterName 2431 +#define wxPrintData_GetQuality 2432 +#define wxPrintData_IsOk 2433 +#define wxPrintData_SetBin 2434 +#define wxPrintData_SetCollate 2435 +#define wxPrintData_SetColour 2436 +#define wxPrintData_SetDuplex 2437 +#define wxPrintData_SetNoCopies 2438 +#define wxPrintData_SetOrientation 2439 +#define wxPrintData_SetPaperId 2440 +#define wxPrintData_SetPrinterName 2441 +#define wxPrintData_SetQuality 2442 +#define wxPrintPreview_new_2 2445 +#define wxPrintPreview_new_3 2446 +#define wxPrintPreview_destruct 2448 +#define wxPrintPreview_GetCanvas 2449 +#define wxPrintPreview_GetCurrentPage 2450 +#define wxPrintPreview_GetFrame 2451 +#define wxPrintPreview_GetMaxPage 2452 +#define wxPrintPreview_GetMinPage 2453 +#define wxPrintPreview_GetPrintout 2454 +#define wxPrintPreview_GetPrintoutForPrinting 2455 +#define wxPrintPreview_IsOk 2456 +#define wxPrintPreview_PaintPage 2457 +#define wxPrintPreview_Print 2458 +#define wxPrintPreview_RenderPage 2459 +#define wxPrintPreview_SetCanvas 2460 +#define wxPrintPreview_SetCurrentPage 2461 +#define wxPrintPreview_SetFrame 2462 +#define wxPrintPreview_SetPrintout 2463 +#define wxPrintPreview_SetZoom 2464 +#define wxPreviewFrame_new 2465 +#define wxPreviewFrame_destruct 2466 +#define wxPreviewFrame_CreateControlBar 2467 +#define wxPreviewFrame_CreateCanvas 2468 +#define wxPreviewFrame_Initialize 2469 +#define wxPreviewFrame_OnCloseWindow 2470 +#define wxPreviewControlBar_new 2471 +#define wxPreviewControlBar_destruct 2472 +#define wxPreviewControlBar_CreateButtons 2473 +#define wxPreviewControlBar_GetPrintPreview 2474 +#define wxPreviewControlBar_GetZoomControl 2475 +#define wxPreviewControlBar_SetZoomControl 2476 +#define wxPrinter_new 2478 +#define wxPrinter_CreateAbortWindow 2479 +#define wxPrinter_GetAbort 2480 +#define wxPrinter_GetLastError 2481 +#define wxPrinter_GetPrintDialogData 2482 +#define wxPrinter_Print 2483 +#define wxPrinter_PrintDialog 2484 +#define wxPrinter_ReportError 2485 +#define wxPrinter_Setup 2486 +#define wxPrinter_destroy 2487 +#define wxXmlResource_new_1 2488 +#define wxXmlResource_new_2 2489 +#define wxXmlResource_destruct 2490 +#define wxXmlResource_AttachUnknownControl 2491 +#define wxXmlResource_ClearHandlers 2492 +#define wxXmlResource_CompareVersion 2493 +#define wxXmlResource_Get 2494 +#define wxXmlResource_GetFlags 2495 +#define wxXmlResource_GetVersion 2496 +#define wxXmlResource_GetXRCID 2497 +#define wxXmlResource_InitAllHandlers 2498 +#define wxXmlResource_Load 2499 +#define wxXmlResource_LoadBitmap 2500 +#define wxXmlResource_LoadDialog_2 2501 +#define wxXmlResource_LoadDialog_3 2502 +#define wxXmlResource_LoadFrame_2 2503 +#define wxXmlResource_LoadFrame_3 2504 +#define wxXmlResource_LoadIcon 2505 +#define wxXmlResource_LoadMenu 2506 +#define wxXmlResource_LoadMenuBar_2 2507 +#define wxXmlResource_LoadMenuBar_1 2508 +#define wxXmlResource_LoadPanel_2 2509 +#define wxXmlResource_LoadPanel_3 2510 +#define wxXmlResource_LoadToolBar 2511 +#define wxXmlResource_Set 2512 +#define wxXmlResource_SetFlags 2513 +#define wxXmlResource_Unload 2514 +#define wxXmlResource_xrcctrl 2515 +#define wxHtmlEasyPrinting_new 2516 +#define wxHtmlEasyPrinting_destruct 2517 +#define wxHtmlEasyPrinting_GetPrintData 2518 +#define wxHtmlEasyPrinting_GetPageSetupData 2519 +#define wxHtmlEasyPrinting_PreviewFile 2520 +#define wxHtmlEasyPrinting_PreviewText 2521 +#define wxHtmlEasyPrinting_PrintFile 2522 +#define wxHtmlEasyPrinting_PrintText 2523 +#define wxHtmlEasyPrinting_PageSetup 2524 +#define wxHtmlEasyPrinting_SetFonts 2525 +#define wxHtmlEasyPrinting_SetHeader 2526 +#define wxHtmlEasyPrinting_SetFooter 2527 +#define wxGLCanvas_new_2 2529 +#define wxGLCanvas_new_3_1 2530 +#define wxGLCanvas_new_3_0 2531 +#define wxGLCanvas_GetContext 2532 +#define wxGLCanvas_SetCurrent 2534 +#define wxGLCanvas_SwapBuffers 2535 +#define wxGLCanvas_destroy 2536 +#define wxAuiManager_new 2537 +#define wxAuiManager_destruct 2538 +#define wxAuiManager_AddPane_2_1 2539 +#define wxAuiManager_AddPane_3 2540 +#define wxAuiManager_AddPane_2_0 2541 +#define wxAuiManager_DetachPane 2542 +#define wxAuiManager_GetAllPanes 2543 +#define wxAuiManager_GetArtProvider 2544 +#define wxAuiManager_GetDockSizeConstraint 2545 +#define wxAuiManager_GetFlags 2546 +#define wxAuiManager_GetManagedWindow 2547 +#define wxAuiManager_GetManager 2548 +#define wxAuiManager_GetPane_1_1 2549 +#define wxAuiManager_GetPane_1_0 2550 +#define wxAuiManager_HideHint 2551 +#define wxAuiManager_InsertPane 2552 +#define wxAuiManager_LoadPaneInfo 2553 +#define wxAuiManager_LoadPerspective 2554 +#define wxAuiManager_SavePaneInfo 2555 +#define wxAuiManager_SavePerspective 2556 +#define wxAuiManager_SetArtProvider 2557 +#define wxAuiManager_SetDockSizeConstraint 2558 +#define wxAuiManager_SetFlags 2559 +#define wxAuiManager_SetManagedWindow 2560 +#define wxAuiManager_ShowHint 2561 +#define wxAuiManager_UnInit 2562 +#define wxAuiManager_Update 2563 +#define wxAuiPaneInfo_new_0 2564 +#define wxAuiPaneInfo_new_1 2565 +#define wxAuiPaneInfo_destruct 2566 +#define wxAuiPaneInfo_BestSize_1 2567 +#define wxAuiPaneInfo_BestSize_2 2568 +#define wxAuiPaneInfo_Bottom 2569 +#define wxAuiPaneInfo_BottomDockable 2570 +#define wxAuiPaneInfo_Caption 2571 +#define wxAuiPaneInfo_CaptionVisible 2572 +#define wxAuiPaneInfo_Centre 2573 +#define wxAuiPaneInfo_CentrePane 2574 +#define wxAuiPaneInfo_CloseButton 2575 +#define wxAuiPaneInfo_DefaultPane 2576 +#define wxAuiPaneInfo_DestroyOnClose 2577 +#define wxAuiPaneInfo_Direction 2578 +#define wxAuiPaneInfo_Dock 2579 +#define wxAuiPaneInfo_Dockable 2580 +#define wxAuiPaneInfo_Fixed 2581 +#define wxAuiPaneInfo_Float 2582 +#define wxAuiPaneInfo_Floatable 2583 +#define wxAuiPaneInfo_FloatingPosition_1 2584 +#define wxAuiPaneInfo_FloatingPosition_2 2585 +#define wxAuiPaneInfo_FloatingSize_1 2586 +#define wxAuiPaneInfo_FloatingSize_2 2587 +#define wxAuiPaneInfo_Gripper 2588 +#define wxAuiPaneInfo_GripperTop 2589 +#define wxAuiPaneInfo_HasBorder 2590 +#define wxAuiPaneInfo_HasCaption 2591 +#define wxAuiPaneInfo_HasCloseButton 2592 +#define wxAuiPaneInfo_HasFlag 2593 +#define wxAuiPaneInfo_HasGripper 2594 +#define wxAuiPaneInfo_HasGripperTop 2595 +#define wxAuiPaneInfo_HasMaximizeButton 2596 +#define wxAuiPaneInfo_HasMinimizeButton 2597 +#define wxAuiPaneInfo_HasPinButton 2598 +#define wxAuiPaneInfo_Hide 2599 +#define wxAuiPaneInfo_IsBottomDockable 2600 +#define wxAuiPaneInfo_IsDocked 2601 +#define wxAuiPaneInfo_IsFixed 2602 +#define wxAuiPaneInfo_IsFloatable 2603 +#define wxAuiPaneInfo_IsFloating 2604 +#define wxAuiPaneInfo_IsLeftDockable 2605 +#define wxAuiPaneInfo_IsMovable 2606 +#define wxAuiPaneInfo_IsOk 2607 +#define wxAuiPaneInfo_IsResizable 2608 +#define wxAuiPaneInfo_IsRightDockable 2609 +#define wxAuiPaneInfo_IsShown 2610 +#define wxAuiPaneInfo_IsToolbar 2611 +#define wxAuiPaneInfo_IsTopDockable 2612 +#define wxAuiPaneInfo_Layer 2613 +#define wxAuiPaneInfo_Left 2614 +#define wxAuiPaneInfo_LeftDockable 2615 +#define wxAuiPaneInfo_MaxSize_1 2616 +#define wxAuiPaneInfo_MaxSize_2 2617 +#define wxAuiPaneInfo_MaximizeButton 2618 +#define wxAuiPaneInfo_MinSize_1 2619 +#define wxAuiPaneInfo_MinSize_2 2620 +#define wxAuiPaneInfo_MinimizeButton 2621 +#define wxAuiPaneInfo_Movable 2622 +#define wxAuiPaneInfo_Name 2623 +#define wxAuiPaneInfo_PaneBorder 2624 +#define wxAuiPaneInfo_PinButton 2625 +#define wxAuiPaneInfo_Position 2626 +#define wxAuiPaneInfo_Resizable 2627 +#define wxAuiPaneInfo_Right 2628 +#define wxAuiPaneInfo_RightDockable 2629 +#define wxAuiPaneInfo_Row 2630 +#define wxAuiPaneInfo_SafeSet 2631 +#define wxAuiPaneInfo_SetFlag 2632 +#define wxAuiPaneInfo_Show 2633 +#define wxAuiPaneInfo_ToolbarPane 2634 +#define wxAuiPaneInfo_Top 2635 +#define wxAuiPaneInfo_TopDockable 2636 +#define wxAuiPaneInfo_Window 2637 +#define wxAuiNotebook_new_0 2638 +#define wxAuiNotebook_new_2 2639 +#define wxAuiNotebook_AddPage 2640 +#define wxAuiNotebook_Create 2641 +#define wxAuiNotebook_DeletePage 2642 +#define wxAuiNotebook_GetArtProvider 2643 +#define wxAuiNotebook_GetPage 2644 +#define wxAuiNotebook_GetPageBitmap 2645 +#define wxAuiNotebook_GetPageCount 2646 +#define wxAuiNotebook_GetPageIndex 2647 +#define wxAuiNotebook_GetPageText 2648 +#define wxAuiNotebook_GetSelection 2649 +#define wxAuiNotebook_InsertPage 2650 +#define wxAuiNotebook_RemovePage 2651 +#define wxAuiNotebook_SetArtProvider 2652 +#define wxAuiNotebook_SetFont 2653 +#define wxAuiNotebook_SetPageBitmap 2654 +#define wxAuiNotebook_SetPageText 2655 +#define wxAuiNotebook_SetSelection 2656 +#define wxAuiNotebook_SetTabCtrlHeight 2657 +#define wxAuiNotebook_SetUniformBitmapSize 2658 +#define wxAuiNotebook_destroy 2659 +#define wxMDIParentFrame_new_0 2660 +#define wxMDIParentFrame_new_4 2661 +#define wxMDIParentFrame_destruct 2662 +#define wxMDIParentFrame_ActivateNext 2663 +#define wxMDIParentFrame_ActivatePrevious 2664 +#define wxMDIParentFrame_ArrangeIcons 2665 +#define wxMDIParentFrame_Cascade 2666 +#define wxMDIParentFrame_Create 2667 +#define wxMDIParentFrame_GetActiveChild 2668 +#define wxMDIParentFrame_GetClientWindow 2669 +#define wxMDIParentFrame_Tile 2670 +#define wxMDIChildFrame_new_0 2671 +#define wxMDIChildFrame_new_4 2672 +#define wxMDIChildFrame_destruct 2673 +#define wxMDIChildFrame_Activate 2674 +#define wxMDIChildFrame_Create 2675 +#define wxMDIChildFrame_Maximize 2676 +#define wxMDIChildFrame_Restore 2677 +#define wxMDIClientWindow_new_0 2678 +#define wxMDIClientWindow_new_2 2679 +#define wxMDIClientWindow_destruct 2680 +#define wxMDIClientWindow_CreateClient 2681 +#define wxLayoutAlgorithm_new 2682 +#define wxLayoutAlgorithm_LayoutFrame 2683 +#define wxLayoutAlgorithm_LayoutMDIFrame 2684 +#define wxLayoutAlgorithm_LayoutWindow 2685 +#define wxLayoutAlgorithm_destroy 2686 +#define wxEvent_GetId 2687 +#define wxEvent_GetSkipped 2688 +#define wxEvent_GetTimestamp 2689 +#define wxEvent_IsCommandEvent 2690 +#define wxEvent_ResumePropagation 2691 +#define wxEvent_ShouldPropagate 2692 +#define wxEvent_Skip 2693 +#define wxEvent_StopPropagation 2694 +#define wxCommandEvent_getClientData 2695 +#define wxCommandEvent_GetExtraLong 2696 +#define wxCommandEvent_GetInt 2697 +#define wxCommandEvent_GetSelection 2698 +#define wxCommandEvent_GetString 2699 +#define wxCommandEvent_IsChecked 2700 +#define wxCommandEvent_IsSelection 2701 +#define wxCommandEvent_SetInt 2702 +#define wxCommandEvent_SetString 2703 +#define wxScrollEvent_GetOrientation 2704 +#define wxScrollEvent_GetPosition 2705 +#define wxScrollWinEvent_GetOrientation 2706 +#define wxScrollWinEvent_GetPosition 2707 +#define wxMouseEvent_AltDown 2708 +#define wxMouseEvent_Button 2709 +#define wxMouseEvent_ButtonDClick 2710 +#define wxMouseEvent_ButtonDown 2711 +#define wxMouseEvent_ButtonUp 2712 +#define wxMouseEvent_CmdDown 2713 +#define wxMouseEvent_ControlDown 2714 +#define wxMouseEvent_Dragging 2715 +#define wxMouseEvent_Entering 2716 +#define wxMouseEvent_GetButton 2717 +#define wxMouseEvent_GetPosition 2720 +#define wxMouseEvent_GetLogicalPosition 2721 +#define wxMouseEvent_GetLinesPerAction 2722 +#define wxMouseEvent_GetWheelRotation 2723 +#define wxMouseEvent_GetWheelDelta 2724 +#define wxMouseEvent_GetX 2725 +#define wxMouseEvent_GetY 2726 +#define wxMouseEvent_IsButton 2727 +#define wxMouseEvent_IsPageScroll 2728 +#define wxMouseEvent_Leaving 2729 +#define wxMouseEvent_LeftDClick 2730 +#define wxMouseEvent_LeftDown 2731 +#define wxMouseEvent_LeftIsDown 2732 +#define wxMouseEvent_LeftUp 2733 +#define wxMouseEvent_MetaDown 2734 +#define wxMouseEvent_MiddleDClick 2735 +#define wxMouseEvent_MiddleDown 2736 +#define wxMouseEvent_MiddleIsDown 2737 +#define wxMouseEvent_MiddleUp 2738 +#define wxMouseEvent_Moving 2739 +#define wxMouseEvent_RightDClick 2740 +#define wxMouseEvent_RightDown 2741 +#define wxMouseEvent_RightIsDown 2742 +#define wxMouseEvent_RightUp 2743 +#define wxMouseEvent_ShiftDown 2744 +#define wxSetCursorEvent_GetCursor 2745 +#define wxSetCursorEvent_GetX 2746 +#define wxSetCursorEvent_GetY 2747 +#define wxSetCursorEvent_HasCursor 2748 +#define wxSetCursorEvent_SetCursor 2749 +#define wxKeyEvent_AltDown 2750 +#define wxKeyEvent_CmdDown 2751 +#define wxKeyEvent_ControlDown 2752 +#define wxKeyEvent_GetKeyCode 2753 +#define wxKeyEvent_GetModifiers 2754 +#define wxKeyEvent_GetPosition 2757 +#define wxKeyEvent_GetRawKeyCode 2758 +#define wxKeyEvent_GetRawKeyFlags 2759 +#define wxKeyEvent_GetUnicodeKey 2760 +#define wxKeyEvent_GetX 2761 +#define wxKeyEvent_GetY 2762 +#define wxKeyEvent_HasModifiers 2763 +#define wxKeyEvent_MetaDown 2764 +#define wxKeyEvent_ShiftDown 2765 +#define wxSizeEvent_GetSize 2766 +#define wxMoveEvent_GetPosition 2767 +#define wxEraseEvent_GetDC 2768 +#define wxFocusEvent_GetWindow 2769 +#define wxChildFocusEvent_GetWindow 2770 +#define wxMenuEvent_GetMenu 2771 +#define wxMenuEvent_GetMenuId 2772 +#define wxMenuEvent_IsPopup 2773 +#define wxCloseEvent_CanVeto 2774 +#define wxCloseEvent_GetLoggingOff 2775 +#define wxCloseEvent_SetCanVeto 2776 +#define wxCloseEvent_SetLoggingOff 2777 +#define wxCloseEvent_Veto 2778 +#define wxShowEvent_SetShow 2779 +#define wxShowEvent_GetShow 2780 +#define wxIconizeEvent_Iconized 2781 +#define wxJoystickEvent_ButtonDown 2782 +#define wxJoystickEvent_ButtonIsDown 2783 +#define wxJoystickEvent_ButtonUp 2784 +#define wxJoystickEvent_GetButtonChange 2785 +#define wxJoystickEvent_GetButtonState 2786 +#define wxJoystickEvent_GetJoystick 2787 +#define wxJoystickEvent_GetPosition 2788 +#define wxJoystickEvent_GetZPosition 2789 +#define wxJoystickEvent_IsButton 2790 +#define wxJoystickEvent_IsMove 2791 +#define wxJoystickEvent_IsZMove 2792 +#define wxUpdateUIEvent_CanUpdate 2793 +#define wxUpdateUIEvent_Check 2794 +#define wxUpdateUIEvent_Enable 2795 +#define wxUpdateUIEvent_Show 2796 +#define wxUpdateUIEvent_GetChecked 2797 +#define wxUpdateUIEvent_GetEnabled 2798 +#define wxUpdateUIEvent_GetShown 2799 +#define wxUpdateUIEvent_GetSetChecked 2800 +#define wxUpdateUIEvent_GetSetEnabled 2801 +#define wxUpdateUIEvent_GetSetShown 2802 +#define wxUpdateUIEvent_GetSetText 2803 +#define wxUpdateUIEvent_GetText 2804 +#define wxUpdateUIEvent_GetMode 2805 +#define wxUpdateUIEvent_GetUpdateInterval 2806 +#define wxUpdateUIEvent_ResetUpdateTime 2807 +#define wxUpdateUIEvent_SetMode 2808 +#define wxUpdateUIEvent_SetText 2809 +#define wxUpdateUIEvent_SetUpdateInterval 2810 +#define wxMouseCaptureChangedEvent_GetCapturedWindow 2811 +#define wxPaletteChangedEvent_SetChangedWindow 2812 +#define wxPaletteChangedEvent_GetChangedWindow 2813 +#define wxQueryNewPaletteEvent_SetPaletteRealized 2814 +#define wxQueryNewPaletteEvent_GetPaletteRealized 2815 +#define wxNavigationKeyEvent_GetDirection 2816 +#define wxNavigationKeyEvent_SetDirection 2817 +#define wxNavigationKeyEvent_IsWindowChange 2818 +#define wxNavigationKeyEvent_SetWindowChange 2819 +#define wxNavigationKeyEvent_IsFromTab 2820 +#define wxNavigationKeyEvent_SetFromTab 2821 +#define wxNavigationKeyEvent_GetCurrentFocus 2822 +#define wxNavigationKeyEvent_SetCurrentFocus 2823 +#define wxHelpEvent_GetOrigin 2824 +#define wxHelpEvent_GetPosition 2825 +#define wxHelpEvent_SetOrigin 2826 +#define wxHelpEvent_SetPosition 2827 +#define wxContextMenuEvent_GetPosition 2828 +#define wxContextMenuEvent_SetPosition 2829 +#define wxIdleEvent_CanSend 2830 +#define wxIdleEvent_GetMode 2831 +#define wxIdleEvent_RequestMore 2832 +#define wxIdleEvent_MoreRequested 2833 +#define wxIdleEvent_SetMode 2834 +#define wxGridEvent_AltDown 2835 +#define wxGridEvent_ControlDown 2836 +#define wxGridEvent_GetCol 2837 +#define wxGridEvent_GetPosition 2838 +#define wxGridEvent_GetRow 2839 +#define wxGridEvent_MetaDown 2840 +#define wxGridEvent_Selecting 2841 +#define wxGridEvent_ShiftDown 2842 +#define wxNotifyEvent_Allow 2843 +#define wxNotifyEvent_IsAllowed 2844 +#define wxNotifyEvent_Veto 2845 +#define wxSashEvent_GetEdge 2846 +#define wxSashEvent_GetDragRect 2847 +#define wxSashEvent_GetDragStatus 2848 +#define wxListEvent_GetCacheFrom 2849 +#define wxListEvent_GetCacheTo 2850 +#define wxListEvent_GetKeyCode 2851 +#define wxListEvent_GetIndex 2852 +#define wxListEvent_GetColumn 2853 +#define wxListEvent_GetPoint 2854 +#define wxListEvent_GetLabel 2855 +#define wxListEvent_GetText 2856 +#define wxListEvent_GetImage 2857 +#define wxListEvent_GetData 2858 +#define wxListEvent_GetMask 2859 +#define wxListEvent_GetItem 2860 +#define wxListEvent_IsEditCancelled 2861 +#define wxDateEvent_GetDate 2862 +#define wxCalendarEvent_GetWeekDay 2863 +#define wxFileDirPickerEvent_GetPath 2864 +#define wxColourPickerEvent_GetColour 2865 +#define wxFontPickerEvent_GetFont 2866 +#define wxStyledTextEvent_GetPosition 2867 +#define wxStyledTextEvent_GetKey 2868 +#define wxStyledTextEvent_GetModifiers 2869 +#define wxStyledTextEvent_GetModificationType 2870 +#define wxStyledTextEvent_GetText 2871 +#define wxStyledTextEvent_GetLength 2872 +#define wxStyledTextEvent_GetLinesAdded 2873 +#define wxStyledTextEvent_GetLine 2874 +#define wxStyledTextEvent_GetFoldLevelNow 2875 +#define wxStyledTextEvent_GetFoldLevelPrev 2876 +#define wxStyledTextEvent_GetMargin 2877 +#define wxStyledTextEvent_GetMessage 2878 +#define wxStyledTextEvent_GetWParam 2879 +#define wxStyledTextEvent_GetLParam 2880 +#define wxStyledTextEvent_GetListType 2881 +#define wxStyledTextEvent_GetX 2882 +#define wxStyledTextEvent_GetY 2883 +#define wxStyledTextEvent_GetDragText 2884 +#define wxStyledTextEvent_GetDragAllowMove 2885 +#define wxStyledTextEvent_GetDragResult 2886 +#define wxStyledTextEvent_GetShift 2887 +#define wxStyledTextEvent_GetControl 2888 +#define wxStyledTextEvent_GetAlt 2889 +#define utils_wxGetKeyState 2890 +#define utils_wxGetMousePosition 2891 +#define utils_wxGetMouseState 2892 +#define utils_wxSetDetectableAutoRepeat 2893 +#define utils_wxBell 2894 +#define utils_wxFindMenuItemId 2895 +#define utils_wxGenericFindWindowAtPoint 2896 +#define utils_wxFindWindowAtPoint 2897 +#define utils_wxBeginBusyCursor 2898 +#define utils_wxEndBusyCursor 2899 +#define utils_wxIsBusy 2900 +#define utils_wxShutdown 2901 +#define utils_wxShell 2902 +#define utils_wxLaunchDefaultBrowser 2903 +#define utils_wxGetEmailAddress 2904 +#define utils_wxGetUserId 2905 +#define utils_wxGetHomeDir 2906 +#define utils_wxNewId 2907 +#define utils_wxRegisterId 2908 +#define utils_wxGetCurrentId 2909 +#define utils_wxGetOsDescription 2910 +#define utils_wxIsPlatformLittleEndian 2911 +#define utils_wxIsPlatform64Bit 2912 +#define wxPrintout_new 2913 +#define wxPrintout_destruct 2914 +#define wxPrintout_GetDC 2915 +#define wxPrintout_GetPageSizeMM 2916 +#define wxPrintout_GetPageSizePixels 2917 +#define wxPrintout_GetPaperRectPixels 2918 +#define wxPrintout_GetPPIPrinter 2919 +#define wxPrintout_GetPPIScreen 2920 +#define wxPrintout_GetTitle 2921 +#define wxPrintout_IsPreview 2922 +#define wxPrintout_FitThisSizeToPaper 2923 +#define wxPrintout_FitThisSizeToPage 2924 +#define wxPrintout_FitThisSizeToPageMargins 2925 +#define wxPrintout_MapScreenSizeToPaper 2926 +#define wxPrintout_MapScreenSizeToPage 2927 +#define wxPrintout_MapScreenSizeToPageMargins 2928 +#define wxPrintout_MapScreenSizeToDevice 2929 +#define wxPrintout_GetLogicalPaperRect 2930 +#define wxPrintout_GetLogicalPageRect 2931 +#define wxPrintout_GetLogicalPageMarginsRect 2932 +#define wxPrintout_SetLogicalOrigin 2933 +#define wxPrintout_OffsetLogicalOrigin 2934 +#define wxStyledTextCtrl_new_2 2935 +#define wxStyledTextCtrl_new_0 2936 +#define wxStyledTextCtrl_destruct 2937 +#define wxStyledTextCtrl_Create 2938 +#define wxStyledTextCtrl_AddText 2939 +#define wxStyledTextCtrl_AddStyledText 2940 +#define wxStyledTextCtrl_InsertText 2941 +#define wxStyledTextCtrl_ClearAll 2942 +#define wxStyledTextCtrl_ClearDocumentStyle 2943 +#define wxStyledTextCtrl_GetLength 2944 +#define wxStyledTextCtrl_GetCharAt 2945 +#define wxStyledTextCtrl_GetCurrentPos 2946 +#define wxStyledTextCtrl_GetAnchor 2947 +#define wxStyledTextCtrl_GetStyleAt 2948 +#define wxStyledTextCtrl_Redo 2949 +#define wxStyledTextCtrl_SetUndoCollection 2950 +#define wxStyledTextCtrl_SelectAll 2951 +#define wxStyledTextCtrl_SetSavePoint 2952 +#define wxStyledTextCtrl_GetStyledText 2953 +#define wxStyledTextCtrl_CanRedo 2954 +#define wxStyledTextCtrl_MarkerLineFromHandle 2955 +#define wxStyledTextCtrl_MarkerDeleteHandle 2956 +#define wxStyledTextCtrl_GetUndoCollection 2957 +#define wxStyledTextCtrl_GetViewWhiteSpace 2958 +#define wxStyledTextCtrl_SetViewWhiteSpace 2959 +#define wxStyledTextCtrl_PositionFromPoint 2960 +#define wxStyledTextCtrl_PositionFromPointClose 2961 +#define wxStyledTextCtrl_GotoLine 2962 +#define wxStyledTextCtrl_GotoPos 2963 +#define wxStyledTextCtrl_SetAnchor 2964 +#define wxStyledTextCtrl_GetCurLine 2965 +#define wxStyledTextCtrl_GetEndStyled 2966 +#define wxStyledTextCtrl_ConvertEOLs 2967 +#define wxStyledTextCtrl_GetEOLMode 2968 +#define wxStyledTextCtrl_SetEOLMode 2969 +#define wxStyledTextCtrl_StartStyling 2970 +#define wxStyledTextCtrl_SetStyling 2971 +#define wxStyledTextCtrl_GetBufferedDraw 2972 +#define wxStyledTextCtrl_SetBufferedDraw 2973 +#define wxStyledTextCtrl_SetTabWidth 2974 +#define wxStyledTextCtrl_GetTabWidth 2975 +#define wxStyledTextCtrl_SetCodePage 2976 +#define wxStyledTextCtrl_MarkerDefine 2977 +#define wxStyledTextCtrl_MarkerSetForeground 2978 +#define wxStyledTextCtrl_MarkerSetBackground 2979 +#define wxStyledTextCtrl_MarkerAdd 2980 +#define wxStyledTextCtrl_MarkerDelete 2981 +#define wxStyledTextCtrl_MarkerDeleteAll 2982 +#define wxStyledTextCtrl_MarkerGet 2983 +#define wxStyledTextCtrl_MarkerNext 2984 +#define wxStyledTextCtrl_MarkerPrevious 2985 +#define wxStyledTextCtrl_MarkerDefineBitmap 2986 +#define wxStyledTextCtrl_MarkerAddSet 2987 +#define wxStyledTextCtrl_MarkerSetAlpha 2988 +#define wxStyledTextCtrl_SetMarginType 2989 +#define wxStyledTextCtrl_GetMarginType 2990 +#define wxStyledTextCtrl_SetMarginWidth 2991 +#define wxStyledTextCtrl_GetMarginWidth 2992 +#define wxStyledTextCtrl_SetMarginMask 2993 +#define wxStyledTextCtrl_GetMarginMask 2994 +#define wxStyledTextCtrl_SetMarginSensitive 2995 +#define wxStyledTextCtrl_GetMarginSensitive 2996 +#define wxStyledTextCtrl_StyleClearAll 2997 +#define wxStyledTextCtrl_StyleSetForeground 2998 +#define wxStyledTextCtrl_StyleSetBackground 2999 +#define wxStyledTextCtrl_StyleSetBold 3000 +#define wxStyledTextCtrl_StyleSetItalic 3001 +#define wxStyledTextCtrl_StyleSetSize 3002 +#define wxStyledTextCtrl_StyleSetFaceName 3003 +#define wxStyledTextCtrl_StyleSetEOLFilled 3004 +#define wxStyledTextCtrl_StyleResetDefault 3005 +#define wxStyledTextCtrl_StyleSetUnderline 3006 +#define wxStyledTextCtrl_StyleSetCase 3007 +#define wxStyledTextCtrl_StyleSetHotSpot 3008 +#define wxStyledTextCtrl_SetSelForeground 3009 +#define wxStyledTextCtrl_SetSelBackground 3010 +#define wxStyledTextCtrl_GetSelAlpha 3011 +#define wxStyledTextCtrl_SetSelAlpha 3012 +#define wxStyledTextCtrl_SetCaretForeground 3013 +#define wxStyledTextCtrl_CmdKeyAssign 3014 +#define wxStyledTextCtrl_CmdKeyClear 3015 +#define wxStyledTextCtrl_CmdKeyClearAll 3016 +#define wxStyledTextCtrl_SetStyleBytes 3017 +#define wxStyledTextCtrl_StyleSetVisible 3018 +#define wxStyledTextCtrl_GetCaretPeriod 3019 +#define wxStyledTextCtrl_SetCaretPeriod 3020 +#define wxStyledTextCtrl_SetWordChars 3021 +#define wxStyledTextCtrl_BeginUndoAction 3022 +#define wxStyledTextCtrl_EndUndoAction 3023 +#define wxStyledTextCtrl_IndicatorSetStyle 3024 +#define wxStyledTextCtrl_IndicatorGetStyle 3025 +#define wxStyledTextCtrl_IndicatorSetForeground 3026 +#define wxStyledTextCtrl_IndicatorGetForeground 3027 +#define wxStyledTextCtrl_SetWhitespaceForeground 3028 +#define wxStyledTextCtrl_SetWhitespaceBackground 3029 +#define wxStyledTextCtrl_GetStyleBits 3030 +#define wxStyledTextCtrl_SetLineState 3031 +#define wxStyledTextCtrl_GetLineState 3032 +#define wxStyledTextCtrl_GetMaxLineState 3033 +#define wxStyledTextCtrl_GetCaretLineVisible 3034 +#define wxStyledTextCtrl_SetCaretLineVisible 3035 +#define wxStyledTextCtrl_GetCaretLineBackground 3036 +#define wxStyledTextCtrl_SetCaretLineBackground 3037 +#define wxStyledTextCtrl_AutoCompShow 3038 +#define wxStyledTextCtrl_AutoCompCancel 3039 +#define wxStyledTextCtrl_AutoCompActive 3040 +#define wxStyledTextCtrl_AutoCompPosStart 3041 +#define wxStyledTextCtrl_AutoCompComplete 3042 +#define wxStyledTextCtrl_AutoCompStops 3043 +#define wxStyledTextCtrl_AutoCompSetSeparator 3044 +#define wxStyledTextCtrl_AutoCompGetSeparator 3045 +#define wxStyledTextCtrl_AutoCompSelect 3046 +#define wxStyledTextCtrl_AutoCompSetCancelAtStart 3047 +#define wxStyledTextCtrl_AutoCompGetCancelAtStart 3048 +#define wxStyledTextCtrl_AutoCompSetFillUps 3049 +#define wxStyledTextCtrl_AutoCompSetChooseSingle 3050 +#define wxStyledTextCtrl_AutoCompGetChooseSingle 3051 +#define wxStyledTextCtrl_AutoCompSetIgnoreCase 3052 +#define wxStyledTextCtrl_AutoCompGetIgnoreCase 3053 +#define wxStyledTextCtrl_UserListShow 3054 +#define wxStyledTextCtrl_AutoCompSetAutoHide 3055 +#define wxStyledTextCtrl_AutoCompGetAutoHide 3056 +#define wxStyledTextCtrl_AutoCompSetDropRestOfWord 3057 +#define wxStyledTextCtrl_AutoCompGetDropRestOfWord 3058 +#define wxStyledTextCtrl_RegisterImage 3059 +#define wxStyledTextCtrl_ClearRegisteredImages 3060 +#define wxStyledTextCtrl_AutoCompGetTypeSeparator 3061 +#define wxStyledTextCtrl_AutoCompSetTypeSeparator 3062 +#define wxStyledTextCtrl_AutoCompSetMaxWidth 3063 +#define wxStyledTextCtrl_AutoCompGetMaxWidth 3064 +#define wxStyledTextCtrl_AutoCompSetMaxHeight 3065 +#define wxStyledTextCtrl_AutoCompGetMaxHeight 3066 +#define wxStyledTextCtrl_SetIndent 3067 +#define wxStyledTextCtrl_GetIndent 3068 +#define wxStyledTextCtrl_SetUseTabs 3069 +#define wxStyledTextCtrl_GetUseTabs 3070 +#define wxStyledTextCtrl_SetLineIndentation 3071 +#define wxStyledTextCtrl_GetLineIndentation 3072 +#define wxStyledTextCtrl_GetLineIndentPosition 3073 +#define wxStyledTextCtrl_GetColumn 3074 +#define wxStyledTextCtrl_SetUseHorizontalScrollBar 3075 +#define wxStyledTextCtrl_GetUseHorizontalScrollBar 3076 +#define wxStyledTextCtrl_SetIndentationGuides 3077 +#define wxStyledTextCtrl_GetIndentationGuides 3078 +#define wxStyledTextCtrl_SetHighlightGuide 3079 +#define wxStyledTextCtrl_GetHighlightGuide 3080 +#define wxStyledTextCtrl_GetLineEndPosition 3081 +#define wxStyledTextCtrl_GetCodePage 3082 +#define wxStyledTextCtrl_GetCaretForeground 3083 +#define wxStyledTextCtrl_GetReadOnly 3084 +#define wxStyledTextCtrl_SetCurrentPos 3085 +#define wxStyledTextCtrl_SetSelectionStart 3086 +#define wxStyledTextCtrl_GetSelectionStart 3087 +#define wxStyledTextCtrl_SetSelectionEnd 3088 +#define wxStyledTextCtrl_GetSelectionEnd 3089 +#define wxStyledTextCtrl_SetPrintMagnification 3090 +#define wxStyledTextCtrl_GetPrintMagnification 3091 +#define wxStyledTextCtrl_SetPrintColourMode 3092 +#define wxStyledTextCtrl_GetPrintColourMode 3093 +#define wxStyledTextCtrl_FindText 3094 +#define wxStyledTextCtrl_FormatRange 3095 +#define wxStyledTextCtrl_GetFirstVisibleLine 3096 +#define wxStyledTextCtrl_GetLine 3097 +#define wxStyledTextCtrl_GetLineCount 3098 +#define wxStyledTextCtrl_SetMarginLeft 3099 +#define wxStyledTextCtrl_GetMarginLeft 3100 +#define wxStyledTextCtrl_SetMarginRight 3101 +#define wxStyledTextCtrl_GetMarginRight 3102 +#define wxStyledTextCtrl_GetModify 3103 +#define wxStyledTextCtrl_SetSelection 3104 +#define wxStyledTextCtrl_GetSelectedText 3105 +#define wxStyledTextCtrl_GetTextRange 3106 +#define wxStyledTextCtrl_HideSelection 3107 +#define wxStyledTextCtrl_LineFromPosition 3108 +#define wxStyledTextCtrl_PositionFromLine 3109 +#define wxStyledTextCtrl_LineScroll 3110 +#define wxStyledTextCtrl_EnsureCaretVisible 3111 +#define wxStyledTextCtrl_ReplaceSelection 3112 +#define wxStyledTextCtrl_SetReadOnly 3113 +#define wxStyledTextCtrl_CanPaste 3114 +#define wxStyledTextCtrl_CanUndo 3115 +#define wxStyledTextCtrl_EmptyUndoBuffer 3116 +#define wxStyledTextCtrl_Undo 3117 +#define wxStyledTextCtrl_Cut 3118 +#define wxStyledTextCtrl_Copy 3119 +#define wxStyledTextCtrl_Paste 3120 +#define wxStyledTextCtrl_Clear 3121 +#define wxStyledTextCtrl_SetText 3122 +#define wxStyledTextCtrl_GetText 3123 +#define wxStyledTextCtrl_GetTextLength 3124 +#define wxStyledTextCtrl_GetOvertype 3125 +#define wxStyledTextCtrl_SetCaretWidth 3126 +#define wxStyledTextCtrl_GetCaretWidth 3127 +#define wxStyledTextCtrl_SetTargetStart 3128 +#define wxStyledTextCtrl_GetTargetStart 3129 +#define wxStyledTextCtrl_SetTargetEnd 3130 +#define wxStyledTextCtrl_GetTargetEnd 3131 +#define wxStyledTextCtrl_ReplaceTarget 3132 +#define wxStyledTextCtrl_SearchInTarget 3133 +#define wxStyledTextCtrl_SetSearchFlags 3134 +#define wxStyledTextCtrl_GetSearchFlags 3135 +#define wxStyledTextCtrl_CallTipShow 3136 +#define wxStyledTextCtrl_CallTipCancel 3137 +#define wxStyledTextCtrl_CallTipActive 3138 +#define wxStyledTextCtrl_CallTipPosAtStart 3139 +#define wxStyledTextCtrl_CallTipSetHighlight 3140 +#define wxStyledTextCtrl_CallTipSetBackground 3141 +#define wxStyledTextCtrl_CallTipSetForeground 3142 +#define wxStyledTextCtrl_CallTipSetForegroundHighlight 3143 +#define wxStyledTextCtrl_CallTipUseStyle 3144 +#define wxStyledTextCtrl_VisibleFromDocLine 3145 +#define wxStyledTextCtrl_DocLineFromVisible 3146 +#define wxStyledTextCtrl_WrapCount 3147 +#define wxStyledTextCtrl_SetFoldLevel 3148 +#define wxStyledTextCtrl_GetFoldLevel 3149 +#define wxStyledTextCtrl_GetLastChild 3150 +#define wxStyledTextCtrl_GetFoldParent 3151 +#define wxStyledTextCtrl_ShowLines 3152 +#define wxStyledTextCtrl_HideLines 3153 +#define wxStyledTextCtrl_GetLineVisible 3154 +#define wxStyledTextCtrl_SetFoldExpanded 3155 +#define wxStyledTextCtrl_GetFoldExpanded 3156 +#define wxStyledTextCtrl_ToggleFold 3157 +#define wxStyledTextCtrl_EnsureVisible 3158 +#define wxStyledTextCtrl_SetFoldFlags 3159 +#define wxStyledTextCtrl_EnsureVisibleEnforcePolicy 3160 +#define wxStyledTextCtrl_SetTabIndents 3161 +#define wxStyledTextCtrl_GetTabIndents 3162 +#define wxStyledTextCtrl_SetBackSpaceUnIndents 3163 +#define wxStyledTextCtrl_GetBackSpaceUnIndents 3164 +#define wxStyledTextCtrl_SetMouseDwellTime 3165 +#define wxStyledTextCtrl_GetMouseDwellTime 3166 +#define wxStyledTextCtrl_WordStartPosition 3167 +#define wxStyledTextCtrl_WordEndPosition 3168 +#define wxStyledTextCtrl_SetWrapMode 3169 +#define wxStyledTextCtrl_GetWrapMode 3170 +#define wxStyledTextCtrl_SetWrapVisualFlags 3171 +#define wxStyledTextCtrl_GetWrapVisualFlags 3172 +#define wxStyledTextCtrl_SetWrapVisualFlagsLocation 3173 +#define wxStyledTextCtrl_GetWrapVisualFlagsLocation 3174 +#define wxStyledTextCtrl_SetWrapStartIndent 3175 +#define wxStyledTextCtrl_GetWrapStartIndent 3176 +#define wxStyledTextCtrl_SetLayoutCache 3177 +#define wxStyledTextCtrl_GetLayoutCache 3178 +#define wxStyledTextCtrl_SetScrollWidth 3179 +#define wxStyledTextCtrl_GetScrollWidth 3180 +#define wxStyledTextCtrl_TextWidth 3181 +#define wxStyledTextCtrl_GetEndAtLastLine 3182 +#define wxStyledTextCtrl_TextHeight 3183 +#define wxStyledTextCtrl_SetUseVerticalScrollBar 3184 +#define wxStyledTextCtrl_GetUseVerticalScrollBar 3185 +#define wxStyledTextCtrl_AppendText 3186 +#define wxStyledTextCtrl_GetTwoPhaseDraw 3187 +#define wxStyledTextCtrl_SetTwoPhaseDraw 3188 +#define wxStyledTextCtrl_TargetFromSelection 3189 +#define wxStyledTextCtrl_LinesJoin 3190 +#define wxStyledTextCtrl_LinesSplit 3191 +#define wxStyledTextCtrl_SetFoldMarginColour 3192 +#define wxStyledTextCtrl_SetFoldMarginHiColour 3193 +#define wxStyledTextCtrl_LineDown 3194 +#define wxStyledTextCtrl_LineDownExtend 3195 +#define wxStyledTextCtrl_LineUp 3196 +#define wxStyledTextCtrl_LineUpExtend 3197 +#define wxStyledTextCtrl_CharLeft 3198 +#define wxStyledTextCtrl_CharLeftExtend 3199 +#define wxStyledTextCtrl_CharRight 3200 +#define wxStyledTextCtrl_CharRightExtend 3201 +#define wxStyledTextCtrl_WordLeft 3202 +#define wxStyledTextCtrl_WordLeftExtend 3203 +#define wxStyledTextCtrl_WordRight 3204 +#define wxStyledTextCtrl_WordRightExtend 3205 +#define wxStyledTextCtrl_Home 3206 +#define wxStyledTextCtrl_HomeExtend 3207 +#define wxStyledTextCtrl_LineEnd 3208 +#define wxStyledTextCtrl_LineEndExtend 3209 +#define wxStyledTextCtrl_DocumentStart 3210 +#define wxStyledTextCtrl_DocumentStartExtend 3211 +#define wxStyledTextCtrl_DocumentEnd 3212 +#define wxStyledTextCtrl_DocumentEndExtend 3213 +#define wxStyledTextCtrl_PageUp 3214 +#define wxStyledTextCtrl_PageUpExtend 3215 +#define wxStyledTextCtrl_PageDown 3216 +#define wxStyledTextCtrl_PageDownExtend 3217 +#define wxStyledTextCtrl_EditToggleOvertype 3218 +#define wxStyledTextCtrl_Cancel 3219 +#define wxStyledTextCtrl_DeleteBack 3220 +#define wxStyledTextCtrl_Tab 3221 +#define wxStyledTextCtrl_BackTab 3222 +#define wxStyledTextCtrl_NewLine 3223 +#define wxStyledTextCtrl_FormFeed 3224 +#define wxStyledTextCtrl_VCHome 3225 +#define wxStyledTextCtrl_VCHomeExtend 3226 +#define wxStyledTextCtrl_ZoomIn 3227 +#define wxStyledTextCtrl_ZoomOut 3228 +#define wxStyledTextCtrl_DelWordLeft 3229 +#define wxStyledTextCtrl_DelWordRight 3230 +#define wxStyledTextCtrl_LineCut 3231 +#define wxStyledTextCtrl_LineDelete 3232 +#define wxStyledTextCtrl_LineTranspose 3233 +#define wxStyledTextCtrl_LineDuplicate 3234 +#define wxStyledTextCtrl_LowerCase 3235 +#define wxStyledTextCtrl_UpperCase 3236 +#define wxStyledTextCtrl_LineScrollDown 3237 +#define wxStyledTextCtrl_LineScrollUp 3238 +#define wxStyledTextCtrl_DeleteBackNotLine 3239 +#define wxStyledTextCtrl_HomeDisplay 3240 +#define wxStyledTextCtrl_HomeDisplayExtend 3241 +#define wxStyledTextCtrl_LineEndDisplay 3242 +#define wxStyledTextCtrl_LineEndDisplayExtend 3243 +#define wxStyledTextCtrl_HomeWrapExtend 3244 +#define wxStyledTextCtrl_LineEndWrap 3245 +#define wxStyledTextCtrl_LineEndWrapExtend 3246 +#define wxStyledTextCtrl_VCHomeWrap 3247 +#define wxStyledTextCtrl_VCHomeWrapExtend 3248 +#define wxStyledTextCtrl_LineCopy 3249 +#define wxStyledTextCtrl_MoveCaretInsideView 3250 +#define wxStyledTextCtrl_LineLength 3251 +#define wxStyledTextCtrl_BraceHighlight 3252 +#define wxStyledTextCtrl_BraceBadLight 3253 +#define wxStyledTextCtrl_BraceMatch 3254 +#define wxStyledTextCtrl_GetViewEOL 3255 +#define wxStyledTextCtrl_SetViewEOL 3256 +#define wxStyledTextCtrl_SetModEventMask 3257 +#define wxStyledTextCtrl_GetEdgeColumn 3258 +#define wxStyledTextCtrl_SetEdgeColumn 3259 +#define wxStyledTextCtrl_GetEdgeMode 3260 +#define wxStyledTextCtrl_GetEdgeColour 3261 +#define wxStyledTextCtrl_SetEdgeColour 3262 +#define wxStyledTextCtrl_SearchAnchor 3263 +#define wxStyledTextCtrl_SearchNext 3264 +#define wxStyledTextCtrl_SearchPrev 3265 +#define wxStyledTextCtrl_LinesOnScreen 3266 +#define wxStyledTextCtrl_UsePopUp 3267 +#define wxStyledTextCtrl_SelectionIsRectangle 3268 +#define wxStyledTextCtrl_SetZoom 3269 +#define wxStyledTextCtrl_GetZoom 3270 +#define wxStyledTextCtrl_GetModEventMask 3271 +#define wxStyledTextCtrl_SetSTCFocus 3272 +#define wxStyledTextCtrl_GetSTCFocus 3273 +#define wxStyledTextCtrl_SetStatus 3274 +#define wxStyledTextCtrl_GetStatus 3275 +#define wxStyledTextCtrl_SetMouseDownCaptures 3276 +#define wxStyledTextCtrl_GetMouseDownCaptures 3277 +#define wxStyledTextCtrl_SetSTCCursor 3278 +#define wxStyledTextCtrl_GetSTCCursor 3279 +#define wxStyledTextCtrl_SetControlCharSymbol 3280 +#define wxStyledTextCtrl_GetControlCharSymbol 3281 +#define wxStyledTextCtrl_WordPartLeft 3282 +#define wxStyledTextCtrl_WordPartLeftExtend 3283 +#define wxStyledTextCtrl_WordPartRight 3284 +#define wxStyledTextCtrl_WordPartRightExtend 3285 +#define wxStyledTextCtrl_SetVisiblePolicy 3286 +#define wxStyledTextCtrl_DelLineLeft 3287 +#define wxStyledTextCtrl_DelLineRight 3288 +#define wxStyledTextCtrl_GetXOffset 3289 +#define wxStyledTextCtrl_ChooseCaretX 3290 +#define wxStyledTextCtrl_SetXCaretPolicy 3291 +#define wxStyledTextCtrl_SetYCaretPolicy 3292 +#define wxStyledTextCtrl_GetPrintWrapMode 3293 +#define wxStyledTextCtrl_SetHotspotActiveForeground 3294 +#define wxStyledTextCtrl_SetHotspotActiveBackground 3295 +#define wxStyledTextCtrl_SetHotspotActiveUnderline 3296 +#define wxStyledTextCtrl_SetHotspotSingleLine 3297 +#define wxStyledTextCtrl_ParaDownExtend 3298 +#define wxStyledTextCtrl_ParaUp 3299 +#define wxStyledTextCtrl_ParaUpExtend 3300 +#define wxStyledTextCtrl_PositionBefore 3301 +#define wxStyledTextCtrl_PositionAfter 3302 +#define wxStyledTextCtrl_CopyRange 3303 +#define wxStyledTextCtrl_CopyText 3304 +#define wxStyledTextCtrl_SetSelectionMode 3305 +#define wxStyledTextCtrl_GetSelectionMode 3306 +#define wxStyledTextCtrl_LineDownRectExtend 3307 +#define wxStyledTextCtrl_LineUpRectExtend 3308 +#define wxStyledTextCtrl_CharLeftRectExtend 3309 +#define wxStyledTextCtrl_CharRightRectExtend 3310 +#define wxStyledTextCtrl_HomeRectExtend 3311 +#define wxStyledTextCtrl_VCHomeRectExtend 3312 +#define wxStyledTextCtrl_LineEndRectExtend 3313 +#define wxStyledTextCtrl_PageUpRectExtend 3314 +#define wxStyledTextCtrl_PageDownRectExtend 3315 +#define wxStyledTextCtrl_StutteredPageUp 3316 +#define wxStyledTextCtrl_StutteredPageUpExtend 3317 +#define wxStyledTextCtrl_StutteredPageDown 3318 +#define wxStyledTextCtrl_StutteredPageDownExtend 3319 +#define wxStyledTextCtrl_WordLeftEnd 3320 +#define wxStyledTextCtrl_WordLeftEndExtend 3321 +#define wxStyledTextCtrl_WordRightEnd 3322 +#define wxStyledTextCtrl_WordRightEndExtend 3323 +#define wxStyledTextCtrl_SetWhitespaceChars 3324 +#define wxStyledTextCtrl_SetCharsDefault 3325 +#define wxStyledTextCtrl_AutoCompGetCurrent 3326 +#define wxStyledTextCtrl_Allocate 3327 +#define wxStyledTextCtrl_FindColumn 3328 +#define wxStyledTextCtrl_GetCaretSticky 3329 +#define wxStyledTextCtrl_SetCaretSticky 3330 +#define wxStyledTextCtrl_ToggleCaretSticky 3331 +#define wxStyledTextCtrl_SetPasteConvertEndings 3332 +#define wxStyledTextCtrl_GetPasteConvertEndings 3333 +#define wxStyledTextCtrl_SelectionDuplicate 3334 +#define wxStyledTextCtrl_SetCaretLineBackAlpha 3335 +#define wxStyledTextCtrl_GetCaretLineBackAlpha 3336 +#define wxStyledTextCtrl_StartRecord 3337 +#define wxStyledTextCtrl_StopRecord 3338 +#define wxStyledTextCtrl_SetLexer 3339 +#define wxStyledTextCtrl_GetLexer 3340 +#define wxStyledTextCtrl_Colourise 3341 +#define wxStyledTextCtrl_SetProperty 3342 +#define wxStyledTextCtrl_SetKeyWords 3343 +#define wxStyledTextCtrl_SetLexerLanguage 3344 +#define wxStyledTextCtrl_GetProperty 3345 +#define wxStyledTextCtrl_GetStyleBitsNeeded 3346 +#define wxStyledTextCtrl_GetCurrentLine 3347 +#define wxStyledTextCtrl_StyleSetSpec 3348 +#define wxStyledTextCtrl_StyleSetFont 3349 +#define wxStyledTextCtrl_StyleSetFontAttr 3350 +#define wxStyledTextCtrl_StyleSetCharacterSet 3351 +#define wxStyledTextCtrl_StyleSetFontEncoding 3352 +#define wxStyledTextCtrl_CmdKeyExecute 3353 +#define wxStyledTextCtrl_SetMargins 3354 +#define wxStyledTextCtrl_GetSelection 3355 +#define wxStyledTextCtrl_PointFromPosition 3356 +#define wxStyledTextCtrl_ScrollToLine 3357 +#define wxStyledTextCtrl_ScrollToColumn 3358 +#define wxStyledTextCtrl_SendMsg 3359 +#define wxStyledTextCtrl_SetVScrollBar 3360 +#define wxStyledTextCtrl_SetHScrollBar 3361 +#define wxStyledTextCtrl_GetLastKeydownProcessed 3362 +#define wxStyledTextCtrl_SetLastKeydownProcessed 3363 +#define wxStyledTextCtrl_SaveFile 3364 +#define wxStyledTextCtrl_LoadFile 3365 +#define wxStyledTextCtrl_DoDragOver 3366 +#define wxStyledTextCtrl_DoDropText 3367 +#define wxStyledTextCtrl_GetUseAntiAliasing 3368 +#define wxStyledTextCtrl_AddTextRaw 3369 +#define wxStyledTextCtrl_InsertTextRaw 3370 +#define wxStyledTextCtrl_GetCurLineRaw 3371 +#define wxStyledTextCtrl_GetLineRaw 3372 +#define wxStyledTextCtrl_GetSelectedTextRaw 3373 +#define wxStyledTextCtrl_GetTextRangeRaw 3374 +#define wxStyledTextCtrl_SetTextRaw 3375 +#define wxStyledTextCtrl_GetTextRaw 3376 +#define wxStyledTextCtrl_AppendTextRaw 3377 +#define wxArtProvider_GetBitmap 3378 +#define wxArtProvider_GetIcon 3379 +#define wxTreeEvent_GetKeyCode 3380 +#define wxTreeEvent_GetItem 3381 +#define wxTreeEvent_GetKeyEvent 3382 +#define wxTreeEvent_GetLabel 3383 +#define wxTreeEvent_GetOldItem 3384 +#define wxTreeEvent_GetPoint 3385 +#define wxTreeEvent_IsEditCancelled 3386 +#define wxTreeEvent_SetToolTip 3387 +#define wxNotebookEvent_GetOldSelection 3388 +#define wxNotebookEvent_GetSelection 3389 +#define wxNotebookEvent_SetOldSelection 3390 +#define wxNotebookEvent_SetSelection 3391 +#define wxFileDataObject_new 3392 +#define wxFileDataObject_AddFile 3393 +#define wxFileDataObject_GetFilenames 3394 +#define wxFileDataObject_destroy 3395 +#define wxTextDataObject_new 3396 +#define wxTextDataObject_GetTextLength 3397 +#define wxTextDataObject_GetText 3398 +#define wxTextDataObject_SetText 3399 +#define wxTextDataObject_destroy 3400 +#define wxBitmapDataObject_new_1_1 3401 +#define wxBitmapDataObject_new_1_0 3402 +#define wxBitmapDataObject_GetBitmap 3403 +#define wxBitmapDataObject_SetBitmap 3404 +#define wxBitmapDataObject_destroy 3405 +#define wxClipboard_new 3407 +#define wxClipboard_destruct 3408 +#define wxClipboard_AddData 3409 +#define wxClipboard_Clear 3410 +#define wxClipboard_Close 3411 +#define wxClipboard_Flush 3412 +#define wxClipboard_GetData 3413 +#define wxClipboard_IsOpened 3414 +#define wxClipboard_Open 3415 +#define wxClipboard_SetData 3416 +#define wxClipboard_UsePrimarySelection 3418 +#define wxClipboard_IsSupported 3419 +#define wxClipboard_Get 3420 +#define wxSpinEvent_GetPosition 3421 +#define wxSpinEvent_SetPosition 3422 +#define wxSplitterWindow_new_0 3423 +#define wxSplitterWindow_new_2 3424 +#define wxSplitterWindow_destruct 3425 +#define wxSplitterWindow_Create 3426 +#define wxSplitterWindow_GetMinimumPaneSize 3427 +#define wxSplitterWindow_GetSashGravity 3428 +#define wxSplitterWindow_GetSashPosition 3429 +#define wxSplitterWindow_GetSplitMode 3430 +#define wxSplitterWindow_GetWindow1 3431 +#define wxSplitterWindow_GetWindow2 3432 +#define wxSplitterWindow_Initialize 3433 +#define wxSplitterWindow_IsSplit 3434 +#define wxSplitterWindow_ReplaceWindow 3435 +#define wxSplitterWindow_SetSashGravity 3436 +#define wxSplitterWindow_SetSashPosition 3437 +#define wxSplitterWindow_SetSashSize 3438 +#define wxSplitterWindow_SetMinimumPaneSize 3439 +#define wxSplitterWindow_SetSplitMode 3440 +#define wxSplitterWindow_SplitHorizontally 3441 +#define wxSplitterWindow_SplitVertically 3442 +#define wxSplitterWindow_Unsplit 3443 +#define wxSplitterWindow_UpdateSize 3444 +#define wxSplitterEvent_GetSashPosition 3445 +#define wxSplitterEvent_GetX 3446 +#define wxSplitterEvent_GetY 3447 +#define wxSplitterEvent_GetWindowBeingRemoved 3448 +#define wxSplitterEvent_SetSashPosition 3449 +#define wxHtmlWindow_new_0 3450 +#define wxHtmlWindow_new_2 3451 +#define wxHtmlWindow_AppendToPage 3452 +#define wxHtmlWindow_GetOpenedAnchor 3453 +#define wxHtmlWindow_GetOpenedPage 3454 +#define wxHtmlWindow_GetOpenedPageTitle 3455 +#define wxHtmlWindow_GetRelatedFrame 3456 +#define wxHtmlWindow_HistoryBack 3457 +#define wxHtmlWindow_HistoryCanBack 3458 +#define wxHtmlWindow_HistoryCanForward 3459 +#define wxHtmlWindow_HistoryClear 3460 +#define wxHtmlWindow_HistoryForward 3461 +#define wxHtmlWindow_LoadFile 3462 +#define wxHtmlWindow_LoadPage 3463 +#define wxHtmlWindow_SelectAll 3464 +#define wxHtmlWindow_SelectionToText 3465 +#define wxHtmlWindow_SelectLine 3466 +#define wxHtmlWindow_SelectWord 3467 +#define wxHtmlWindow_SetBorders 3468 +#define wxHtmlWindow_SetFonts 3469 +#define wxHtmlWindow_SetPage 3470 +#define wxHtmlWindow_SetRelatedFrame 3471 +#define wxHtmlWindow_SetRelatedStatusBar 3472 +#define wxHtmlWindow_ToText 3473 +#define wxHtmlWindow_destroy 3474 +#define wxHtmlLinkEvent_GetLinkInfo 3475 +#define wxAuiNotebookEvent_SetSelection 3476 +#define wxAuiNotebookEvent_GetSelection 3477 +#define wxAuiNotebookEvent_SetOldSelection 3478 +#define wxAuiNotebookEvent_GetOldSelection 3479 +#define wxAuiNotebookEvent_SetDragSource 3480 +#define wxAuiNotebookEvent_GetDragSource 3481 +#define wxAuiManagerEvent_SetManager 3482 +#define wxAuiManagerEvent_GetManager 3483 +#define wxAuiManagerEvent_SetPane 3484 +#define wxAuiManagerEvent_GetPane 3485 +#define wxAuiManagerEvent_SetButton 3486 +#define wxAuiManagerEvent_GetButton 3487 +#define wxAuiManagerEvent_SetDC 3488 +#define wxAuiManagerEvent_GetDC 3489 +#define wxAuiManagerEvent_Veto 3490 +#define wxAuiManagerEvent_GetVeto 3491 +#define wxAuiManagerEvent_SetCanVeto 3492 +#define wxAuiManagerEvent_CanVeto 3493 +#define wxLogNull_new 3494 +#define wxLogNull_destroy 3495 diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp index d115bb2243..4486dff63b 100644 --- a/lib/wx/c_src/wxe_impl.cpp +++ b/lib/wx/c_src/wxe_impl.cpp @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2008-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2008-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -615,28 +615,33 @@ int WxeApp::getRef(void * ptr, wxeMemEnv *memenv) { ptrMap::iterator it = ptr2ref.find(ptr); if(it != ptr2ref.end()) { wxeRefData *refd = it->second; - return refd->ref; - } else { // New Ptr - int ref; - intList free = memenv->free; - - if(free.IsEmpty()) { - ref = memenv->next++; - } else { - ref = free.Pop(); - }; - if(ref >= memenv->max) { - memenv->max *= 2; - memenv->ref2ptr = - (void **) driver_realloc(memenv->ref2ptr,memenv->max * sizeof(void*)); - } + if(refd->memenv == memenv) { + // Found it return + return refd->ref; + } // else + // Old reference to deleted object, release old and recreate in current memenv. + clearPtr(ptr); + } + int ref; + intList free = memenv->free; - memenv->ref2ptr[ref] = ptr; - ptr2ref[ptr] = new wxeRefData(ref, 0, false, memenv); - return ref; + if(free.IsEmpty()) { + ref = memenv->next++; + } else { + ref = free.Pop(); + }; + if(ref >= memenv->max) { + memenv->max *= 2; + memenv->ref2ptr = + (void **) driver_realloc(memenv->ref2ptr,memenv->max * sizeof(void*)); } + + memenv->ref2ptr[ref] = ptr; + ptr2ref[ptr] = new wxeRefData(ref, 0, false, memenv); + return ref; } + void WxeApp::clearPtr(void * ptr) { ptrMap::iterator it; it = ptr2ref.find(ptr); @@ -697,13 +702,15 @@ void WxeApp::clearPtr(void * ptr) { void * WxeApp::getPtr(char * bp, wxeMemEnv *memenv) { int index = *(int *) bp; - if(!memenv) + if(!memenv) { throw wxe_badarg(index); + } void * temp = memenv->ref2ptr[index]; if((index < memenv->next) && ((index == 0) || (temp > NULL))) return temp; - else + else { throw wxe_badarg(index); + } } void WxeApp::registerPid(char * bp, ErlDrvTermData pid, wxeMemEnv * memenv) { diff --git a/lib/wx/c_src/wxe_return.cpp b/lib/wx/c_src/wxe_return.cpp index 8a00d6f4c6..2c4f7541e7 100644 --- a/lib/wx/c_src/wxe_return.cpp +++ b/lib/wx/c_src/wxe_return.cpp @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2008-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2008-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -219,7 +219,7 @@ void wxeReturn::add(wxArrayInt val) { INLINE void wxeReturn::add(wxUIntPtr *val) { - addInt((ErlDrvTermData)val); // TODO is this right? + add(ERL_DRV_UINT, (ErlDrvTermData) val); } INLINE diff --git a/lib/wx/include/wx.hrl b/lib/wx/include/wx.hrl index b22f7e34b8..f5824196b0 100644 --- a/lib/wx/include/wx.hrl +++ b/lib/wx/include/wx.hrl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% This file is generated DO NOT EDIT @@ -261,7 +261,7 @@ %% Callback event: {@link wxColourPickerEvent} -record(wxColourPicker,{type, colour}). -%% @type wxTree() = #wxTree{type=wxEventType(),item=wxTreeItemId(),itemOld=wxTreeItemId(),pointDrag={X::integer(),Y::integer()}}. +%% @type wxTree() = #wxTree{type=wxEventType(),item=integer(),itemOld=integer(),pointDrag={X::integer(),Y::integer()}}. %% <dl><dt>EventType:</dt> <dd><em>command_tree_begin_drag</em>, <em>command_tree_begin_rdrag</em>, <em>command_tree_begin_label_edit</em>, <em>command_tree_end_label_edit</em>, <em>command_tree_delete_item</em>, <em>command_tree_get_info</em>, <em>command_tree_set_info</em>, <em>command_tree_item_expanded</em>, <em>command_tree_item_expanding</em>, <em>command_tree_item_collapsed</em>, <em>command_tree_item_collapsing</em>, <em>command_tree_sel_changed</em>, <em>command_tree_sel_changing</em>, <em>command_tree_key_down</em>, <em>command_tree_item_activated</em>, <em>command_tree_item_right_click</em>, <em>command_tree_item_middle_click</em>, <em>command_tree_end_drag</em>, <em>command_tree_state_image_click</em>, <em>command_tree_item_gettooltip</em>, <em>command_tree_item_menu</em></dd></dl> %% Callback event: {@link wxTreeEvent} -record(wxTree,{type, item,itemOld,pointDrag}). diff --git a/lib/wx/src/gen/wxGenericDirCtrl.erl b/lib/wx/src/gen/wxGenericDirCtrl.erl index 4146a3bacc..bd97e14816 100644 --- a/lib/wx/src/gen/wxGenericDirCtrl.erl +++ b/lib/wx/src/gen/wxGenericDirCtrl.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% This file is generated DO NOT EDIT @@ -191,7 +191,7 @@ getFilterIndex(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:call(?wxGenericDirCtrl_GetFilterIndex, <<ThisRef:32/?UI>>). -%% @spec (This::wxGenericDirCtrl()) -> wxTreeItemId() +%% @spec (This::wxGenericDirCtrl()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxgenericdirctrl.html#wxgenericdirctrlgetrootid">external documentation</a>. getRootId(#wx_ref{type=ThisT,ref=ThisRef}) -> ?CLASS(ThisT,wxGenericDirCtrl), diff --git a/lib/wx/src/gen/wxTreeCtrl.erl b/lib/wx/src/gen/wxTreeCtrl.erl index cc08c14754..a5f0bdc750 100644 --- a/lib/wx/src/gen/wxTreeCtrl.erl +++ b/lib/wx/src/gen/wxTreeCtrl.erl @@ -1,23 +1,27 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% This file is generated DO NOT EDIT %% @doc See external documentation: <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html">wxTreeCtrl</a>. +%% +%% Note: The representation of treeItemId() have changed from the original class implementation to be an semi-opaque type,Equality between TreeItemId's can be tested and zero means that the TreeItem is invalid. + +%% %% <p>This class is derived (and can use functions) from: %% <br />{@link wxControl} %% <br />{@link wxWindow} @@ -33,10 +37,10 @@ collapse/2,collapseAndReset/2,create/2,create/3,delete/2,deleteAllItems/1, deleteChildren/2,destroy/1,ensureVisible/2,expand/2,getBoundingRect/3, getBoundingRect/4,getChildrenCount/2,getChildrenCount/3,getCount/1, - getEditControl/1,getFirstVisibleItem/1,getImageList/1,getIndent/1, - getItemBackgroundColour/2,getItemData/2,getItemFont/2,getItemImage/2, - getItemImage/3,getItemParent/2,getItemText/2,getItemTextColour/2, - getLastChild/2,getNextSibling/2,getNextVisible/2,getPrevSibling/2, + getEditControl/1,getFirstChild/2,getFirstVisibleItem/1,getImageList/1, + getIndent/1,getItemBackgroundColour/2,getItemData/2,getItemFont/2, + getItemImage/2,getItemImage/3,getItemParent/2,getItemText/2,getItemTextColour/2, + getLastChild/2,getNextChild/3,getNextSibling/2,getNextVisible/2,getPrevSibling/2, getPrevVisible/2,getRootItem/1,getSelection/1,getSelections/1,getStateImageList/1, hitTest/2,insertItem/4,insertItem/5,isBold/2,isExpanded/2,isSelected/2, isVisible/2,itemHasChildren/2,new/0,new/1,new/2,prependItem/3,prependItem/4, @@ -119,13 +123,13 @@ new(#wx_ref{type=ParentT,ref=ParentRef}, Options) wxe_util:construct(?wxTreeCtrl_new_2, <<ParentRef:32/?UI, 0:32,BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Text::string()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Text::string()) -> integer() %% @equiv addRoot(This,Text, []) addRoot(This,Text) when is_record(This, wx_ref),is_list(Text) -> addRoot(This,Text, []). -%% @spec (This::wxTreeCtrl(), Text::string(), [Option]) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Text::string(), [Option]) -> integer() %% Option = {image, integer()} | {selectedImage, integer()} | {data, term()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrladdroot">external documentation</a>. addRoot(#wx_ref{type=ThisT,ref=ThisRef},Text, Options) @@ -140,17 +144,17 @@ addRoot(#wx_ref{type=ThisT,ref=ThisRef},Text, Options) wxe_util:call(?wxTreeCtrl_AddRoot, <<ThisRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((0+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Parent::wxTreeItemId(), Text::string()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Parent::integer(), Text::string()) -> integer() %% @equiv appendItem(This,Parent,Text, []) appendItem(This,Parent,Text) - when is_record(This, wx_ref),is_record(Parent, wx_ref),is_list(Text) -> + when is_record(This, wx_ref),is_integer(Parent),is_list(Text) -> appendItem(This,Parent,Text, []). -%% @spec (This::wxTreeCtrl(), Parent::wxTreeItemId(), Text::string(), [Option]) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Parent::integer(), Text::string(), [Option]) -> integer() %% Option = {image, integer()} | {selectedImage, integer()} | {data, term()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlappenditem">external documentation</a>. -appendItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ParentRef},Text, Options) - when is_list(Text),is_list(Options) -> +appendItem(#wx_ref{type=ThisT,ref=ThisRef},Parent,Text, Options) + when is_integer(Parent),is_list(Text),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), Text_UC = unicode:characters_to_binary([Text,0]), MOpts = fun({image, Image}, Acc) -> [<<1:32/?UI,Image:32/?UI>>|Acc]; @@ -159,7 +163,7 @@ appendItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ParentR (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:call(?wxTreeCtrl_AppendItem, - <<ThisRef:32/?UI,ParentRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((4+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Parent:64/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((4+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>). %% @spec (This::wxTreeCtrl(), ImageList::wxImageList:wxImageList()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlassignimagelist">external documentation</a>. @@ -177,19 +181,21 @@ assignStateImageList(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=ImageListT,ref wxe_util:cast(?wxTreeCtrl_AssignStateImageList, <<ThisRef:32/?UI,ImageListRef:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlcollapse">external documentation</a>. -collapse(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +collapse(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_Collapse, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlcollapseandreset">external documentation</a>. -collapseAndReset(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +collapseAndReset(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_CollapseAndReset, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). %% @spec (This::wxTreeCtrl(), Parent::wxWindow:wxWindow()) -> bool() %% @equiv create(This,Parent, []) @@ -214,12 +220,13 @@ create(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=ParentT,ref=ParentRef}, Opti wxe_util:call(?wxTreeCtrl_Create, <<ThisRef:32/?UI,ParentRef:32/?UI, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrldelete">external documentation</a>. -delete(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +delete(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_Delete, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). %% @spec (This::wxTreeCtrl()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrldeleteallitems">external documentation</a>. @@ -228,62 +235,65 @@ deleteAllItems(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:cast(?wxTreeCtrl_DeleteAllItems, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrldeletechildren">external documentation</a>. -deleteChildren(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +deleteChildren(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_DeleteChildren, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlensurevisible">external documentation</a>. -ensureVisible(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +ensureVisible(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_EnsureVisible, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlexpand">external documentation</a>. -expand(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +expand(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_Expand, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Rect::{X::integer(),Y::integer(),W::integer(),H::integer()}) -> bool() +%% @spec (This::wxTreeCtrl(), Item::integer(), Rect::{X::integer(),Y::integer(),W::integer(),H::integer()}) -> bool() %% @equiv getBoundingRect(This,Item,Rect, []) getBoundingRect(This,Item,Rect={RectX,RectY,RectW,RectH}) - when is_record(This, wx_ref),is_record(Item, wx_ref),is_integer(RectX),is_integer(RectY),is_integer(RectW),is_integer(RectH) -> + when is_record(This, wx_ref),is_integer(Item),is_integer(RectX),is_integer(RectY),is_integer(RectW),is_integer(RectH) -> getBoundingRect(This,Item,Rect, []). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Rect::{X::integer(),Y::integer(),W::integer(),H::integer()}, [Option]) -> bool() +%% @spec (This::wxTreeCtrl(), Item::integer(), Rect::{X::integer(),Y::integer(),W::integer(),H::integer()}, [Option]) -> bool() %% Option = {textOnly, bool()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetboundingrect">external documentation</a>. -getBoundingRect(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef},{RectX,RectY,RectW,RectH}, Options) - when is_integer(RectX),is_integer(RectY),is_integer(RectW),is_integer(RectH),is_list(Options) -> +getBoundingRect(#wx_ref{type=ThisT,ref=ThisRef},Item,{RectX,RectY,RectW,RectH}, Options) + when is_integer(Item),is_integer(RectX),is_integer(RectY),is_integer(RectW),is_integer(RectH),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({textOnly, TextOnly}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(TextOnly)):32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:call(?wxTreeCtrl_GetBoundingRect, - <<ThisRef:32/?UI,ItemRef:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> integer() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> integer() %% @equiv getChildrenCount(This,Item, []) getChildrenCount(This,Item) - when is_record(This, wx_ref),is_record(Item, wx_ref) -> + when is_record(This, wx_ref),is_integer(Item) -> getChildrenCount(This,Item, []). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), [Option]) -> integer() +%% @spec (This::wxTreeCtrl(), Item::integer(), [Option]) -> integer() %% Option = {recursively, bool()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetchildrencount">external documentation</a>. -getChildrenCount(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}, Options) - when is_list(Options) -> +getChildrenCount(#wx_ref{type=ThisT,ref=ThisRef},Item, Options) + when is_integer(Item),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({recursively, Recursively}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Recursively)):32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:call(?wxTreeCtrl_GetChildrenCount, - <<ThisRef:32/?UI,ItemRef:32/?UI, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI, BinOpt/binary>>). %% @spec (This::wxTreeCtrl()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetcount">external documentation</a>. @@ -299,7 +309,23 @@ getEditControl(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:call(?wxTreeCtrl_GetEditControl, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeCtrl()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> {integer(),Cookie::integer()} +%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetfirstchild">external documentation</a>. +getFirstChild(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> + ?CLASS(ThisT,wxTreeCtrl), + wxe_util:call(?wxTreeCtrl_GetFirstChild, + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). + +%% @spec (This::wxTreeCtrl(), Item::integer(), Cookie::integer()) -> {integer(),Cookie::integer()} +%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetnextchild">external documentation</a>. +getNextChild(#wx_ref{type=ThisT,ref=ThisRef},Item,Cookie) + when is_integer(Item),is_integer(Cookie) -> + ?CLASS(ThisT,wxTreeCtrl), + wxe_util:call(?wxTreeCtrl_GetNextChild, + <<ThisRef:32/?UI,0:32,Item:64/?UI,Cookie:64/?UI>>). + +%% @spec (This::wxTreeCtrl()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetfirstvisibleitem">external documentation</a>. getFirstVisibleItem(#wx_ref{type=ThisT,ref=ThisRef}) -> ?CLASS(ThisT,wxTreeCtrl), @@ -320,119 +346,131 @@ getIndent(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:call(?wxTreeCtrl_GetIndent, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wx:colour() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> wx:colour() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetitembackgroundcolour">external documentation</a>. -getItemBackgroundColour(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getItemBackgroundColour(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetItemBackgroundColour, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> term() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> term() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetitemdata">external documentation</a>. -getItemData(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getItemData(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetItemData, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wxFont:wxFont() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> wxFont:wxFont() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetitemfont">external documentation</a>. -getItemFont(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getItemFont(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetItemFont, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> integer() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetitemimage">external documentation</a>. -getItemImage(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getItemImage(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetItemImage_1, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), [Option]) -> integer() +%% @spec (This::wxTreeCtrl(), Item::integer(), [Option]) -> integer() %% Option = {which, WxTreeItemIcon} %% WxTreeItemIcon = integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetitemimage">external documentation</a>. %%<br /> WxTreeItemIcon is one of ?wxTreeItemIcon_Normal | ?wxTreeItemIcon_Selected | ?wxTreeItemIcon_Expanded | ?wxTreeItemIcon_SelectedExpanded | ?wxTreeItemIcon_Max -getItemImage(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}, Options) - when is_list(Options) -> +getItemImage(#wx_ref{type=ThisT,ref=ThisRef},Item, Options) + when is_integer(Item),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({which, Which}, Acc) -> [<<1:32/?UI,Which:32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:call(?wxTreeCtrl_GetItemImage_2, - <<ThisRef:32/?UI,ItemRef:32/?UI, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> string() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> string() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetitemtext">external documentation</a>. -getItemText(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getItemText(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetItemText, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wx:colour() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> wx:colour() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetitemtextcolour">external documentation</a>. -getItemTextColour(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getItemTextColour(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetItemTextColour, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetlastchild">external documentation</a>. -getLastChild(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getLastChild(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetLastChild, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetnextsibling">external documentation</a>. -getNextSibling(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getNextSibling(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetNextSibling, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetnextvisible">external documentation</a>. -getNextVisible(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getNextVisible(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetNextVisible, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetitemparent">external documentation</a>. -getItemParent(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getItemParent(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetItemParent, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetprevsibling">external documentation</a>. -getPrevSibling(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getPrevSibling(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetPrevSibling, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetprevvisible">external documentation</a>. -getPrevVisible(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +getPrevVisible(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetPrevVisible, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetrootitem">external documentation</a>. getRootItem(#wx_ref{type=ThisT,ref=ThisRef}) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetRootItem, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeCtrl()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetselection">external documentation</a>. getSelection(#wx_ref{type=ThisT,ref=ThisRef}) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_GetSelection, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeCtrl()) -> {integer(),Val::[wxTreeItemId()]} +%% @spec (This::wxTreeCtrl()) -> {integer(),Val::[integer()]} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetselections">external documentation</a>. getSelections(#wx_ref{type=ThisT,ref=ThisRef}) -> ?CLASS(ThisT,wxTreeCtrl), @@ -446,7 +484,7 @@ getStateImageList(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:call(?wxTreeCtrl_GetStateImageList, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Point::{X::integer(),Y::integer()}) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Point::{X::integer(),Y::integer()}) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlhittest">external documentation</a>. hitTest(#wx_ref{type=ThisT,ref=ThisRef},{PointX,PointY}) when is_integer(PointX),is_integer(PointY) -> @@ -454,35 +492,17 @@ hitTest(#wx_ref{type=ThisT,ref=ThisRef},{PointX,PointY}) wxe_util:call(?wxTreeCtrl_HitTest, <<ThisRef:32/?UI,PointX:32/?UI,PointY:32/?UI>>). -%% @spec (This::wxTreeCtrl(),Parent::wxTreeItemId(),X::integer()|wxTreeItemId(),Text::string()) -> wxTreeItemId() -%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlinsertitem">external documentation</a>. -%% <br /> Alternatives: -%% <p><c> -%% insertItem(This::wxTreeCtrl(), Parent::wxTreeItemId(), Pos::integer(), Text::string()) -> insertItem(This,Parent,Pos,Text, []) </c></p> -%% <p><c> -%% insertItem(This::wxTreeCtrl(), Parent::wxTreeItemId(), IdPrevious::wxTreeItemId(), Text::string()) -> insertItem(This,Parent,IdPrevious,Text, []) </c></p> - +%% @spec (This::wxTreeCtrl(), Parent::integer(), Pos::integer(), Text::string()) -> integer() +%% @equiv insertItem(This,Parent,Pos,Text, []) insertItem(This,Parent,Pos,Text) - when is_record(This, wx_ref),is_record(Parent, wx_ref),is_integer(Pos),is_list(Text) -> - insertItem(This,Parent,Pos,Text, []); - -insertItem(This,Parent,IdPrevious,Text) - when is_record(This, wx_ref),is_record(Parent, wx_ref),is_record(IdPrevious, wx_ref),is_list(Text) -> - insertItem(This,Parent,IdPrevious,Text, []). + when is_record(This, wx_ref),is_integer(Parent),is_integer(Pos),is_list(Text) -> + insertItem(This,Parent,Pos,Text, []). -%% @spec (This::wxTreeCtrl(),Parent::wxTreeItemId(),X::integer()|wxTreeItemId(),Text::string(),[Option]) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Parent::integer(), Pos::integer(), Text::string(), [Option]) -> integer() +%% Option = {image, integer()} | {selImage, integer()} | {data, term()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlinsertitem">external documentation</a>. -%% <br /> Alternatives: -%% <p><c> -%% insertItem(This::wxTreeCtrl(), Parent::wxTreeItemId(), Pos::integer(), Text::string(), [Option]) -> wxTreeItemId() </c> -%%<br /> Option = {image, integer()} | {selImage, integer()} | {data, term()} -%% </p> -%% <p><c> -%% insertItem(This::wxTreeCtrl(), Parent::wxTreeItemId(), IdPrevious::wxTreeItemId(), Text::string(), [Option]) -> wxTreeItemId() </c> -%%<br /> Option = {image, integer()} | {selectedImage, integer()} | {data, term()} -%% </p> -insertItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ParentRef},Pos,Text, Options) - when is_integer(Pos),is_list(Text),is_list(Options) -> +insertItem(#wx_ref{type=ThisT,ref=ThisRef},Parent,Pos,Text, Options) + when is_integer(Parent),is_integer(Pos),is_list(Text),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), Text_UC = unicode:characters_to_binary([Text,0]), MOpts = fun({image, Image}, Acc) -> [<<1:32/?UI,Image:32/?UI>>|Acc]; @@ -490,66 +510,60 @@ insertItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ParentR ({data, Data}, Acc) -> wxe_util:send_bin(term_to_binary(Data)),[<<3:32/?UI,0:32>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), - wxe_util:call(?wxTreeCtrl_InsertItem_4_0, - <<ThisRef:32/?UI,ParentRef:32/?UI,Pos:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((0+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>); -insertItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ParentRef},#wx_ref{type=wxTreeItemId,ref=IdPreviousRef},Text, Options) - when is_list(Text),is_list(Options) -> - ?CLASS(ThisT,wxTreeCtrl), - Text_UC = unicode:characters_to_binary([Text,0]), - MOpts = fun({image, Image}, Acc) -> [<<1:32/?UI,Image:32/?UI>>|Acc]; - ({selectedImage, SelectedImage}, Acc) -> [<<2:32/?UI,SelectedImage:32/?UI>>|Acc]; - ({data, Data}, Acc) -> wxe_util:send_bin(term_to_binary(Data)),[<<3:32/?UI,0:32>>|Acc]; - (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, - BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), - wxe_util:call(?wxTreeCtrl_InsertItem_4_1, - <<ThisRef:32/?UI,ParentRef:32/?UI,IdPreviousRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((0+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>). + wxe_util:call(?wxTreeCtrl_InsertItem, + <<ThisRef:32/?UI,0:32,Parent:64/?UI,Pos:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((0+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> bool() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> bool() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlisbold">external documentation</a>. -isBold(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +isBold(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_IsBold, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> bool() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> bool() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlisexpanded">external documentation</a>. -isExpanded(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +isExpanded(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_IsExpanded, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> bool() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> bool() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlisselected">external documentation</a>. -isSelected(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +isSelected(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_IsSelected, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> bool() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> bool() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlisvisible">external documentation</a>. -isVisible(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +isVisible(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_IsVisible, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> bool() +%% @spec (This::wxTreeCtrl(), Item::integer()) -> bool() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlitemhaschildren">external documentation</a>. -itemHasChildren(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +itemHasChildren(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:call(?wxTreeCtrl_ItemHasChildren, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Parent::wxTreeItemId(), Text::string()) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Parent::integer(), Text::string()) -> integer() %% @equiv prependItem(This,Parent,Text, []) prependItem(This,Parent,Text) - when is_record(This, wx_ref),is_record(Parent, wx_ref),is_list(Text) -> + when is_record(This, wx_ref),is_integer(Parent),is_list(Text) -> prependItem(This,Parent,Text, []). -%% @spec (This::wxTreeCtrl(), Parent::wxTreeItemId(), Text::string(), [Option]) -> wxTreeItemId() +%% @spec (This::wxTreeCtrl(), Parent::integer(), Text::string(), [Option]) -> integer() %% Option = {image, integer()} | {selectedImage, integer()} | {data, term()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlprependitem">external documentation</a>. -prependItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ParentRef},Text, Options) - when is_list(Text),is_list(Options) -> +prependItem(#wx_ref{type=ThisT,ref=ThisRef},Parent,Text, Options) + when is_integer(Parent),is_list(Text),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), Text_UC = unicode:characters_to_binary([Text,0]), MOpts = fun({image, Image}, Acc) -> [<<1:32/?UI,Image:32/?UI>>|Acc]; @@ -558,33 +572,35 @@ prependItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=Parent (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:call(?wxTreeCtrl_PrependItem, - <<ThisRef:32/?UI,ParentRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((4+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Parent:64/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((4+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlscrollto">external documentation</a>. -scrollTo(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +scrollTo(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_ScrollTo, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlselectitem">external documentation</a>. -selectItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +selectItem(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_SelectItem_1, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), [Option]) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), [Option]) -> ok %% Option = {select, bool()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlselectitem">external documentation</a>. -selectItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}, Options) - when is_list(Options) -> +selectItem(#wx_ref{type=ThisT,ref=ThisRef},Item, Options) + when is_integer(Item),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({select, Select}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Select)):32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:cast(?wxTreeCtrl_SelectItem_2, - <<ThisRef:32/?UI,ItemRef:32/?UI, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI, BinOpt/binary>>). %% @spec (This::wxTreeCtrl(), Indent::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetindent">external documentation</a>. @@ -602,122 +618,124 @@ setImageList(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=ImageListT,ref=ImageLi wxe_util:cast(?wxTreeCtrl_SetImageList, <<ThisRef:32/?UI,ImageListRef:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Col::wx:colour()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), Col::wx:colour()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitembackgroundcolour">external documentation</a>. -setItemBackgroundColour(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef},Col) - when tuple_size(Col) =:= 3; tuple_size(Col) =:= 4 -> +setItemBackgroundColour(#wx_ref{type=ThisT,ref=ThisRef},Item,Col) + when is_integer(Item),tuple_size(Col) =:= 3; tuple_size(Col) =:= 4 -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_SetItemBackgroundColour, - <<ThisRef:32/?UI,ItemRef:32/?UI,(wxe_util:colour_bin(Col)):16/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI,(wxe_util:colour_bin(Col)):16/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @equiv setItemBold(This,Item, []) setItemBold(This,Item) - when is_record(This, wx_ref),is_record(Item, wx_ref) -> + when is_record(This, wx_ref),is_integer(Item) -> setItemBold(This,Item, []). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), [Option]) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), [Option]) -> ok %% Option = {bold, bool()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitembold">external documentation</a>. -setItemBold(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}, Options) - when is_list(Options) -> +setItemBold(#wx_ref{type=ThisT,ref=ThisRef},Item, Options) + when is_integer(Item),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({bold, Bold}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Bold)):32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:cast(?wxTreeCtrl_SetItemBold, - <<ThisRef:32/?UI,ItemRef:32/?UI, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Data::term()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), Data::term()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitemdata">external documentation</a>. -setItemData(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef},Data) -> +setItemData(#wx_ref{type=ThisT,ref=ThisRef},Item,Data) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:send_bin(term_to_binary(Data)), wxe_util:cast(?wxTreeCtrl_SetItemData, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @equiv setItemDropHighlight(This,Item, []) setItemDropHighlight(This,Item) - when is_record(This, wx_ref),is_record(Item, wx_ref) -> + when is_record(This, wx_ref),is_integer(Item) -> setItemDropHighlight(This,Item, []). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), [Option]) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), [Option]) -> ok %% Option = {highlight, bool()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitemdrophighlight">external documentation</a>. -setItemDropHighlight(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}, Options) - when is_list(Options) -> +setItemDropHighlight(#wx_ref{type=ThisT,ref=ThisRef},Item, Options) + when is_integer(Item),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({highlight, Highlight}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Highlight)):32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:cast(?wxTreeCtrl_SetItemDropHighlight, - <<ThisRef:32/?UI,ItemRef:32/?UI, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Font::wxFont:wxFont()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), Font::wxFont:wxFont()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitemfont">external documentation</a>. -setItemFont(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef},#wx_ref{type=FontT,ref=FontRef}) -> +setItemFont(#wx_ref{type=ThisT,ref=ThisRef},Item,#wx_ref{type=FontT,ref=FontRef}) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), ?CLASS(FontT,wxFont), wxe_util:cast(?wxTreeCtrl_SetItemFont, - <<ThisRef:32/?UI,ItemRef:32/?UI,FontRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI,FontRef:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @equiv setItemHasChildren(This,Item, []) setItemHasChildren(This,Item) - when is_record(This, wx_ref),is_record(Item, wx_ref) -> + when is_record(This, wx_ref),is_integer(Item) -> setItemHasChildren(This,Item, []). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), [Option]) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), [Option]) -> ok %% Option = {has, bool()} %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitemhaschildren">external documentation</a>. -setItemHasChildren(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}, Options) - when is_list(Options) -> +setItemHasChildren(#wx_ref{type=ThisT,ref=ThisRef},Item, Options) + when is_integer(Item),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({has, Has}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Has)):32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:cast(?wxTreeCtrl_SetItemHasChildren, - <<ThisRef:32/?UI,ItemRef:32/?UI, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI, BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Image::integer()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), Image::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitemimage">external documentation</a>. -setItemImage(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef},Image) - when is_integer(Image) -> +setItemImage(#wx_ref{type=ThisT,ref=ThisRef},Item,Image) + when is_integer(Item),is_integer(Image) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_SetItemImage_2, - <<ThisRef:32/?UI,ItemRef:32/?UI,Image:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI,Image:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Image::integer(), [Option]) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), Image::integer(), [Option]) -> ok %% Option = {which, WxTreeItemIcon} %% WxTreeItemIcon = integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitemimage">external documentation</a>. %%<br /> WxTreeItemIcon is one of ?wxTreeItemIcon_Normal | ?wxTreeItemIcon_Selected | ?wxTreeItemIcon_Expanded | ?wxTreeItemIcon_SelectedExpanded | ?wxTreeItemIcon_Max -setItemImage(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef},Image, Options) - when is_integer(Image),is_list(Options) -> +setItemImage(#wx_ref{type=ThisT,ref=ThisRef},Item,Image, Options) + when is_integer(Item),is_integer(Image),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({which, Which}, Acc) -> [<<1:32/?UI,Which:32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:cast(?wxTreeCtrl_SetItemImage_3, - <<ThisRef:32/?UI,ItemRef:32/?UI,Image:32/?UI, 0:32,BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI,Image:32/?UI, 0:32,BinOpt/binary>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Text::string()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), Text::string()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitemtext">external documentation</a>. -setItemText(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef},Text) - when is_list(Text) -> +setItemText(#wx_ref{type=ThisT,ref=ThisRef},Item,Text) + when is_integer(Item),is_list(Text) -> ?CLASS(ThisT,wxTreeCtrl), Text_UC = unicode:characters_to_binary([Text,0]), wxe_util:cast(?wxTreeCtrl_SetItemText, - <<ThisRef:32/?UI,ItemRef:32/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((4+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI,(byte_size(Text_UC)):32/?UI,(Text_UC)/binary, 0:(((8- ((4+byte_size(Text_UC)) band 16#7)) band 16#7))/unit:8>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId(), Col::wx:colour()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer(), Col::wx:colour()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetitemtextcolour">external documentation</a>. -setItemTextColour(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef},Col) - when tuple_size(Col) =:= 3; tuple_size(Col) =:= 4 -> +setItemTextColour(#wx_ref{type=ThisT,ref=ThisRef},Item,Col) + when is_integer(Item),tuple_size(Col) =:= 3; tuple_size(Col) =:= 4 -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_SetItemTextColour, - <<ThisRef:32/?UI,ItemRef:32/?UI,(wxe_util:colour_bin(Col)):16/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI,(wxe_util:colour_bin(Col)):16/binary>>). %% @spec (This::wxTreeCtrl(), ImageList::wxImageList:wxImageList()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsetstateimagelist">external documentation</a>. @@ -735,26 +753,29 @@ setWindowStyle(#wx_ref{type=ThisT,ref=ThisRef},Styles) wxe_util:cast(?wxTreeCtrl_SetWindowStyle, <<ThisRef:32/?UI,Styles:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlsortchildren">external documentation</a>. -sortChildren(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +sortChildren(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_SortChildren, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrltoggle">external documentation</a>. -toggle(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +toggle(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_Toggle, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrltoggleitemselection">external documentation</a>. -toggleItemSelection(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +toggleItemSelection(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_ToggleItemSelection, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). %% @spec (This::wxTreeCtrl()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlunselect">external documentation</a>. @@ -770,12 +791,13 @@ unselectAll(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:cast(?wxTreeCtrl_UnselectAll, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeCtrl(), Item::wxTreeItemId()) -> ok +%% @spec (This::wxTreeCtrl(), Item::integer()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlunselectitem">external documentation</a>. -unselectItem(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=wxTreeItemId,ref=ItemRef}) -> +unselectItem(#wx_ref{type=ThisT,ref=ThisRef},Item) + when is_integer(Item) -> ?CLASS(ThisT,wxTreeCtrl), wxe_util:cast(?wxTreeCtrl_UnselectItem, - <<ThisRef:32/?UI,ItemRef:32/?UI>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI>>). %% @spec (This::wxTreeCtrl()) -> ok %% @doc Destroys this object, do not use object again diff --git a/lib/wx/src/gen/wxTreeEvent.erl b/lib/wx/src/gen/wxTreeEvent.erl index 3f20e79b22..11e442b0f3 100644 --- a/lib/wx/src/gen/wxTreeEvent.erl +++ b/lib/wx/src/gen/wxTreeEvent.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% This file is generated DO NOT EDIT @@ -55,7 +55,7 @@ getKeyCode(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:call(?wxTreeEvent_GetKeyCode, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeEvent()) -> wxTreeItemId() +%% @spec (This::wxTreeEvent()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreeevent.html#wxtreeeventgetitem">external documentation</a>. getItem(#wx_ref{type=ThisT,ref=ThisRef}) -> ?CLASS(ThisT,wxTreeEvent), @@ -76,7 +76,7 @@ getLabel(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:call(?wxTreeEvent_GetLabel, <<ThisRef:32/?UI>>). -%% @spec (This::wxTreeEvent()) -> wxTreeItemId() +%% @spec (This::wxTreeEvent()) -> integer() %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreeevent.html#wxtreeeventgetolditem">external documentation</a>. getOldItem(#wx_ref{type=ThisT,ref=ThisRef}) -> ?CLASS(ThisT,wxTreeEvent), diff --git a/lib/wx/src/gen/wxe_debug.hrl b/lib/wx/src/gen/wxe_debug.hrl index 11f5b9e781..c325170dbb 100644 --- a/lib/wx/src/gen/wxe_debug.hrl +++ b/lib/wx/src/gen/wxe_debug.hrl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% This file is generated DO NOT EDIT @@ -1842,1438 +1842,1439 @@ wxdebug_table() -> {2015, {wxTreeCtrl, getChildrenCount, 2}}, {2016, {wxTreeCtrl, getCount, 0}}, {2017, {wxTreeCtrl, getEditControl, 0}}, - {2018, {wxTreeCtrl, getFirstVisibleItem, 0}}, - {2019, {wxTreeCtrl, getImageList, 0}}, - {2020, {wxTreeCtrl, getIndent, 0}}, - {2021, {wxTreeCtrl, getItemBackgroundColour, 1}}, - {2022, {wxTreeCtrl, getItemData, 1}}, - {2023, {wxTreeCtrl, getItemFont, 1}}, - {2024, {wxTreeCtrl, getItemImage_1, 1}}, - {2025, {wxTreeCtrl, getItemImage_2, 2}}, - {2026, {wxTreeCtrl, getItemText, 1}}, - {2027, {wxTreeCtrl, getItemTextColour, 1}}, - {2028, {wxTreeCtrl, getLastChild, 1}}, - {2029, {wxTreeCtrl, getNextSibling, 1}}, - {2030, {wxTreeCtrl, getNextVisible, 1}}, - {2031, {wxTreeCtrl, getItemParent, 1}}, - {2032, {wxTreeCtrl, getPrevSibling, 1}}, - {2033, {wxTreeCtrl, getPrevVisible, 1}}, - {2034, {wxTreeCtrl, getRootItem, 0}}, - {2035, {wxTreeCtrl, getSelection, 0}}, - {2036, {wxTreeCtrl, getSelections, 1}}, - {2037, {wxTreeCtrl, getStateImageList, 0}}, - {2038, {wxTreeCtrl, hitTest, 1}}, - {2039, {wxTreeCtrl, insertItem_4_1, 4}}, - {2040, {wxTreeCtrl, insertItem_4_0, 4}}, - {2041, {wxTreeCtrl, isBold, 1}}, - {2042, {wxTreeCtrl, isExpanded, 1}}, - {2043, {wxTreeCtrl, isSelected, 1}}, - {2044, {wxTreeCtrl, isVisible, 1}}, - {2045, {wxTreeCtrl, itemHasChildren, 1}}, - {2046, {wxTreeCtrl, prependItem, 3}}, - {2047, {wxTreeCtrl, scrollTo, 1}}, - {2048, {wxTreeCtrl, selectItem_1, 1}}, - {2049, {wxTreeCtrl, selectItem_2, 2}}, - {2050, {wxTreeCtrl, setIndent, 1}}, - {2051, {wxTreeCtrl, setImageList, 1}}, - {2052, {wxTreeCtrl, setItemBackgroundColour, 2}}, - {2053, {wxTreeCtrl, setItemBold, 2}}, - {2054, {wxTreeCtrl, setItemData, 2}}, - {2055, {wxTreeCtrl, setItemDropHighlight, 2}}, - {2056, {wxTreeCtrl, setItemFont, 2}}, - {2057, {wxTreeCtrl, setItemHasChildren, 2}}, - {2058, {wxTreeCtrl, setItemImage_2, 2}}, - {2059, {wxTreeCtrl, setItemImage_3, 3}}, - {2060, {wxTreeCtrl, setItemText, 2}}, - {2061, {wxTreeCtrl, setItemTextColour, 2}}, - {2062, {wxTreeCtrl, setStateImageList, 1}}, - {2063, {wxTreeCtrl, setWindowStyle, 1}}, - {2064, {wxTreeCtrl, sortChildren, 1}}, - {2065, {wxTreeCtrl, toggle, 1}}, - {2066, {wxTreeCtrl, toggleItemSelection, 1}}, - {2067, {wxTreeCtrl, unselect, 0}}, - {2068, {wxTreeCtrl, unselectAll, 0}}, - {2069, {wxTreeCtrl, unselectItem, 1}}, - {2070, {wxScrollBar, new_0, 0}}, - {2071, {wxScrollBar, new_3, 3}}, - {2072, {wxScrollBar, destruct, 0}}, - {2073, {wxScrollBar, create, 3}}, - {2074, {wxScrollBar, getRange, 0}}, - {2075, {wxScrollBar, getPageSize, 0}}, - {2076, {wxScrollBar, getThumbPosition, 0}}, - {2077, {wxScrollBar, getThumbSize, 0}}, - {2078, {wxScrollBar, setThumbPosition, 1}}, - {2079, {wxScrollBar, setScrollbar, 5}}, - {2081, {wxSpinButton, new_2, 2}}, - {2082, {wxSpinButton, new_0, 0}}, - {2083, {wxSpinButton, create, 2}}, - {2084, {wxSpinButton, getMax, 0}}, - {2085, {wxSpinButton, getMin, 0}}, - {2086, {wxSpinButton, getValue, 0}}, - {2087, {wxSpinButton, setRange, 2}}, - {2088, {wxSpinButton, setValue, 1}}, - {2089, {wxSpinButton, 'Destroy', undefined}}, - {2090, {wxSpinCtrl, new_0, 0}}, - {2091, {wxSpinCtrl, new_2, 2}}, - {2093, {wxSpinCtrl, create, 2}}, - {2096, {wxSpinCtrl, setValue_1_1, 1}}, - {2097, {wxSpinCtrl, setValue_1_0, 1}}, - {2099, {wxSpinCtrl, getValue, 0}}, - {2101, {wxSpinCtrl, setRange, 2}}, - {2102, {wxSpinCtrl, setSelection, 2}}, - {2104, {wxSpinCtrl, getMin, 0}}, - {2106, {wxSpinCtrl, getMax, 0}}, - {2107, {wxSpinCtrl, 'Destroy', undefined}}, - {2108, {wxStaticText, new_0, 0}}, - {2109, {wxStaticText, new_4, 4}}, - {2110, {wxStaticText, create, 4}}, - {2111, {wxStaticText, getLabel, 0}}, - {2112, {wxStaticText, setLabel, 1}}, - {2113, {wxStaticText, wrap, 1}}, - {2114, {wxStaticText, 'Destroy', undefined}}, - {2115, {wxStaticBitmap, new_0, 0}}, - {2116, {wxStaticBitmap, new_4, 4}}, - {2117, {wxStaticBitmap, create, 4}}, - {2118, {wxStaticBitmap, getBitmap, 0}}, - {2119, {wxStaticBitmap, setBitmap, 1}}, - {2120, {wxStaticBitmap, 'Destroy', undefined}}, - {2121, {wxRadioBox, new, 7}}, - {2123, {wxRadioBox, destruct, 0}}, - {2124, {wxRadioBox, create, 7}}, - {2125, {wxRadioBox, enable_2, 2}}, - {2126, {wxRadioBox, enable_1, 1}}, - {2127, {wxRadioBox, getSelection, 0}}, - {2128, {wxRadioBox, getString, 1}}, - {2129, {wxRadioBox, setSelection, 1}}, - {2130, {wxRadioBox, show_2, 2}}, - {2131, {wxRadioBox, show_1, 1}}, - {2132, {wxRadioBox, getColumnCount, 0}}, - {2133, {wxRadioBox, getItemHelpText, 1}}, - {2134, {wxRadioBox, getItemToolTip, 1}}, - {2136, {wxRadioBox, getItemFromPoint, 1}}, - {2137, {wxRadioBox, getRowCount, 0}}, - {2138, {wxRadioBox, isItemEnabled, 1}}, - {2139, {wxRadioBox, isItemShown, 1}}, - {2140, {wxRadioBox, setItemHelpText, 2}}, - {2141, {wxRadioBox, setItemToolTip, 2}}, - {2142, {wxRadioButton, new_0, 0}}, - {2143, {wxRadioButton, new_4, 4}}, - {2144, {wxRadioButton, create, 4}}, - {2145, {wxRadioButton, getValue, 0}}, - {2146, {wxRadioButton, setValue, 1}}, - {2147, {wxRadioButton, 'Destroy', undefined}}, - {2149, {wxSlider, new_6, 6}}, - {2150, {wxSlider, new_0, 0}}, - {2151, {wxSlider, create, 6}}, - {2152, {wxSlider, getLineSize, 0}}, - {2153, {wxSlider, getMax, 0}}, - {2154, {wxSlider, getMin, 0}}, - {2155, {wxSlider, getPageSize, 0}}, - {2156, {wxSlider, getThumbLength, 0}}, - {2157, {wxSlider, getValue, 0}}, - {2158, {wxSlider, setLineSize, 1}}, - {2159, {wxSlider, setPageSize, 1}}, - {2160, {wxSlider, setRange, 2}}, - {2161, {wxSlider, setThumbLength, 1}}, - {2162, {wxSlider, setValue, 1}}, - {2163, {wxSlider, 'Destroy', undefined}}, - {2165, {wxDialog, new_4, 4}}, - {2166, {wxDialog, new_0, 0}}, - {2168, {wxDialog, destruct, 0}}, - {2169, {wxDialog, create, 4}}, - {2170, {wxDialog, createButtonSizer, 1}}, - {2171, {wxDialog, createStdDialogButtonSizer, 1}}, - {2172, {wxDialog, endModal, 1}}, - {2173, {wxDialog, getAffirmativeId, 0}}, - {2174, {wxDialog, getReturnCode, 0}}, - {2175, {wxDialog, isModal, 0}}, - {2176, {wxDialog, setAffirmativeId, 1}}, - {2177, {wxDialog, setReturnCode, 1}}, - {2178, {wxDialog, show, 1}}, - {2179, {wxDialog, showModal, 0}}, - {2180, {wxColourDialog, new_0, 0}}, - {2181, {wxColourDialog, new_2, 2}}, - {2182, {wxColourDialog, destruct, 0}}, - {2183, {wxColourDialog, create, 2}}, - {2184, {wxColourDialog, getColourData, 0}}, - {2185, {wxColourData, new_0, 0}}, - {2186, {wxColourData, new_1, 1}}, - {2187, {wxColourData, destruct, 0}}, - {2188, {wxColourData, getChooseFull, 0}}, - {2189, {wxColourData, getColour, 0}}, - {2191, {wxColourData, getCustomColour, 1}}, - {2192, {wxColourData, setChooseFull, 1}}, - {2193, {wxColourData, setColour, 1}}, - {2194, {wxColourData, setCustomColour, 2}}, - {2195, {wxPalette, new_0, 0}}, - {2196, {wxPalette, new_4, 4}}, - {2198, {wxPalette, destruct, 0}}, - {2199, {wxPalette, create, 4}}, - {2200, {wxPalette, getColoursCount, 0}}, - {2201, {wxPalette, getPixel, 3}}, - {2202, {wxPalette, getRGB, 4}}, - {2203, {wxPalette, isOk, 0}}, - {2207, {wxDirDialog, new, 2}}, - {2208, {wxDirDialog, destruct, 0}}, - {2209, {wxDirDialog, getPath, 0}}, - {2210, {wxDirDialog, getMessage, 0}}, - {2211, {wxDirDialog, setMessage, 1}}, - {2212, {wxDirDialog, setPath, 1}}, - {2216, {wxFileDialog, new, 2}}, - {2217, {wxFileDialog, destruct, 0}}, - {2218, {wxFileDialog, getDirectory, 0}}, - {2219, {wxFileDialog, getFilename, 0}}, - {2220, {wxFileDialog, getFilenames, 1}}, - {2221, {wxFileDialog, getFilterIndex, 0}}, - {2222, {wxFileDialog, getMessage, 0}}, - {2223, {wxFileDialog, getPath, 0}}, - {2224, {wxFileDialog, getPaths, 1}}, - {2225, {wxFileDialog, getWildcard, 0}}, - {2226, {wxFileDialog, setDirectory, 1}}, - {2227, {wxFileDialog, setFilename, 1}}, - {2228, {wxFileDialog, setFilterIndex, 1}}, - {2229, {wxFileDialog, setMessage, 1}}, - {2230, {wxFileDialog, setPath, 1}}, - {2231, {wxFileDialog, setWildcard, 1}}, - {2232, {wxPickerBase, setInternalMargin, 1}}, - {2233, {wxPickerBase, getInternalMargin, 0}}, - {2234, {wxPickerBase, setTextCtrlProportion, 1}}, - {2235, {wxPickerBase, setPickerCtrlProportion, 1}}, - {2236, {wxPickerBase, getTextCtrlProportion, 0}}, - {2237, {wxPickerBase, getPickerCtrlProportion, 0}}, - {2238, {wxPickerBase, hasTextCtrl, 0}}, - {2239, {wxPickerBase, getTextCtrl, 0}}, - {2240, {wxPickerBase, isTextCtrlGrowable, 0}}, - {2241, {wxPickerBase, setPickerCtrlGrowable, 1}}, - {2242, {wxPickerBase, setTextCtrlGrowable, 1}}, - {2243, {wxPickerBase, isPickerCtrlGrowable, 0}}, - {2244, {wxFilePickerCtrl, new_0, 0}}, - {2245, {wxFilePickerCtrl, new_3, 3}}, - {2246, {wxFilePickerCtrl, create, 3}}, - {2247, {wxFilePickerCtrl, getPath, 0}}, - {2248, {wxFilePickerCtrl, setPath, 1}}, - {2249, {wxFilePickerCtrl, 'Destroy', undefined}}, - {2250, {wxDirPickerCtrl, new_0, 0}}, - {2251, {wxDirPickerCtrl, new_3, 3}}, - {2252, {wxDirPickerCtrl, create, 3}}, - {2253, {wxDirPickerCtrl, getPath, 0}}, - {2254, {wxDirPickerCtrl, setPath, 1}}, - {2255, {wxDirPickerCtrl, 'Destroy', undefined}}, - {2256, {wxColourPickerCtrl, new_0, 0}}, - {2257, {wxColourPickerCtrl, new_3, 3}}, - {2258, {wxColourPickerCtrl, create, 3}}, - {2259, {wxColourPickerCtrl, getColour, 0}}, - {2260, {wxColourPickerCtrl, setColour_1_1, 1}}, - {2261, {wxColourPickerCtrl, setColour_1_0, 1}}, - {2262, {wxColourPickerCtrl, 'Destroy', undefined}}, - {2263, {wxDatePickerCtrl, new_0, 0}}, - {2264, {wxDatePickerCtrl, new_3, 3}}, - {2265, {wxDatePickerCtrl, getRange, 2}}, - {2266, {wxDatePickerCtrl, getValue, 0}}, - {2267, {wxDatePickerCtrl, setRange, 2}}, - {2268, {wxDatePickerCtrl, setValue, 1}}, - {2269, {wxDatePickerCtrl, 'Destroy', undefined}}, - {2270, {wxFontPickerCtrl, new_0, 0}}, - {2271, {wxFontPickerCtrl, new_3, 3}}, - {2272, {wxFontPickerCtrl, create, 3}}, - {2273, {wxFontPickerCtrl, getSelectedFont, 0}}, - {2274, {wxFontPickerCtrl, setSelectedFont, 1}}, - {2275, {wxFontPickerCtrl, getMaxPointSize, 0}}, - {2276, {wxFontPickerCtrl, setMaxPointSize, 1}}, - {2277, {wxFontPickerCtrl, 'Destroy', undefined}}, - {2280, {wxFindReplaceDialog, new_0, 0}}, - {2281, {wxFindReplaceDialog, new_4, 4}}, - {2282, {wxFindReplaceDialog, destruct, 0}}, - {2283, {wxFindReplaceDialog, create, 4}}, - {2284, {wxFindReplaceDialog, getData, 0}}, - {2285, {wxFindReplaceData, new_0, 0}}, - {2286, {wxFindReplaceData, new_1, 1}}, - {2287, {wxFindReplaceData, getFindString, 0}}, - {2288, {wxFindReplaceData, getReplaceString, 0}}, - {2289, {wxFindReplaceData, getFlags, 0}}, - {2290, {wxFindReplaceData, setFlags, 1}}, - {2291, {wxFindReplaceData, setFindString, 1}}, - {2292, {wxFindReplaceData, setReplaceString, 1}}, - {2293, {wxFindReplaceData, 'Destroy', undefined}}, - {2294, {wxMultiChoiceDialog, new_0, 0}}, - {2296, {wxMultiChoiceDialog, new_5, 5}}, - {2297, {wxMultiChoiceDialog, getSelections, 0}}, - {2298, {wxMultiChoiceDialog, setSelections, 1}}, - {2299, {wxMultiChoiceDialog, 'Destroy', undefined}}, - {2300, {wxSingleChoiceDialog, new_0, 0}}, - {2302, {wxSingleChoiceDialog, new_5, 5}}, - {2303, {wxSingleChoiceDialog, getSelection, 0}}, - {2304, {wxSingleChoiceDialog, getStringSelection, 0}}, - {2305, {wxSingleChoiceDialog, setSelection, 1}}, - {2306, {wxSingleChoiceDialog, 'Destroy', undefined}}, - {2307, {wxTextEntryDialog, new, 3}}, - {2308, {wxTextEntryDialog, getValue, 0}}, - {2309, {wxTextEntryDialog, setValue, 1}}, - {2310, {wxTextEntryDialog, 'Destroy', undefined}}, - {2311, {wxPasswordEntryDialog, new, 3}}, - {2312, {wxPasswordEntryDialog, 'Destroy', undefined}}, - {2313, {wxFontData, new_0, 0}}, - {2314, {wxFontData, new_1, 1}}, - {2315, {wxFontData, destruct, 0}}, - {2316, {wxFontData, enableEffects, 1}}, - {2317, {wxFontData, getAllowSymbols, 0}}, - {2318, {wxFontData, getColour, 0}}, - {2319, {wxFontData, getChosenFont, 0}}, - {2320, {wxFontData, getEnableEffects, 0}}, - {2321, {wxFontData, getInitialFont, 0}}, - {2322, {wxFontData, getShowHelp, 0}}, - {2323, {wxFontData, setAllowSymbols, 1}}, - {2324, {wxFontData, setChosenFont, 1}}, - {2325, {wxFontData, setColour, 1}}, - {2326, {wxFontData, setInitialFont, 1}}, - {2327, {wxFontData, setRange, 2}}, - {2328, {wxFontData, setShowHelp, 1}}, - {2332, {wxFontDialog, new_0, 0}}, - {2334, {wxFontDialog, new_2, 2}}, - {2336, {wxFontDialog, create, 2}}, - {2337, {wxFontDialog, getFontData, 0}}, - {2339, {wxFontDialog, 'Destroy', undefined}}, - {2340, {wxProgressDialog, new, 3}}, - {2341, {wxProgressDialog, destruct, 0}}, - {2342, {wxProgressDialog, resume, 0}}, - {2343, {wxProgressDialog, update_2, 2}}, - {2344, {wxProgressDialog, update_0, 0}}, - {2345, {wxMessageDialog, new, 3}}, - {2346, {wxMessageDialog, destruct, 0}}, - {2347, {wxPageSetupDialog, new, 2}}, - {2348, {wxPageSetupDialog, destruct, 0}}, - {2349, {wxPageSetupDialog, getPageSetupData, 0}}, - {2350, {wxPageSetupDialog, showModal, 0}}, - {2351, {wxPageSetupDialogData, new_0, 0}}, - {2352, {wxPageSetupDialogData, new_1_0, 1}}, - {2353, {wxPageSetupDialogData, new_1_1, 1}}, - {2354, {wxPageSetupDialogData, destruct, 0}}, - {2355, {wxPageSetupDialogData, enableHelp, 1}}, - {2356, {wxPageSetupDialogData, enableMargins, 1}}, - {2357, {wxPageSetupDialogData, enableOrientation, 1}}, - {2358, {wxPageSetupDialogData, enablePaper, 1}}, - {2359, {wxPageSetupDialogData, enablePrinter, 1}}, - {2360, {wxPageSetupDialogData, getDefaultMinMargins, 0}}, - {2361, {wxPageSetupDialogData, getEnableMargins, 0}}, - {2362, {wxPageSetupDialogData, getEnableOrientation, 0}}, - {2363, {wxPageSetupDialogData, getEnablePaper, 0}}, - {2364, {wxPageSetupDialogData, getEnablePrinter, 0}}, - {2365, {wxPageSetupDialogData, getEnableHelp, 0}}, - {2366, {wxPageSetupDialogData, getDefaultInfo, 0}}, - {2367, {wxPageSetupDialogData, getMarginTopLeft, 0}}, - {2368, {wxPageSetupDialogData, getMarginBottomRight, 0}}, - {2369, {wxPageSetupDialogData, getMinMarginTopLeft, 0}}, - {2370, {wxPageSetupDialogData, getMinMarginBottomRight, 0}}, - {2371, {wxPageSetupDialogData, getPaperId, 0}}, - {2372, {wxPageSetupDialogData, getPaperSize, 0}}, - {2374, {wxPageSetupDialogData, getPrintData, 0}}, - {2375, {wxPageSetupDialogData, isOk, 0}}, - {2376, {wxPageSetupDialogData, setDefaultInfo, 1}}, - {2377, {wxPageSetupDialogData, setDefaultMinMargins, 1}}, - {2378, {wxPageSetupDialogData, setMarginTopLeft, 1}}, - {2379, {wxPageSetupDialogData, setMarginBottomRight, 1}}, - {2380, {wxPageSetupDialogData, setMinMarginTopLeft, 1}}, - {2381, {wxPageSetupDialogData, setMinMarginBottomRight, 1}}, - {2382, {wxPageSetupDialogData, setPaperId, 1}}, - {2383, {wxPageSetupDialogData, setPaperSize_1_1, 1}}, - {2384, {wxPageSetupDialogData, setPaperSize_1_0, 1}}, - {2385, {wxPageSetupDialogData, setPrintData, 1}}, - {2386, {wxPrintDialog, new_2_0, 2}}, - {2387, {wxPrintDialog, new_2_1, 2}}, - {2388, {wxPrintDialog, destruct, 0}}, - {2389, {wxPrintDialog, getPrintDialogData, 0}}, - {2390, {wxPrintDialog, getPrintDC, 0}}, - {2391, {wxPrintDialogData, new_0, 0}}, - {2392, {wxPrintDialogData, new_1_1, 1}}, - {2393, {wxPrintDialogData, new_1_0, 1}}, - {2394, {wxPrintDialogData, destruct, 0}}, - {2395, {wxPrintDialogData, enableHelp, 1}}, - {2396, {wxPrintDialogData, enablePageNumbers, 1}}, - {2397, {wxPrintDialogData, enablePrintToFile, 1}}, - {2398, {wxPrintDialogData, enableSelection, 1}}, - {2399, {wxPrintDialogData, getAllPages, 0}}, - {2400, {wxPrintDialogData, getCollate, 0}}, - {2401, {wxPrintDialogData, getFromPage, 0}}, - {2402, {wxPrintDialogData, getMaxPage, 0}}, - {2403, {wxPrintDialogData, getMinPage, 0}}, - {2404, {wxPrintDialogData, getNoCopies, 0}}, - {2405, {wxPrintDialogData, getPrintData, 0}}, - {2406, {wxPrintDialogData, getPrintToFile, 0}}, - {2407, {wxPrintDialogData, getSelection, 0}}, - {2408, {wxPrintDialogData, getToPage, 0}}, - {2409, {wxPrintDialogData, isOk, 0}}, - {2410, {wxPrintDialogData, setCollate, 1}}, - {2411, {wxPrintDialogData, setFromPage, 1}}, - {2412, {wxPrintDialogData, setMaxPage, 1}}, - {2413, {wxPrintDialogData, setMinPage, 1}}, - {2414, {wxPrintDialogData, setNoCopies, 1}}, - {2415, {wxPrintDialogData, setPrintData, 1}}, - {2416, {wxPrintDialogData, setPrintToFile, 1}}, - {2417, {wxPrintDialogData, setSelection, 1}}, - {2418, {wxPrintDialogData, setToPage, 1}}, - {2419, {wxPrintData, new_0, 0}}, - {2420, {wxPrintData, new_1, 1}}, - {2421, {wxPrintData, destruct, 0}}, - {2422, {wxPrintData, getCollate, 0}}, - {2423, {wxPrintData, getBin, 0}}, - {2424, {wxPrintData, getColour, 0}}, - {2425, {wxPrintData, getDuplex, 0}}, - {2426, {wxPrintData, getNoCopies, 0}}, - {2427, {wxPrintData, getOrientation, 0}}, - {2428, {wxPrintData, getPaperId, 0}}, - {2429, {wxPrintData, getPrinterName, 0}}, - {2430, {wxPrintData, getQuality, 0}}, - {2431, {wxPrintData, isOk, 0}}, - {2432, {wxPrintData, setBin, 1}}, - {2433, {wxPrintData, setCollate, 1}}, - {2434, {wxPrintData, setColour, 1}}, - {2435, {wxPrintData, setDuplex, 1}}, - {2436, {wxPrintData, setNoCopies, 1}}, - {2437, {wxPrintData, setOrientation, 1}}, - {2438, {wxPrintData, setPaperId, 1}}, - {2439, {wxPrintData, setPrinterName, 1}}, - {2440, {wxPrintData, setQuality, 1}}, - {2443, {wxPrintPreview, new_2, 2}}, - {2444, {wxPrintPreview, new_3, 3}}, - {2446, {wxPrintPreview, destruct, 0}}, - {2447, {wxPrintPreview, getCanvas, 0}}, - {2448, {wxPrintPreview, getCurrentPage, 0}}, - {2449, {wxPrintPreview, getFrame, 0}}, - {2450, {wxPrintPreview, getMaxPage, 0}}, - {2451, {wxPrintPreview, getMinPage, 0}}, - {2452, {wxPrintPreview, getPrintout, 0}}, - {2453, {wxPrintPreview, getPrintoutForPrinting, 0}}, - {2454, {wxPrintPreview, isOk, 0}}, - {2455, {wxPrintPreview, paintPage, 2}}, - {2456, {wxPrintPreview, print, 1}}, - {2457, {wxPrintPreview, renderPage, 1}}, - {2458, {wxPrintPreview, setCanvas, 1}}, - {2459, {wxPrintPreview, setCurrentPage, 1}}, - {2460, {wxPrintPreview, setFrame, 1}}, - {2461, {wxPrintPreview, setPrintout, 1}}, - {2462, {wxPrintPreview, setZoom, 1}}, - {2463, {wxPreviewFrame, new, 3}}, - {2464, {wxPreviewFrame, destruct, 0}}, - {2465, {wxPreviewFrame, createControlBar, 0}}, - {2466, {wxPreviewFrame, createCanvas, 0}}, - {2467, {wxPreviewFrame, initialize, 0}}, - {2468, {wxPreviewFrame, onCloseWindow, 1}}, - {2469, {wxPreviewControlBar, new, 4}}, - {2470, {wxPreviewControlBar, destruct, 0}}, - {2471, {wxPreviewControlBar, createButtons, 0}}, - {2472, {wxPreviewControlBar, getPrintPreview, 0}}, - {2473, {wxPreviewControlBar, getZoomControl, 0}}, - {2474, {wxPreviewControlBar, setZoomControl, 1}}, - {2476, {wxPrinter, new, 1}}, - {2477, {wxPrinter, createAbortWindow, 2}}, - {2478, {wxPrinter, getAbort, 0}}, - {2479, {wxPrinter, getLastError, 0}}, - {2480, {wxPrinter, getPrintDialogData, 0}}, - {2481, {wxPrinter, print, 3}}, - {2482, {wxPrinter, printDialog, 1}}, - {2483, {wxPrinter, reportError, 3}}, - {2484, {wxPrinter, setup, 1}}, - {2485, {wxPrinter, 'Destroy', undefined}}, - {2486, {wxXmlResource, new_1, 1}}, - {2487, {wxXmlResource, new_2, 2}}, - {2488, {wxXmlResource, destruct, 0}}, - {2489, {wxXmlResource, attachUnknownControl, 3}}, - {2490, {wxXmlResource, clearHandlers, 0}}, - {2491, {wxXmlResource, compareVersion, 4}}, - {2492, {wxXmlResource, get, 0}}, - {2493, {wxXmlResource, getFlags, 0}}, - {2494, {wxXmlResource, getVersion, 0}}, - {2495, {wxXmlResource, getXRCID, 2}}, - {2496, {wxXmlResource, initAllHandlers, 0}}, - {2497, {wxXmlResource, load, 1}}, - {2498, {wxXmlResource, loadBitmap, 1}}, - {2499, {wxXmlResource, loadDialog_2, 2}}, - {2500, {wxXmlResource, loadDialog_3, 3}}, - {2501, {wxXmlResource, loadFrame_2, 2}}, - {2502, {wxXmlResource, loadFrame_3, 3}}, - {2503, {wxXmlResource, loadIcon, 1}}, - {2504, {wxXmlResource, loadMenu, 1}}, - {2505, {wxXmlResource, loadMenuBar_2, 2}}, - {2506, {wxXmlResource, loadMenuBar_1, 1}}, - {2507, {wxXmlResource, loadPanel_2, 2}}, - {2508, {wxXmlResource, loadPanel_3, 3}}, - {2509, {wxXmlResource, loadToolBar, 2}}, - {2510, {wxXmlResource, set, 1}}, - {2511, {wxXmlResource, setFlags, 1}}, - {2512, {wxXmlResource, unload, 1}}, - {2513, {wxXmlResource, xrcctrl, 3}}, - {2514, {wxHtmlEasyPrinting, new, 1}}, - {2515, {wxHtmlEasyPrinting, destruct, 0}}, - {2516, {wxHtmlEasyPrinting, getPrintData, 0}}, - {2517, {wxHtmlEasyPrinting, getPageSetupData, 0}}, - {2518, {wxHtmlEasyPrinting, previewFile, 1}}, - {2519, {wxHtmlEasyPrinting, previewText, 2}}, - {2520, {wxHtmlEasyPrinting, printFile, 1}}, - {2521, {wxHtmlEasyPrinting, printText, 2}}, - {2522, {wxHtmlEasyPrinting, pageSetup, 0}}, - {2523, {wxHtmlEasyPrinting, setFonts, 3}}, - {2524, {wxHtmlEasyPrinting, setHeader, 2}}, - {2525, {wxHtmlEasyPrinting, setFooter, 2}}, - {2527, {wxGLCanvas, new_2, 2}}, - {2528, {wxGLCanvas, new_3_1, 3}}, - {2529, {wxGLCanvas, new_3_0, 3}}, - {2530, {wxGLCanvas, getContext, 0}}, - {2532, {wxGLCanvas, setCurrent, 0}}, - {2533, {wxGLCanvas, swapBuffers, 0}}, - {2534, {wxGLCanvas, 'Destroy', undefined}}, - {2535, {wxAuiManager, new, 1}}, - {2536, {wxAuiManager, destruct, 0}}, - {2537, {wxAuiManager, addPane_2_1, 2}}, - {2538, {wxAuiManager, addPane_3, 3}}, - {2539, {wxAuiManager, addPane_2_0, 2}}, - {2540, {wxAuiManager, detachPane, 1}}, - {2541, {wxAuiManager, getAllPanes, 0}}, - {2542, {wxAuiManager, getArtProvider, 0}}, - {2543, {wxAuiManager, getDockSizeConstraint, 2}}, - {2544, {wxAuiManager, getFlags, 0}}, - {2545, {wxAuiManager, getManagedWindow, 0}}, - {2546, {wxAuiManager, getManager, 1}}, - {2547, {wxAuiManager, getPane_1_1, 1}}, - {2548, {wxAuiManager, getPane_1_0, 1}}, - {2549, {wxAuiManager, hideHint, 0}}, - {2550, {wxAuiManager, insertPane, 3}}, - {2551, {wxAuiManager, loadPaneInfo, 2}}, - {2552, {wxAuiManager, loadPerspective, 2}}, - {2553, {wxAuiManager, savePaneInfo, 1}}, - {2554, {wxAuiManager, savePerspective, 0}}, - {2555, {wxAuiManager, setArtProvider, 1}}, - {2556, {wxAuiManager, setDockSizeConstraint, 2}}, - {2557, {wxAuiManager, setFlags, 1}}, - {2558, {wxAuiManager, setManagedWindow, 1}}, - {2559, {wxAuiManager, showHint, 1}}, - {2560, {wxAuiManager, unInit, 0}}, - {2561, {wxAuiManager, update, 0}}, - {2562, {wxAuiPaneInfo, new_0, 0}}, - {2563, {wxAuiPaneInfo, new_1, 1}}, - {2564, {wxAuiPaneInfo, destruct, 0}}, - {2565, {wxAuiPaneInfo, bestSize_1, 1}}, - {2566, {wxAuiPaneInfo, bestSize_2, 2}}, - {2567, {wxAuiPaneInfo, bottom, 0}}, - {2568, {wxAuiPaneInfo, bottomDockable, 1}}, - {2569, {wxAuiPaneInfo, caption, 1}}, - {2570, {wxAuiPaneInfo, captionVisible, 1}}, - {2571, {wxAuiPaneInfo, centre, 0}}, - {2572, {wxAuiPaneInfo, centrePane, 0}}, - {2573, {wxAuiPaneInfo, closeButton, 1}}, - {2574, {wxAuiPaneInfo, defaultPane, 0}}, - {2575, {wxAuiPaneInfo, destroyOnClose, 1}}, - {2576, {wxAuiPaneInfo, direction, 1}}, - {2577, {wxAuiPaneInfo, dock, 0}}, - {2578, {wxAuiPaneInfo, dockable, 1}}, - {2579, {wxAuiPaneInfo, fixed, 0}}, - {2580, {wxAuiPaneInfo, float, 0}}, - {2581, {wxAuiPaneInfo, floatable, 1}}, - {2582, {wxAuiPaneInfo, floatingPosition_1, 1}}, - {2583, {wxAuiPaneInfo, floatingPosition_2, 2}}, - {2584, {wxAuiPaneInfo, floatingSize_1, 1}}, - {2585, {wxAuiPaneInfo, floatingSize_2, 2}}, - {2586, {wxAuiPaneInfo, gripper, 1}}, - {2587, {wxAuiPaneInfo, gripperTop, 1}}, - {2588, {wxAuiPaneInfo, hasBorder, 0}}, - {2589, {wxAuiPaneInfo, hasCaption, 0}}, - {2590, {wxAuiPaneInfo, hasCloseButton, 0}}, - {2591, {wxAuiPaneInfo, hasFlag, 1}}, - {2592, {wxAuiPaneInfo, hasGripper, 0}}, - {2593, {wxAuiPaneInfo, hasGripperTop, 0}}, - {2594, {wxAuiPaneInfo, hasMaximizeButton, 0}}, - {2595, {wxAuiPaneInfo, hasMinimizeButton, 0}}, - {2596, {wxAuiPaneInfo, hasPinButton, 0}}, - {2597, {wxAuiPaneInfo, hide, 0}}, - {2598, {wxAuiPaneInfo, isBottomDockable, 0}}, - {2599, {wxAuiPaneInfo, isDocked, 0}}, - {2600, {wxAuiPaneInfo, isFixed, 0}}, - {2601, {wxAuiPaneInfo, isFloatable, 0}}, - {2602, {wxAuiPaneInfo, isFloating, 0}}, - {2603, {wxAuiPaneInfo, isLeftDockable, 0}}, - {2604, {wxAuiPaneInfo, isMovable, 0}}, - {2605, {wxAuiPaneInfo, isOk, 0}}, - {2606, {wxAuiPaneInfo, isResizable, 0}}, - {2607, {wxAuiPaneInfo, isRightDockable, 0}}, - {2608, {wxAuiPaneInfo, isShown, 0}}, - {2609, {wxAuiPaneInfo, isToolbar, 0}}, - {2610, {wxAuiPaneInfo, isTopDockable, 0}}, - {2611, {wxAuiPaneInfo, layer, 1}}, - {2612, {wxAuiPaneInfo, left, 0}}, - {2613, {wxAuiPaneInfo, leftDockable, 1}}, - {2614, {wxAuiPaneInfo, maxSize_1, 1}}, - {2615, {wxAuiPaneInfo, maxSize_2, 2}}, - {2616, {wxAuiPaneInfo, maximizeButton, 1}}, - {2617, {wxAuiPaneInfo, minSize_1, 1}}, - {2618, {wxAuiPaneInfo, minSize_2, 2}}, - {2619, {wxAuiPaneInfo, minimizeButton, 1}}, - {2620, {wxAuiPaneInfo, movable, 1}}, - {2621, {wxAuiPaneInfo, name, 1}}, - {2622, {wxAuiPaneInfo, paneBorder, 1}}, - {2623, {wxAuiPaneInfo, pinButton, 1}}, - {2624, {wxAuiPaneInfo, position, 1}}, - {2625, {wxAuiPaneInfo, resizable, 1}}, - {2626, {wxAuiPaneInfo, right, 0}}, - {2627, {wxAuiPaneInfo, rightDockable, 1}}, - {2628, {wxAuiPaneInfo, row, 1}}, - {2629, {wxAuiPaneInfo, safeSet, 1}}, - {2630, {wxAuiPaneInfo, setFlag, 2}}, - {2631, {wxAuiPaneInfo, show, 1}}, - {2632, {wxAuiPaneInfo, toolbarPane, 0}}, - {2633, {wxAuiPaneInfo, top, 0}}, - {2634, {wxAuiPaneInfo, topDockable, 1}}, - {2635, {wxAuiPaneInfo, window, 1}}, - {2636, {wxAuiNotebook, new_0, 0}}, - {2637, {wxAuiNotebook, new_2, 2}}, - {2638, {wxAuiNotebook, addPage, 3}}, - {2639, {wxAuiNotebook, create, 2}}, - {2640, {wxAuiNotebook, deletePage, 1}}, - {2641, {wxAuiNotebook, getArtProvider, 0}}, - {2642, {wxAuiNotebook, getPage, 1}}, - {2643, {wxAuiNotebook, getPageBitmap, 1}}, - {2644, {wxAuiNotebook, getPageCount, 0}}, - {2645, {wxAuiNotebook, getPageIndex, 1}}, - {2646, {wxAuiNotebook, getPageText, 1}}, - {2647, {wxAuiNotebook, getSelection, 0}}, - {2648, {wxAuiNotebook, insertPage, 4}}, - {2649, {wxAuiNotebook, removePage, 1}}, - {2650, {wxAuiNotebook, setArtProvider, 1}}, - {2651, {wxAuiNotebook, setFont, 1}}, - {2652, {wxAuiNotebook, setPageBitmap, 2}}, - {2653, {wxAuiNotebook, setPageText, 2}}, - {2654, {wxAuiNotebook, setSelection, 1}}, - {2655, {wxAuiNotebook, setTabCtrlHeight, 1}}, - {2656, {wxAuiNotebook, setUniformBitmapSize, 1}}, - {2657, {wxAuiNotebook, 'Destroy', undefined}}, - {2658, {wxMDIParentFrame, new_0, 0}}, - {2659, {wxMDIParentFrame, new_4, 4}}, - {2660, {wxMDIParentFrame, destruct, 0}}, - {2661, {wxMDIParentFrame, activateNext, 0}}, - {2662, {wxMDIParentFrame, activatePrevious, 0}}, - {2663, {wxMDIParentFrame, arrangeIcons, 0}}, - {2664, {wxMDIParentFrame, cascade, 0}}, - {2665, {wxMDIParentFrame, create, 4}}, - {2666, {wxMDIParentFrame, getActiveChild, 0}}, - {2667, {wxMDIParentFrame, getClientWindow, 0}}, - {2668, {wxMDIParentFrame, tile, 1}}, - {2669, {wxMDIChildFrame, new_0, 0}}, - {2670, {wxMDIChildFrame, new_4, 4}}, - {2671, {wxMDIChildFrame, destruct, 0}}, - {2672, {wxMDIChildFrame, activate, 0}}, - {2673, {wxMDIChildFrame, create, 4}}, - {2674, {wxMDIChildFrame, maximize, 1}}, - {2675, {wxMDIChildFrame, restore, 0}}, - {2676, {wxMDIClientWindow, new_0, 0}}, - {2677, {wxMDIClientWindow, new_2, 2}}, - {2678, {wxMDIClientWindow, destruct, 0}}, - {2679, {wxMDIClientWindow, createClient, 2}}, - {2680, {wxLayoutAlgorithm, new, 0}}, - {2681, {wxLayoutAlgorithm, layoutFrame, 2}}, - {2682, {wxLayoutAlgorithm, layoutMDIFrame, 2}}, - {2683, {wxLayoutAlgorithm, layoutWindow, 2}}, - {2684, {wxLayoutAlgorithm, 'Destroy', undefined}}, - {2685, {wxEvent, getId, 0}}, - {2686, {wxEvent, getSkipped, 0}}, - {2687, {wxEvent, getTimestamp, 0}}, - {2688, {wxEvent, isCommandEvent, 0}}, - {2689, {wxEvent, resumePropagation, 1}}, - {2690, {wxEvent, shouldPropagate, 0}}, - {2691, {wxEvent, skip, 1}}, - {2692, {wxEvent, stopPropagation, 0}}, - {2693, {wxCommandEvent, getClientData, 0}}, - {2694, {wxCommandEvent, getExtraLong, 0}}, - {2695, {wxCommandEvent, getInt, 0}}, - {2696, {wxCommandEvent, getSelection, 0}}, - {2697, {wxCommandEvent, getString, 0}}, - {2698, {wxCommandEvent, isChecked, 0}}, - {2699, {wxCommandEvent, isSelection, 0}}, - {2700, {wxCommandEvent, setInt, 1}}, - {2701, {wxCommandEvent, setString, 1}}, - {2702, {wxScrollEvent, getOrientation, 0}}, - {2703, {wxScrollEvent, getPosition, 0}}, - {2704, {wxScrollWinEvent, getOrientation, 0}}, - {2705, {wxScrollWinEvent, getPosition, 0}}, - {2706, {wxMouseEvent, altDown, 0}}, - {2707, {wxMouseEvent, button, 1}}, - {2708, {wxMouseEvent, buttonDClick, 1}}, - {2709, {wxMouseEvent, buttonDown, 1}}, - {2710, {wxMouseEvent, buttonUp, 1}}, - {2711, {wxMouseEvent, cmdDown, 0}}, - {2712, {wxMouseEvent, controlDown, 0}}, - {2713, {wxMouseEvent, dragging, 0}}, - {2714, {wxMouseEvent, entering, 0}}, - {2715, {wxMouseEvent, getButton, 0}}, - {2718, {wxMouseEvent, getPosition, 0}}, - {2719, {wxMouseEvent, getLogicalPosition, 1}}, - {2720, {wxMouseEvent, getLinesPerAction, 0}}, - {2721, {wxMouseEvent, getWheelRotation, 0}}, - {2722, {wxMouseEvent, getWheelDelta, 0}}, - {2723, {wxMouseEvent, getX, 0}}, - {2724, {wxMouseEvent, getY, 0}}, - {2725, {wxMouseEvent, isButton, 0}}, - {2726, {wxMouseEvent, isPageScroll, 0}}, - {2727, {wxMouseEvent, leaving, 0}}, - {2728, {wxMouseEvent, leftDClick, 0}}, - {2729, {wxMouseEvent, leftDown, 0}}, - {2730, {wxMouseEvent, leftIsDown, 0}}, - {2731, {wxMouseEvent, leftUp, 0}}, - {2732, {wxMouseEvent, metaDown, 0}}, - {2733, {wxMouseEvent, middleDClick, 0}}, - {2734, {wxMouseEvent, middleDown, 0}}, - {2735, {wxMouseEvent, middleIsDown, 0}}, - {2736, {wxMouseEvent, middleUp, 0}}, - {2737, {wxMouseEvent, moving, 0}}, - {2738, {wxMouseEvent, rightDClick, 0}}, - {2739, {wxMouseEvent, rightDown, 0}}, - {2740, {wxMouseEvent, rightIsDown, 0}}, - {2741, {wxMouseEvent, rightUp, 0}}, - {2742, {wxMouseEvent, shiftDown, 0}}, - {2743, {wxSetCursorEvent, getCursor, 0}}, - {2744, {wxSetCursorEvent, getX, 0}}, - {2745, {wxSetCursorEvent, getY, 0}}, - {2746, {wxSetCursorEvent, hasCursor, 0}}, - {2747, {wxSetCursorEvent, setCursor, 1}}, - {2748, {wxKeyEvent, altDown, 0}}, - {2749, {wxKeyEvent, cmdDown, 0}}, - {2750, {wxKeyEvent, controlDown, 0}}, - {2751, {wxKeyEvent, getKeyCode, 0}}, - {2752, {wxKeyEvent, getModifiers, 0}}, - {2755, {wxKeyEvent, getPosition, 0}}, - {2756, {wxKeyEvent, getRawKeyCode, 0}}, - {2757, {wxKeyEvent, getRawKeyFlags, 0}}, - {2758, {wxKeyEvent, getUnicodeKey, 0}}, - {2759, {wxKeyEvent, getX, 0}}, - {2760, {wxKeyEvent, getY, 0}}, - {2761, {wxKeyEvent, hasModifiers, 0}}, - {2762, {wxKeyEvent, metaDown, 0}}, - {2763, {wxKeyEvent, shiftDown, 0}}, - {2764, {wxSizeEvent, getSize, 0}}, - {2765, {wxMoveEvent, getPosition, 0}}, - {2766, {wxEraseEvent, getDC, 0}}, - {2767, {wxFocusEvent, getWindow, 0}}, - {2768, {wxChildFocusEvent, getWindow, 0}}, - {2769, {wxMenuEvent, getMenu, 0}}, - {2770, {wxMenuEvent, getMenuId, 0}}, - {2771, {wxMenuEvent, isPopup, 0}}, - {2772, {wxCloseEvent, canVeto, 0}}, - {2773, {wxCloseEvent, getLoggingOff, 0}}, - {2774, {wxCloseEvent, setCanVeto, 1}}, - {2775, {wxCloseEvent, setLoggingOff, 1}}, - {2776, {wxCloseEvent, veto, 1}}, - {2777, {wxShowEvent, setShow, 1}}, - {2778, {wxShowEvent, getShow, 0}}, - {2779, {wxIconizeEvent, iconized, 0}}, - {2780, {wxJoystickEvent, buttonDown, 1}}, - {2781, {wxJoystickEvent, buttonIsDown, 1}}, - {2782, {wxJoystickEvent, buttonUp, 1}}, - {2783, {wxJoystickEvent, getButtonChange, 0}}, - {2784, {wxJoystickEvent, getButtonState, 0}}, - {2785, {wxJoystickEvent, getJoystick, 0}}, - {2786, {wxJoystickEvent, getPosition, 0}}, - {2787, {wxJoystickEvent, getZPosition, 0}}, - {2788, {wxJoystickEvent, isButton, 0}}, - {2789, {wxJoystickEvent, isMove, 0}}, - {2790, {wxJoystickEvent, isZMove, 0}}, - {2791, {wxUpdateUIEvent, canUpdate, 1}}, - {2792, {wxUpdateUIEvent, check, 1}}, - {2793, {wxUpdateUIEvent, enable, 1}}, - {2794, {wxUpdateUIEvent, show, 1}}, - {2795, {wxUpdateUIEvent, getChecked, 0}}, - {2796, {wxUpdateUIEvent, getEnabled, 0}}, - {2797, {wxUpdateUIEvent, getShown, 0}}, - {2798, {wxUpdateUIEvent, getSetChecked, 0}}, - {2799, {wxUpdateUIEvent, getSetEnabled, 0}}, - {2800, {wxUpdateUIEvent, getSetShown, 0}}, - {2801, {wxUpdateUIEvent, getSetText, 0}}, - {2802, {wxUpdateUIEvent, getText, 0}}, - {2803, {wxUpdateUIEvent, getMode, 0}}, - {2804, {wxUpdateUIEvent, getUpdateInterval, 0}}, - {2805, {wxUpdateUIEvent, resetUpdateTime, 0}}, - {2806, {wxUpdateUIEvent, setMode, 1}}, - {2807, {wxUpdateUIEvent, setText, 1}}, - {2808, {wxUpdateUIEvent, setUpdateInterval, 1}}, - {2809, {wxMouseCaptureChangedEvent, getCapturedWindow, 0}}, - {2810, {wxPaletteChangedEvent, setChangedWindow, 1}}, - {2811, {wxPaletteChangedEvent, getChangedWindow, 0}}, - {2812, {wxQueryNewPaletteEvent, setPaletteRealized, 1}}, - {2813, {wxQueryNewPaletteEvent, getPaletteRealized, 0}}, - {2814, {wxNavigationKeyEvent, getDirection, 0}}, - {2815, {wxNavigationKeyEvent, setDirection, 1}}, - {2816, {wxNavigationKeyEvent, isWindowChange, 0}}, - {2817, {wxNavigationKeyEvent, setWindowChange, 1}}, - {2818, {wxNavigationKeyEvent, isFromTab, 0}}, - {2819, {wxNavigationKeyEvent, setFromTab, 1}}, - {2820, {wxNavigationKeyEvent, getCurrentFocus, 0}}, - {2821, {wxNavigationKeyEvent, setCurrentFocus, 1}}, - {2822, {wxHelpEvent, getOrigin, 0}}, - {2823, {wxHelpEvent, getPosition, 0}}, - {2824, {wxHelpEvent, setOrigin, 1}}, - {2825, {wxHelpEvent, setPosition, 1}}, - {2826, {wxContextMenuEvent, getPosition, 0}}, - {2827, {wxContextMenuEvent, setPosition, 1}}, - {2828, {wxIdleEvent, canSend, 1}}, - {2829, {wxIdleEvent, getMode, 0}}, - {2830, {wxIdleEvent, requestMore, 1}}, - {2831, {wxIdleEvent, moreRequested, 0}}, - {2832, {wxIdleEvent, setMode, 1}}, - {2833, {wxGridEvent, altDown, 0}}, - {2834, {wxGridEvent, controlDown, 0}}, - {2835, {wxGridEvent, getCol, 0}}, - {2836, {wxGridEvent, getPosition, 0}}, - {2837, {wxGridEvent, getRow, 0}}, - {2838, {wxGridEvent, metaDown, 0}}, - {2839, {wxGridEvent, selecting, 0}}, - {2840, {wxGridEvent, shiftDown, 0}}, - {2841, {wxNotifyEvent, allow, 0}}, - {2842, {wxNotifyEvent, isAllowed, 0}}, - {2843, {wxNotifyEvent, veto, 0}}, - {2844, {wxSashEvent, getEdge, 0}}, - {2845, {wxSashEvent, getDragRect, 0}}, - {2846, {wxSashEvent, getDragStatus, 0}}, - {2847, {wxListEvent, getCacheFrom, 0}}, - {2848, {wxListEvent, getCacheTo, 0}}, - {2849, {wxListEvent, getKeyCode, 0}}, - {2850, {wxListEvent, getIndex, 0}}, - {2851, {wxListEvent, getColumn, 0}}, - {2852, {wxListEvent, getPoint, 0}}, - {2853, {wxListEvent, getLabel, 0}}, - {2854, {wxListEvent, getText, 0}}, - {2855, {wxListEvent, getImage, 0}}, - {2856, {wxListEvent, getData, 0}}, - {2857, {wxListEvent, getMask, 0}}, - {2858, {wxListEvent, getItem, 0}}, - {2859, {wxListEvent, isEditCancelled, 0}}, - {2860, {wxDateEvent, getDate, 0}}, - {2861, {wxCalendarEvent, getWeekDay, 0}}, - {2862, {wxFileDirPickerEvent, getPath, 0}}, - {2863, {wxColourPickerEvent, getColour, 0}}, - {2864, {wxFontPickerEvent, getFont, 0}}, - {2865, {wxStyledTextEvent, getPosition, 0}}, - {2866, {wxStyledTextEvent, getKey, 0}}, - {2867, {wxStyledTextEvent, getModifiers, 0}}, - {2868, {wxStyledTextEvent, getModificationType, 0}}, - {2869, {wxStyledTextEvent, getText, 0}}, - {2870, {wxStyledTextEvent, getLength, 0}}, - {2871, {wxStyledTextEvent, getLinesAdded, 0}}, - {2872, {wxStyledTextEvent, getLine, 0}}, - {2873, {wxStyledTextEvent, getFoldLevelNow, 0}}, - {2874, {wxStyledTextEvent, getFoldLevelPrev, 0}}, - {2875, {wxStyledTextEvent, getMargin, 0}}, - {2876, {wxStyledTextEvent, getMessage, 0}}, - {2877, {wxStyledTextEvent, getWParam, 0}}, - {2878, {wxStyledTextEvent, getLParam, 0}}, - {2879, {wxStyledTextEvent, getListType, 0}}, - {2880, {wxStyledTextEvent, getX, 0}}, - {2881, {wxStyledTextEvent, getY, 0}}, - {2882, {wxStyledTextEvent, getDragText, 0}}, - {2883, {wxStyledTextEvent, getDragAllowMove, 0}}, - {2884, {wxStyledTextEvent, getDragResult, 0}}, - {2885, {wxStyledTextEvent, getShift, 0}}, - {2886, {wxStyledTextEvent, getControl, 0}}, - {2887, {wxStyledTextEvent, getAlt, 0}}, - {2888, {utils, getKeyState, 1}}, - {2889, {utils, getMousePosition, 2}}, - {2890, {utils, getMouseState, 0}}, - {2891, {utils, setDetectableAutoRepeat, 1}}, - {2892, {utils, bell, 0}}, - {2893, {utils, findMenuItemId, 3}}, - {2894, {utils, genericFindWindowAtPoint, 1}}, - {2895, {utils, findWindowAtPoint, 1}}, - {2896, {utils, beginBusyCursor, 1}}, - {2897, {utils, endBusyCursor, 0}}, - {2898, {utils, isBusy, 0}}, - {2899, {utils, shutdown, 1}}, - {2900, {utils, shell, 1}}, - {2901, {utils, launchDefaultBrowser, 2}}, - {2902, {utils, getEmailAddress, 0}}, - {2903, {utils, getUserId, 0}}, - {2904, {utils, getHomeDir, 0}}, - {2905, {utils, newId, 0}}, - {2906, {utils, registerId, 1}}, - {2907, {utils, getCurrentId, 0}}, - {2908, {utils, getOsDescription, 0}}, - {2909, {utils, isPlatformLittleEndian, 0}}, - {2910, {utils, isPlatform64Bit, 0}}, - {2911, {wxPrintout, new, 1}}, - {2912, {wxPrintout, destruct, 0}}, - {2913, {wxPrintout, getDC, 0}}, - {2914, {wxPrintout, getPageSizeMM, 2}}, - {2915, {wxPrintout, getPageSizePixels, 2}}, - {2916, {wxPrintout, getPaperRectPixels, 0}}, - {2917, {wxPrintout, getPPIPrinter, 2}}, - {2918, {wxPrintout, getPPIScreen, 2}}, - {2919, {wxPrintout, getTitle, 0}}, - {2920, {wxPrintout, isPreview, 0}}, - {2921, {wxPrintout, fitThisSizeToPaper, 1}}, - {2922, {wxPrintout, fitThisSizeToPage, 1}}, - {2923, {wxPrintout, fitThisSizeToPageMargins, 2}}, - {2924, {wxPrintout, mapScreenSizeToPaper, 0}}, - {2925, {wxPrintout, mapScreenSizeToPage, 0}}, - {2926, {wxPrintout, mapScreenSizeToPageMargins, 1}}, - {2927, {wxPrintout, mapScreenSizeToDevice, 0}}, - {2928, {wxPrintout, getLogicalPaperRect, 0}}, - {2929, {wxPrintout, getLogicalPageRect, 0}}, - {2930, {wxPrintout, getLogicalPageMarginsRect, 1}}, - {2931, {wxPrintout, setLogicalOrigin, 2}}, - {2932, {wxPrintout, offsetLogicalOrigin, 2}}, - {2933, {wxStyledTextCtrl, new_2, 2}}, - {2934, {wxStyledTextCtrl, new_0, 0}}, - {2935, {wxStyledTextCtrl, destruct, 0}}, - {2936, {wxStyledTextCtrl, create, 2}}, - {2937, {wxStyledTextCtrl, addText, 1}}, - {2938, {wxStyledTextCtrl, addStyledText, 1}}, - {2939, {wxStyledTextCtrl, insertText, 2}}, - {2940, {wxStyledTextCtrl, clearAll, 0}}, - {2941, {wxStyledTextCtrl, clearDocumentStyle, 0}}, - {2942, {wxStyledTextCtrl, getLength, 0}}, - {2943, {wxStyledTextCtrl, getCharAt, 1}}, - {2944, {wxStyledTextCtrl, getCurrentPos, 0}}, - {2945, {wxStyledTextCtrl, getAnchor, 0}}, - {2946, {wxStyledTextCtrl, getStyleAt, 1}}, - {2947, {wxStyledTextCtrl, redo, 0}}, - {2948, {wxStyledTextCtrl, setUndoCollection, 1}}, - {2949, {wxStyledTextCtrl, selectAll, 0}}, - {2950, {wxStyledTextCtrl, setSavePoint, 0}}, - {2951, {wxStyledTextCtrl, getStyledText, 2}}, - {2952, {wxStyledTextCtrl, canRedo, 0}}, - {2953, {wxStyledTextCtrl, markerLineFromHandle, 1}}, - {2954, {wxStyledTextCtrl, markerDeleteHandle, 1}}, - {2955, {wxStyledTextCtrl, getUndoCollection, 0}}, - {2956, {wxStyledTextCtrl, getViewWhiteSpace, 0}}, - {2957, {wxStyledTextCtrl, setViewWhiteSpace, 1}}, - {2958, {wxStyledTextCtrl, positionFromPoint, 1}}, - {2959, {wxStyledTextCtrl, positionFromPointClose, 2}}, - {2960, {wxStyledTextCtrl, gotoLine, 1}}, - {2961, {wxStyledTextCtrl, gotoPos, 1}}, - {2962, {wxStyledTextCtrl, setAnchor, 1}}, - {2963, {wxStyledTextCtrl, getCurLine, 1}}, - {2964, {wxStyledTextCtrl, getEndStyled, 0}}, - {2965, {wxStyledTextCtrl, convertEOLs, 1}}, - {2966, {wxStyledTextCtrl, getEOLMode, 0}}, - {2967, {wxStyledTextCtrl, setEOLMode, 1}}, - {2968, {wxStyledTextCtrl, startStyling, 2}}, - {2969, {wxStyledTextCtrl, setStyling, 2}}, - {2970, {wxStyledTextCtrl, getBufferedDraw, 0}}, - {2971, {wxStyledTextCtrl, setBufferedDraw, 1}}, - {2972, {wxStyledTextCtrl, setTabWidth, 1}}, - {2973, {wxStyledTextCtrl, getTabWidth, 0}}, - {2974, {wxStyledTextCtrl, setCodePage, 1}}, - {2975, {wxStyledTextCtrl, markerDefine, 3}}, - {2976, {wxStyledTextCtrl, markerSetForeground, 2}}, - {2977, {wxStyledTextCtrl, markerSetBackground, 2}}, - {2978, {wxStyledTextCtrl, markerAdd, 2}}, - {2979, {wxStyledTextCtrl, markerDelete, 2}}, - {2980, {wxStyledTextCtrl, markerDeleteAll, 1}}, - {2981, {wxStyledTextCtrl, markerGet, 1}}, - {2982, {wxStyledTextCtrl, markerNext, 2}}, - {2983, {wxStyledTextCtrl, markerPrevious, 2}}, - {2984, {wxStyledTextCtrl, markerDefineBitmap, 2}}, - {2985, {wxStyledTextCtrl, markerAddSet, 2}}, - {2986, {wxStyledTextCtrl, markerSetAlpha, 2}}, - {2987, {wxStyledTextCtrl, setMarginType, 2}}, - {2988, {wxStyledTextCtrl, getMarginType, 1}}, - {2989, {wxStyledTextCtrl, setMarginWidth, 2}}, - {2990, {wxStyledTextCtrl, getMarginWidth, 1}}, - {2991, {wxStyledTextCtrl, setMarginMask, 2}}, - {2992, {wxStyledTextCtrl, getMarginMask, 1}}, - {2993, {wxStyledTextCtrl, setMarginSensitive, 2}}, - {2994, {wxStyledTextCtrl, getMarginSensitive, 1}}, - {2995, {wxStyledTextCtrl, styleClearAll, 0}}, - {2996, {wxStyledTextCtrl, styleSetForeground, 2}}, - {2997, {wxStyledTextCtrl, styleSetBackground, 2}}, - {2998, {wxStyledTextCtrl, styleSetBold, 2}}, - {2999, {wxStyledTextCtrl, styleSetItalic, 2}}, - {3000, {wxStyledTextCtrl, styleSetSize, 2}}, - {3001, {wxStyledTextCtrl, styleSetFaceName, 2}}, - {3002, {wxStyledTextCtrl, styleSetEOLFilled, 2}}, - {3003, {wxStyledTextCtrl, styleResetDefault, 0}}, - {3004, {wxStyledTextCtrl, styleSetUnderline, 2}}, - {3005, {wxStyledTextCtrl, styleSetCase, 2}}, - {3006, {wxStyledTextCtrl, styleSetHotSpot, 2}}, - {3007, {wxStyledTextCtrl, setSelForeground, 2}}, - {3008, {wxStyledTextCtrl, setSelBackground, 2}}, - {3009, {wxStyledTextCtrl, getSelAlpha, 0}}, - {3010, {wxStyledTextCtrl, setSelAlpha, 1}}, - {3011, {wxStyledTextCtrl, setCaretForeground, 1}}, - {3012, {wxStyledTextCtrl, cmdKeyAssign, 3}}, - {3013, {wxStyledTextCtrl, cmdKeyClear, 2}}, - {3014, {wxStyledTextCtrl, cmdKeyClearAll, 0}}, - {3015, {wxStyledTextCtrl, setStyleBytes, 2}}, - {3016, {wxStyledTextCtrl, styleSetVisible, 2}}, - {3017, {wxStyledTextCtrl, getCaretPeriod, 0}}, - {3018, {wxStyledTextCtrl, setCaretPeriod, 1}}, - {3019, {wxStyledTextCtrl, setWordChars, 1}}, - {3020, {wxStyledTextCtrl, beginUndoAction, 0}}, - {3021, {wxStyledTextCtrl, endUndoAction, 0}}, - {3022, {wxStyledTextCtrl, indicatorSetStyle, 2}}, - {3023, {wxStyledTextCtrl, indicatorGetStyle, 1}}, - {3024, {wxStyledTextCtrl, indicatorSetForeground, 2}}, - {3025, {wxStyledTextCtrl, indicatorGetForeground, 1}}, - {3026, {wxStyledTextCtrl, setWhitespaceForeground, 2}}, - {3027, {wxStyledTextCtrl, setWhitespaceBackground, 2}}, - {3028, {wxStyledTextCtrl, getStyleBits, 0}}, - {3029, {wxStyledTextCtrl, setLineState, 2}}, - {3030, {wxStyledTextCtrl, getLineState, 1}}, - {3031, {wxStyledTextCtrl, getMaxLineState, 0}}, - {3032, {wxStyledTextCtrl, getCaretLineVisible, 0}}, - {3033, {wxStyledTextCtrl, setCaretLineVisible, 1}}, - {3034, {wxStyledTextCtrl, getCaretLineBackground, 0}}, - {3035, {wxStyledTextCtrl, setCaretLineBackground, 1}}, - {3036, {wxStyledTextCtrl, autoCompShow, 2}}, - {3037, {wxStyledTextCtrl, autoCompCancel, 0}}, - {3038, {wxStyledTextCtrl, autoCompActive, 0}}, - {3039, {wxStyledTextCtrl, autoCompPosStart, 0}}, - {3040, {wxStyledTextCtrl, autoCompComplete, 0}}, - {3041, {wxStyledTextCtrl, autoCompStops, 1}}, - {3042, {wxStyledTextCtrl, autoCompSetSeparator, 1}}, - {3043, {wxStyledTextCtrl, autoCompGetSeparator, 0}}, - {3044, {wxStyledTextCtrl, autoCompSelect, 1}}, - {3045, {wxStyledTextCtrl, autoCompSetCancelAtStart, 1}}, - {3046, {wxStyledTextCtrl, autoCompGetCancelAtStart, 0}}, - {3047, {wxStyledTextCtrl, autoCompSetFillUps, 1}}, - {3048, {wxStyledTextCtrl, autoCompSetChooseSingle, 1}}, - {3049, {wxStyledTextCtrl, autoCompGetChooseSingle, 0}}, - {3050, {wxStyledTextCtrl, autoCompSetIgnoreCase, 1}}, - {3051, {wxStyledTextCtrl, autoCompGetIgnoreCase, 0}}, - {3052, {wxStyledTextCtrl, userListShow, 2}}, - {3053, {wxStyledTextCtrl, autoCompSetAutoHide, 1}}, - {3054, {wxStyledTextCtrl, autoCompGetAutoHide, 0}}, - {3055, {wxStyledTextCtrl, autoCompSetDropRestOfWord, 1}}, - {3056, {wxStyledTextCtrl, autoCompGetDropRestOfWord, 0}}, - {3057, {wxStyledTextCtrl, registerImage, 2}}, - {3058, {wxStyledTextCtrl, clearRegisteredImages, 0}}, - {3059, {wxStyledTextCtrl, autoCompGetTypeSeparator, 0}}, - {3060, {wxStyledTextCtrl, autoCompSetTypeSeparator, 1}}, - {3061, {wxStyledTextCtrl, autoCompSetMaxWidth, 1}}, - {3062, {wxStyledTextCtrl, autoCompGetMaxWidth, 0}}, - {3063, {wxStyledTextCtrl, autoCompSetMaxHeight, 1}}, - {3064, {wxStyledTextCtrl, autoCompGetMaxHeight, 0}}, - {3065, {wxStyledTextCtrl, setIndent, 1}}, - {3066, {wxStyledTextCtrl, getIndent, 0}}, - {3067, {wxStyledTextCtrl, setUseTabs, 1}}, - {3068, {wxStyledTextCtrl, getUseTabs, 0}}, - {3069, {wxStyledTextCtrl, setLineIndentation, 2}}, - {3070, {wxStyledTextCtrl, getLineIndentation, 1}}, - {3071, {wxStyledTextCtrl, getLineIndentPosition, 1}}, - {3072, {wxStyledTextCtrl, getColumn, 1}}, - {3073, {wxStyledTextCtrl, setUseHorizontalScrollBar, 1}}, - {3074, {wxStyledTextCtrl, getUseHorizontalScrollBar, 0}}, - {3075, {wxStyledTextCtrl, setIndentationGuides, 1}}, - {3076, {wxStyledTextCtrl, getIndentationGuides, 0}}, - {3077, {wxStyledTextCtrl, setHighlightGuide, 1}}, - {3078, {wxStyledTextCtrl, getHighlightGuide, 0}}, - {3079, {wxStyledTextCtrl, getLineEndPosition, 1}}, - {3080, {wxStyledTextCtrl, getCodePage, 0}}, - {3081, {wxStyledTextCtrl, getCaretForeground, 0}}, - {3082, {wxStyledTextCtrl, getReadOnly, 0}}, - {3083, {wxStyledTextCtrl, setCurrentPos, 1}}, - {3084, {wxStyledTextCtrl, setSelectionStart, 1}}, - {3085, {wxStyledTextCtrl, getSelectionStart, 0}}, - {3086, {wxStyledTextCtrl, setSelectionEnd, 1}}, - {3087, {wxStyledTextCtrl, getSelectionEnd, 0}}, - {3088, {wxStyledTextCtrl, setPrintMagnification, 1}}, - {3089, {wxStyledTextCtrl, getPrintMagnification, 0}}, - {3090, {wxStyledTextCtrl, setPrintColourMode, 1}}, - {3091, {wxStyledTextCtrl, getPrintColourMode, 0}}, - {3092, {wxStyledTextCtrl, findText, 4}}, - {3093, {wxStyledTextCtrl, formatRange, 7}}, - {3094, {wxStyledTextCtrl, getFirstVisibleLine, 0}}, - {3095, {wxStyledTextCtrl, getLine, 1}}, - {3096, {wxStyledTextCtrl, getLineCount, 0}}, - {3097, {wxStyledTextCtrl, setMarginLeft, 1}}, - {3098, {wxStyledTextCtrl, getMarginLeft, 0}}, - {3099, {wxStyledTextCtrl, setMarginRight, 1}}, - {3100, {wxStyledTextCtrl, getMarginRight, 0}}, - {3101, {wxStyledTextCtrl, getModify, 0}}, - {3102, {wxStyledTextCtrl, setSelection, 2}}, - {3103, {wxStyledTextCtrl, getSelectedText, 0}}, - {3104, {wxStyledTextCtrl, getTextRange, 2}}, - {3105, {wxStyledTextCtrl, hideSelection, 1}}, - {3106, {wxStyledTextCtrl, lineFromPosition, 1}}, - {3107, {wxStyledTextCtrl, positionFromLine, 1}}, - {3108, {wxStyledTextCtrl, lineScroll, 2}}, - {3109, {wxStyledTextCtrl, ensureCaretVisible, 0}}, - {3110, {wxStyledTextCtrl, replaceSelection, 1}}, - {3111, {wxStyledTextCtrl, setReadOnly, 1}}, - {3112, {wxStyledTextCtrl, canPaste, 0}}, - {3113, {wxStyledTextCtrl, canUndo, 0}}, - {3114, {wxStyledTextCtrl, emptyUndoBuffer, 0}}, - {3115, {wxStyledTextCtrl, undo, 0}}, - {3116, {wxStyledTextCtrl, cut, 0}}, - {3117, {wxStyledTextCtrl, copy, 0}}, - {3118, {wxStyledTextCtrl, paste, 0}}, - {3119, {wxStyledTextCtrl, clear, 0}}, - {3120, {wxStyledTextCtrl, setText, 1}}, - {3121, {wxStyledTextCtrl, getText, 0}}, - {3122, {wxStyledTextCtrl, getTextLength, 0}}, - {3123, {wxStyledTextCtrl, getOvertype, 0}}, - {3124, {wxStyledTextCtrl, setCaretWidth, 1}}, - {3125, {wxStyledTextCtrl, getCaretWidth, 0}}, - {3126, {wxStyledTextCtrl, setTargetStart, 1}}, - {3127, {wxStyledTextCtrl, getTargetStart, 0}}, - {3128, {wxStyledTextCtrl, setTargetEnd, 1}}, - {3129, {wxStyledTextCtrl, getTargetEnd, 0}}, - {3130, {wxStyledTextCtrl, replaceTarget, 1}}, - {3131, {wxStyledTextCtrl, searchInTarget, 1}}, - {3132, {wxStyledTextCtrl, setSearchFlags, 1}}, - {3133, {wxStyledTextCtrl, getSearchFlags, 0}}, - {3134, {wxStyledTextCtrl, callTipShow, 2}}, - {3135, {wxStyledTextCtrl, callTipCancel, 0}}, - {3136, {wxStyledTextCtrl, callTipActive, 0}}, - {3137, {wxStyledTextCtrl, callTipPosAtStart, 0}}, - {3138, {wxStyledTextCtrl, callTipSetHighlight, 2}}, - {3139, {wxStyledTextCtrl, callTipSetBackground, 1}}, - {3140, {wxStyledTextCtrl, callTipSetForeground, 1}}, - {3141, {wxStyledTextCtrl, callTipSetForegroundHighlight, 1}}, - {3142, {wxStyledTextCtrl, callTipUseStyle, 1}}, - {3143, {wxStyledTextCtrl, visibleFromDocLine, 1}}, - {3144, {wxStyledTextCtrl, docLineFromVisible, 1}}, - {3145, {wxStyledTextCtrl, wrapCount, 1}}, - {3146, {wxStyledTextCtrl, setFoldLevel, 2}}, - {3147, {wxStyledTextCtrl, getFoldLevel, 1}}, - {3148, {wxStyledTextCtrl, getLastChild, 2}}, - {3149, {wxStyledTextCtrl, getFoldParent, 1}}, - {3150, {wxStyledTextCtrl, showLines, 2}}, - {3151, {wxStyledTextCtrl, hideLines, 2}}, - {3152, {wxStyledTextCtrl, getLineVisible, 1}}, - {3153, {wxStyledTextCtrl, setFoldExpanded, 2}}, - {3154, {wxStyledTextCtrl, getFoldExpanded, 1}}, - {3155, {wxStyledTextCtrl, toggleFold, 1}}, - {3156, {wxStyledTextCtrl, ensureVisible, 1}}, - {3157, {wxStyledTextCtrl, setFoldFlags, 1}}, - {3158, {wxStyledTextCtrl, ensureVisibleEnforcePolicy, 1}}, - {3159, {wxStyledTextCtrl, setTabIndents, 1}}, - {3160, {wxStyledTextCtrl, getTabIndents, 0}}, - {3161, {wxStyledTextCtrl, setBackSpaceUnIndents, 1}}, - {3162, {wxStyledTextCtrl, getBackSpaceUnIndents, 0}}, - {3163, {wxStyledTextCtrl, setMouseDwellTime, 1}}, - {3164, {wxStyledTextCtrl, getMouseDwellTime, 0}}, - {3165, {wxStyledTextCtrl, wordStartPosition, 2}}, - {3166, {wxStyledTextCtrl, wordEndPosition, 2}}, - {3167, {wxStyledTextCtrl, setWrapMode, 1}}, - {3168, {wxStyledTextCtrl, getWrapMode, 0}}, - {3169, {wxStyledTextCtrl, setWrapVisualFlags, 1}}, - {3170, {wxStyledTextCtrl, getWrapVisualFlags, 0}}, - {3171, {wxStyledTextCtrl, setWrapVisualFlagsLocation, 1}}, - {3172, {wxStyledTextCtrl, getWrapVisualFlagsLocation, 0}}, - {3173, {wxStyledTextCtrl, setWrapStartIndent, 1}}, - {3174, {wxStyledTextCtrl, getWrapStartIndent, 0}}, - {3175, {wxStyledTextCtrl, setLayoutCache, 1}}, - {3176, {wxStyledTextCtrl, getLayoutCache, 0}}, - {3177, {wxStyledTextCtrl, setScrollWidth, 1}}, - {3178, {wxStyledTextCtrl, getScrollWidth, 0}}, - {3179, {wxStyledTextCtrl, textWidth, 2}}, - {3180, {wxStyledTextCtrl, getEndAtLastLine, 0}}, - {3181, {wxStyledTextCtrl, textHeight, 1}}, - {3182, {wxStyledTextCtrl, setUseVerticalScrollBar, 1}}, - {3183, {wxStyledTextCtrl, getUseVerticalScrollBar, 0}}, - {3184, {wxStyledTextCtrl, appendText, 1}}, - {3185, {wxStyledTextCtrl, getTwoPhaseDraw, 0}}, - {3186, {wxStyledTextCtrl, setTwoPhaseDraw, 1}}, - {3187, {wxStyledTextCtrl, targetFromSelection, 0}}, - {3188, {wxStyledTextCtrl, linesJoin, 0}}, - {3189, {wxStyledTextCtrl, linesSplit, 1}}, - {3190, {wxStyledTextCtrl, setFoldMarginColour, 2}}, - {3191, {wxStyledTextCtrl, setFoldMarginHiColour, 2}}, - {3192, {wxStyledTextCtrl, lineDown, 0}}, - {3193, {wxStyledTextCtrl, lineDownExtend, 0}}, - {3194, {wxStyledTextCtrl, lineUp, 0}}, - {3195, {wxStyledTextCtrl, lineUpExtend, 0}}, - {3196, {wxStyledTextCtrl, charLeft, 0}}, - {3197, {wxStyledTextCtrl, charLeftExtend, 0}}, - {3198, {wxStyledTextCtrl, charRight, 0}}, - {3199, {wxStyledTextCtrl, charRightExtend, 0}}, - {3200, {wxStyledTextCtrl, wordLeft, 0}}, - {3201, {wxStyledTextCtrl, wordLeftExtend, 0}}, - {3202, {wxStyledTextCtrl, wordRight, 0}}, - {3203, {wxStyledTextCtrl, wordRightExtend, 0}}, - {3204, {wxStyledTextCtrl, home, 0}}, - {3205, {wxStyledTextCtrl, homeExtend, 0}}, - {3206, {wxStyledTextCtrl, lineEnd, 0}}, - {3207, {wxStyledTextCtrl, lineEndExtend, 0}}, - {3208, {wxStyledTextCtrl, documentStart, 0}}, - {3209, {wxStyledTextCtrl, documentStartExtend, 0}}, - {3210, {wxStyledTextCtrl, documentEnd, 0}}, - {3211, {wxStyledTextCtrl, documentEndExtend, 0}}, - {3212, {wxStyledTextCtrl, pageUp, 0}}, - {3213, {wxStyledTextCtrl, pageUpExtend, 0}}, - {3214, {wxStyledTextCtrl, pageDown, 0}}, - {3215, {wxStyledTextCtrl, pageDownExtend, 0}}, - {3216, {wxStyledTextCtrl, editToggleOvertype, 0}}, - {3217, {wxStyledTextCtrl, cancel, 0}}, - {3218, {wxStyledTextCtrl, deleteBack, 0}}, - {3219, {wxStyledTextCtrl, tab, 0}}, - {3220, {wxStyledTextCtrl, backTab, 0}}, - {3221, {wxStyledTextCtrl, newLine, 0}}, - {3222, {wxStyledTextCtrl, formFeed, 0}}, - {3223, {wxStyledTextCtrl, vCHome, 0}}, - {3224, {wxStyledTextCtrl, vCHomeExtend, 0}}, - {3225, {wxStyledTextCtrl, zoomIn, 0}}, - {3226, {wxStyledTextCtrl, zoomOut, 0}}, - {3227, {wxStyledTextCtrl, delWordLeft, 0}}, - {3228, {wxStyledTextCtrl, delWordRight, 0}}, - {3229, {wxStyledTextCtrl, lineCut, 0}}, - {3230, {wxStyledTextCtrl, lineDelete, 0}}, - {3231, {wxStyledTextCtrl, lineTranspose, 0}}, - {3232, {wxStyledTextCtrl, lineDuplicate, 0}}, - {3233, {wxStyledTextCtrl, lowerCase, 0}}, - {3234, {wxStyledTextCtrl, upperCase, 0}}, - {3235, {wxStyledTextCtrl, lineScrollDown, 0}}, - {3236, {wxStyledTextCtrl, lineScrollUp, 0}}, - {3237, {wxStyledTextCtrl, deleteBackNotLine, 0}}, - {3238, {wxStyledTextCtrl, homeDisplay, 0}}, - {3239, {wxStyledTextCtrl, homeDisplayExtend, 0}}, - {3240, {wxStyledTextCtrl, lineEndDisplay, 0}}, - {3241, {wxStyledTextCtrl, lineEndDisplayExtend, 0}}, - {3242, {wxStyledTextCtrl, homeWrapExtend, 0}}, - {3243, {wxStyledTextCtrl, lineEndWrap, 0}}, - {3244, {wxStyledTextCtrl, lineEndWrapExtend, 0}}, - {3245, {wxStyledTextCtrl, vCHomeWrap, 0}}, - {3246, {wxStyledTextCtrl, vCHomeWrapExtend, 0}}, - {3247, {wxStyledTextCtrl, lineCopy, 0}}, - {3248, {wxStyledTextCtrl, moveCaretInsideView, 0}}, - {3249, {wxStyledTextCtrl, lineLength, 1}}, - {3250, {wxStyledTextCtrl, braceHighlight, 2}}, - {3251, {wxStyledTextCtrl, braceBadLight, 1}}, - {3252, {wxStyledTextCtrl, braceMatch, 1}}, - {3253, {wxStyledTextCtrl, getViewEOL, 0}}, - {3254, {wxStyledTextCtrl, setViewEOL, 1}}, - {3255, {wxStyledTextCtrl, setModEventMask, 1}}, - {3256, {wxStyledTextCtrl, getEdgeColumn, 0}}, - {3257, {wxStyledTextCtrl, setEdgeColumn, 1}}, - {3258, {wxStyledTextCtrl, getEdgeMode, 0}}, - {3259, {wxStyledTextCtrl, getEdgeColour, 0}}, - {3260, {wxStyledTextCtrl, setEdgeColour, 1}}, - {3261, {wxStyledTextCtrl, searchAnchor, 0}}, - {3262, {wxStyledTextCtrl, searchNext, 2}}, - {3263, {wxStyledTextCtrl, searchPrev, 2}}, - {3264, {wxStyledTextCtrl, linesOnScreen, 0}}, - {3265, {wxStyledTextCtrl, usePopUp, 1}}, - {3266, {wxStyledTextCtrl, selectionIsRectangle, 0}}, - {3267, {wxStyledTextCtrl, setZoom, 1}}, - {3268, {wxStyledTextCtrl, getZoom, 0}}, - {3269, {wxStyledTextCtrl, getModEventMask, 0}}, - {3270, {wxStyledTextCtrl, setSTCFocus, 1}}, - {3271, {wxStyledTextCtrl, getSTCFocus, 0}}, - {3272, {wxStyledTextCtrl, setStatus, 1}}, - {3273, {wxStyledTextCtrl, getStatus, 0}}, - {3274, {wxStyledTextCtrl, setMouseDownCaptures, 1}}, - {3275, {wxStyledTextCtrl, getMouseDownCaptures, 0}}, - {3276, {wxStyledTextCtrl, setSTCCursor, 1}}, - {3277, {wxStyledTextCtrl, getSTCCursor, 0}}, - {3278, {wxStyledTextCtrl, setControlCharSymbol, 1}}, - {3279, {wxStyledTextCtrl, getControlCharSymbol, 0}}, - {3280, {wxStyledTextCtrl, wordPartLeft, 0}}, - {3281, {wxStyledTextCtrl, wordPartLeftExtend, 0}}, - {3282, {wxStyledTextCtrl, wordPartRight, 0}}, - {3283, {wxStyledTextCtrl, wordPartRightExtend, 0}}, - {3284, {wxStyledTextCtrl, setVisiblePolicy, 2}}, - {3285, {wxStyledTextCtrl, delLineLeft, 0}}, - {3286, {wxStyledTextCtrl, delLineRight, 0}}, - {3287, {wxStyledTextCtrl, getXOffset, 0}}, - {3288, {wxStyledTextCtrl, chooseCaretX, 0}}, - {3289, {wxStyledTextCtrl, setXCaretPolicy, 2}}, - {3290, {wxStyledTextCtrl, setYCaretPolicy, 2}}, - {3291, {wxStyledTextCtrl, getPrintWrapMode, 0}}, - {3292, {wxStyledTextCtrl, setHotspotActiveForeground, 2}}, - {3293, {wxStyledTextCtrl, setHotspotActiveBackground, 2}}, - {3294, {wxStyledTextCtrl, setHotspotActiveUnderline, 1}}, - {3295, {wxStyledTextCtrl, setHotspotSingleLine, 1}}, - {3296, {wxStyledTextCtrl, paraDownExtend, 0}}, - {3297, {wxStyledTextCtrl, paraUp, 0}}, - {3298, {wxStyledTextCtrl, paraUpExtend, 0}}, - {3299, {wxStyledTextCtrl, positionBefore, 1}}, - {3300, {wxStyledTextCtrl, positionAfter, 1}}, - {3301, {wxStyledTextCtrl, copyRange, 2}}, - {3302, {wxStyledTextCtrl, copyText, 2}}, - {3303, {wxStyledTextCtrl, setSelectionMode, 1}}, - {3304, {wxStyledTextCtrl, getSelectionMode, 0}}, - {3305, {wxStyledTextCtrl, lineDownRectExtend, 0}}, - {3306, {wxStyledTextCtrl, lineUpRectExtend, 0}}, - {3307, {wxStyledTextCtrl, charLeftRectExtend, 0}}, - {3308, {wxStyledTextCtrl, charRightRectExtend, 0}}, - {3309, {wxStyledTextCtrl, homeRectExtend, 0}}, - {3310, {wxStyledTextCtrl, vCHomeRectExtend, 0}}, - {3311, {wxStyledTextCtrl, lineEndRectExtend, 0}}, - {3312, {wxStyledTextCtrl, pageUpRectExtend, 0}}, - {3313, {wxStyledTextCtrl, pageDownRectExtend, 0}}, - {3314, {wxStyledTextCtrl, stutteredPageUp, 0}}, - {3315, {wxStyledTextCtrl, stutteredPageUpExtend, 0}}, - {3316, {wxStyledTextCtrl, stutteredPageDown, 0}}, - {3317, {wxStyledTextCtrl, stutteredPageDownExtend, 0}}, - {3318, {wxStyledTextCtrl, wordLeftEnd, 0}}, - {3319, {wxStyledTextCtrl, wordLeftEndExtend, 0}}, - {3320, {wxStyledTextCtrl, wordRightEnd, 0}}, - {3321, {wxStyledTextCtrl, wordRightEndExtend, 0}}, - {3322, {wxStyledTextCtrl, setWhitespaceChars, 1}}, - {3323, {wxStyledTextCtrl, setCharsDefault, 0}}, - {3324, {wxStyledTextCtrl, autoCompGetCurrent, 0}}, - {3325, {wxStyledTextCtrl, allocate, 1}}, - {3326, {wxStyledTextCtrl, findColumn, 2}}, - {3327, {wxStyledTextCtrl, getCaretSticky, 0}}, - {3328, {wxStyledTextCtrl, setCaretSticky, 1}}, - {3329, {wxStyledTextCtrl, toggleCaretSticky, 0}}, - {3330, {wxStyledTextCtrl, setPasteConvertEndings, 1}}, - {3331, {wxStyledTextCtrl, getPasteConvertEndings, 0}}, - {3332, {wxStyledTextCtrl, selectionDuplicate, 0}}, - {3333, {wxStyledTextCtrl, setCaretLineBackAlpha, 1}}, - {3334, {wxStyledTextCtrl, getCaretLineBackAlpha, 0}}, - {3335, {wxStyledTextCtrl, startRecord, 0}}, - {3336, {wxStyledTextCtrl, stopRecord, 0}}, - {3337, {wxStyledTextCtrl, setLexer, 1}}, - {3338, {wxStyledTextCtrl, getLexer, 0}}, - {3339, {wxStyledTextCtrl, colourise, 2}}, - {3340, {wxStyledTextCtrl, setProperty, 2}}, - {3341, {wxStyledTextCtrl, setKeyWords, 2}}, - {3342, {wxStyledTextCtrl, setLexerLanguage, 1}}, - {3343, {wxStyledTextCtrl, getProperty, 1}}, - {3344, {wxStyledTextCtrl, getStyleBitsNeeded, 0}}, - {3345, {wxStyledTextCtrl, getCurrentLine, 0}}, - {3346, {wxStyledTextCtrl, styleSetSpec, 2}}, - {3347, {wxStyledTextCtrl, styleSetFont, 2}}, - {3348, {wxStyledTextCtrl, styleSetFontAttr, 7}}, - {3349, {wxStyledTextCtrl, styleSetCharacterSet, 2}}, - {3350, {wxStyledTextCtrl, styleSetFontEncoding, 2}}, - {3351, {wxStyledTextCtrl, cmdKeyExecute, 1}}, - {3352, {wxStyledTextCtrl, setMargins, 2}}, - {3353, {wxStyledTextCtrl, getSelection, 2}}, - {3354, {wxStyledTextCtrl, pointFromPosition, 1}}, - {3355, {wxStyledTextCtrl, scrollToLine, 1}}, - {3356, {wxStyledTextCtrl, scrollToColumn, 1}}, - {3357, {wxStyledTextCtrl, sendMsg, 2}}, - {3358, {wxStyledTextCtrl, setVScrollBar, 1}}, - {3359, {wxStyledTextCtrl, setHScrollBar, 1}}, - {3360, {wxStyledTextCtrl, getLastKeydownProcessed, 0}}, - {3361, {wxStyledTextCtrl, setLastKeydownProcessed, 1}}, - {3362, {wxStyledTextCtrl, saveFile, 1}}, - {3363, {wxStyledTextCtrl, loadFile, 1}}, - {3364, {wxStyledTextCtrl, doDragOver, 3}}, - {3365, {wxStyledTextCtrl, doDropText, 3}}, - {3366, {wxStyledTextCtrl, getUseAntiAliasing, 0}}, - {3367, {wxStyledTextCtrl, addTextRaw, 1}}, - {3368, {wxStyledTextCtrl, insertTextRaw, 2}}, - {3369, {wxStyledTextCtrl, getCurLineRaw, 1}}, - {3370, {wxStyledTextCtrl, getLineRaw, 1}}, - {3371, {wxStyledTextCtrl, getSelectedTextRaw, 0}}, - {3372, {wxStyledTextCtrl, getTextRangeRaw, 2}}, - {3373, {wxStyledTextCtrl, setTextRaw, 1}}, - {3374, {wxStyledTextCtrl, getTextRaw, 0}}, - {3375, {wxStyledTextCtrl, appendTextRaw, 1}}, - {3376, {wxArtProvider, getBitmap, 2}}, - {3377, {wxArtProvider, getIcon, 2}}, - {3378, {wxTreeEvent, getKeyCode, 0}}, - {3379, {wxTreeEvent, getItem, 0}}, - {3380, {wxTreeEvent, getKeyEvent, 0}}, - {3381, {wxTreeEvent, getLabel, 0}}, - {3382, {wxTreeEvent, getOldItem, 0}}, - {3383, {wxTreeEvent, getPoint, 0}}, - {3384, {wxTreeEvent, isEditCancelled, 0}}, - {3385, {wxTreeEvent, setToolTip, 1}}, - {3386, {wxNotebookEvent, getOldSelection, 0}}, - {3387, {wxNotebookEvent, getSelection, 0}}, - {3388, {wxNotebookEvent, setOldSelection, 1}}, - {3389, {wxNotebookEvent, setSelection, 1}}, - {3390, {wxFileDataObject, new, 0}}, - {3391, {wxFileDataObject, addFile, 1}}, - {3392, {wxFileDataObject, getFilenames, 0}}, - {3393, {wxFileDataObject, 'Destroy', undefined}}, - {3394, {wxTextDataObject, new, 1}}, - {3395, {wxTextDataObject, getTextLength, 0}}, - {3396, {wxTextDataObject, getText, 0}}, - {3397, {wxTextDataObject, setText, 1}}, - {3398, {wxTextDataObject, 'Destroy', undefined}}, - {3399, {wxBitmapDataObject, new_1_1, 1}}, - {3400, {wxBitmapDataObject, new_1_0, 1}}, - {3401, {wxBitmapDataObject, getBitmap, 0}}, - {3402, {wxBitmapDataObject, setBitmap, 1}}, - {3403, {wxBitmapDataObject, 'Destroy', undefined}}, - {3405, {wxClipboard, new, 0}}, - {3406, {wxClipboard, destruct, 0}}, - {3407, {wxClipboard, addData, 1}}, - {3408, {wxClipboard, clear, 0}}, - {3409, {wxClipboard, close, 0}}, - {3410, {wxClipboard, flush, 0}}, - {3411, {wxClipboard, getData, 1}}, - {3412, {wxClipboard, isOpened, 0}}, - {3413, {wxClipboard, open, 0}}, - {3414, {wxClipboard, setData, 1}}, - {3416, {wxClipboard, usePrimarySelection, 1}}, - {3417, {wxClipboard, isSupported, 1}}, - {3418, {wxClipboard, get, 0}}, - {3419, {wxSpinEvent, getPosition, 0}}, - {3420, {wxSpinEvent, setPosition, 1}}, - {3421, {wxSplitterWindow, new_0, 0}}, - {3422, {wxSplitterWindow, new_2, 2}}, - {3423, {wxSplitterWindow, destruct, 0}}, - {3424, {wxSplitterWindow, create, 2}}, - {3425, {wxSplitterWindow, getMinimumPaneSize, 0}}, - {3426, {wxSplitterWindow, getSashGravity, 0}}, - {3427, {wxSplitterWindow, getSashPosition, 0}}, - {3428, {wxSplitterWindow, getSplitMode, 0}}, - {3429, {wxSplitterWindow, getWindow1, 0}}, - {3430, {wxSplitterWindow, getWindow2, 0}}, - {3431, {wxSplitterWindow, initialize, 1}}, - {3432, {wxSplitterWindow, isSplit, 0}}, - {3433, {wxSplitterWindow, replaceWindow, 2}}, - {3434, {wxSplitterWindow, setSashGravity, 1}}, - {3435, {wxSplitterWindow, setSashPosition, 2}}, - {3436, {wxSplitterWindow, setSashSize, 1}}, - {3437, {wxSplitterWindow, setMinimumPaneSize, 1}}, - {3438, {wxSplitterWindow, setSplitMode, 1}}, - {3439, {wxSplitterWindow, splitHorizontally, 3}}, - {3440, {wxSplitterWindow, splitVertically, 3}}, - {3441, {wxSplitterWindow, unsplit, 1}}, - {3442, {wxSplitterWindow, updateSize, 0}}, - {3443, {wxSplitterEvent, getSashPosition, 0}}, - {3444, {wxSplitterEvent, getX, 0}}, - {3445, {wxSplitterEvent, getY, 0}}, - {3446, {wxSplitterEvent, getWindowBeingRemoved, 0}}, - {3447, {wxSplitterEvent, setSashPosition, 1}}, - {3448, {wxHtmlWindow, new_0, 0}}, - {3449, {wxHtmlWindow, new_2, 2}}, - {3450, {wxHtmlWindow, appendToPage, 1}}, - {3451, {wxHtmlWindow, getOpenedAnchor, 0}}, - {3452, {wxHtmlWindow, getOpenedPage, 0}}, - {3453, {wxHtmlWindow, getOpenedPageTitle, 0}}, - {3454, {wxHtmlWindow, getRelatedFrame, 0}}, - {3455, {wxHtmlWindow, historyBack, 0}}, - {3456, {wxHtmlWindow, historyCanBack, 0}}, - {3457, {wxHtmlWindow, historyCanForward, 0}}, - {3458, {wxHtmlWindow, historyClear, 0}}, - {3459, {wxHtmlWindow, historyForward, 0}}, - {3460, {wxHtmlWindow, loadFile, 1}}, - {3461, {wxHtmlWindow, loadPage, 1}}, - {3462, {wxHtmlWindow, selectAll, 0}}, - {3463, {wxHtmlWindow, selectionToText, 0}}, - {3464, {wxHtmlWindow, selectLine, 1}}, - {3465, {wxHtmlWindow, selectWord, 1}}, - {3466, {wxHtmlWindow, setBorders, 1}}, - {3467, {wxHtmlWindow, setFonts, 3}}, - {3468, {wxHtmlWindow, setPage, 1}}, - {3469, {wxHtmlWindow, setRelatedFrame, 2}}, - {3470, {wxHtmlWindow, setRelatedStatusBar, 1}}, - {3471, {wxHtmlWindow, toText, 0}}, - {3472, {wxHtmlWindow, 'Destroy', undefined}}, - {3473, {wxHtmlLinkEvent, getLinkInfo, 0}}, - {3474, {wxAuiNotebookEvent, setSelection, 1}}, - {3475, {wxAuiNotebookEvent, getSelection, 0}}, - {3476, {wxAuiNotebookEvent, setOldSelection, 1}}, - {3477, {wxAuiNotebookEvent, getOldSelection, 0}}, - {3478, {wxAuiNotebookEvent, setDragSource, 1}}, - {3479, {wxAuiNotebookEvent, getDragSource, 0}}, - {3480, {wxAuiManagerEvent, setManager, 1}}, - {3481, {wxAuiManagerEvent, getManager, 0}}, - {3482, {wxAuiManagerEvent, setPane, 1}}, - {3483, {wxAuiManagerEvent, getPane, 0}}, - {3484, {wxAuiManagerEvent, setButton, 1}}, - {3485, {wxAuiManagerEvent, getButton, 0}}, - {3486, {wxAuiManagerEvent, setDC, 1}}, - {3487, {wxAuiManagerEvent, getDC, 0}}, - {3488, {wxAuiManagerEvent, veto, 1}}, - {3489, {wxAuiManagerEvent, getVeto, 0}}, - {3490, {wxAuiManagerEvent, setCanVeto, 1}}, - {3491, {wxAuiManagerEvent, canVeto, 0}}, - {3492, {wxLogNull, new, 0}}, - {3493, {wxLogNull, 'Destroy', undefined}}, + {2018, {wxTreeCtrl, getFirstChild, 2}}, + {2019, {wxTreeCtrl, getNextChild, 2}}, + {2020, {wxTreeCtrl, getFirstVisibleItem, 0}}, + {2021, {wxTreeCtrl, getImageList, 0}}, + {2022, {wxTreeCtrl, getIndent, 0}}, + {2023, {wxTreeCtrl, getItemBackgroundColour, 1}}, + {2024, {wxTreeCtrl, getItemData, 1}}, + {2025, {wxTreeCtrl, getItemFont, 1}}, + {2026, {wxTreeCtrl, getItemImage_1, 1}}, + {2027, {wxTreeCtrl, getItemImage_2, 2}}, + {2028, {wxTreeCtrl, getItemText, 1}}, + {2029, {wxTreeCtrl, getItemTextColour, 1}}, + {2030, {wxTreeCtrl, getLastChild, 1}}, + {2031, {wxTreeCtrl, getNextSibling, 1}}, + {2032, {wxTreeCtrl, getNextVisible, 1}}, + {2033, {wxTreeCtrl, getItemParent, 1}}, + {2034, {wxTreeCtrl, getPrevSibling, 1}}, + {2035, {wxTreeCtrl, getPrevVisible, 1}}, + {2036, {wxTreeCtrl, getRootItem, 0}}, + {2037, {wxTreeCtrl, getSelection, 0}}, + {2038, {wxTreeCtrl, getSelections, 1}}, + {2039, {wxTreeCtrl, getStateImageList, 0}}, + {2040, {wxTreeCtrl, hitTest, 1}}, + {2042, {wxTreeCtrl, insertItem, 4}}, + {2043, {wxTreeCtrl, isBold, 1}}, + {2044, {wxTreeCtrl, isExpanded, 1}}, + {2045, {wxTreeCtrl, isSelected, 1}}, + {2046, {wxTreeCtrl, isVisible, 1}}, + {2047, {wxTreeCtrl, itemHasChildren, 1}}, + {2048, {wxTreeCtrl, prependItem, 3}}, + {2049, {wxTreeCtrl, scrollTo, 1}}, + {2050, {wxTreeCtrl, selectItem_1, 1}}, + {2051, {wxTreeCtrl, selectItem_2, 2}}, + {2052, {wxTreeCtrl, setIndent, 1}}, + {2053, {wxTreeCtrl, setImageList, 1}}, + {2054, {wxTreeCtrl, setItemBackgroundColour, 2}}, + {2055, {wxTreeCtrl, setItemBold, 2}}, + {2056, {wxTreeCtrl, setItemData, 2}}, + {2057, {wxTreeCtrl, setItemDropHighlight, 2}}, + {2058, {wxTreeCtrl, setItemFont, 2}}, + {2059, {wxTreeCtrl, setItemHasChildren, 2}}, + {2060, {wxTreeCtrl, setItemImage_2, 2}}, + {2061, {wxTreeCtrl, setItemImage_3, 3}}, + {2062, {wxTreeCtrl, setItemText, 2}}, + {2063, {wxTreeCtrl, setItemTextColour, 2}}, + {2064, {wxTreeCtrl, setStateImageList, 1}}, + {2065, {wxTreeCtrl, setWindowStyle, 1}}, + {2066, {wxTreeCtrl, sortChildren, 1}}, + {2067, {wxTreeCtrl, toggle, 1}}, + {2068, {wxTreeCtrl, toggleItemSelection, 1}}, + {2069, {wxTreeCtrl, unselect, 0}}, + {2070, {wxTreeCtrl, unselectAll, 0}}, + {2071, {wxTreeCtrl, unselectItem, 1}}, + {2072, {wxScrollBar, new_0, 0}}, + {2073, {wxScrollBar, new_3, 3}}, + {2074, {wxScrollBar, destruct, 0}}, + {2075, {wxScrollBar, create, 3}}, + {2076, {wxScrollBar, getRange, 0}}, + {2077, {wxScrollBar, getPageSize, 0}}, + {2078, {wxScrollBar, getThumbPosition, 0}}, + {2079, {wxScrollBar, getThumbSize, 0}}, + {2080, {wxScrollBar, setThumbPosition, 1}}, + {2081, {wxScrollBar, setScrollbar, 5}}, + {2083, {wxSpinButton, new_2, 2}}, + {2084, {wxSpinButton, new_0, 0}}, + {2085, {wxSpinButton, create, 2}}, + {2086, {wxSpinButton, getMax, 0}}, + {2087, {wxSpinButton, getMin, 0}}, + {2088, {wxSpinButton, getValue, 0}}, + {2089, {wxSpinButton, setRange, 2}}, + {2090, {wxSpinButton, setValue, 1}}, + {2091, {wxSpinButton, 'Destroy', undefined}}, + {2092, {wxSpinCtrl, new_0, 0}}, + {2093, {wxSpinCtrl, new_2, 2}}, + {2095, {wxSpinCtrl, create, 2}}, + {2098, {wxSpinCtrl, setValue_1_1, 1}}, + {2099, {wxSpinCtrl, setValue_1_0, 1}}, + {2101, {wxSpinCtrl, getValue, 0}}, + {2103, {wxSpinCtrl, setRange, 2}}, + {2104, {wxSpinCtrl, setSelection, 2}}, + {2106, {wxSpinCtrl, getMin, 0}}, + {2108, {wxSpinCtrl, getMax, 0}}, + {2109, {wxSpinCtrl, 'Destroy', undefined}}, + {2110, {wxStaticText, new_0, 0}}, + {2111, {wxStaticText, new_4, 4}}, + {2112, {wxStaticText, create, 4}}, + {2113, {wxStaticText, getLabel, 0}}, + {2114, {wxStaticText, setLabel, 1}}, + {2115, {wxStaticText, wrap, 1}}, + {2116, {wxStaticText, 'Destroy', undefined}}, + {2117, {wxStaticBitmap, new_0, 0}}, + {2118, {wxStaticBitmap, new_4, 4}}, + {2119, {wxStaticBitmap, create, 4}}, + {2120, {wxStaticBitmap, getBitmap, 0}}, + {2121, {wxStaticBitmap, setBitmap, 1}}, + {2122, {wxStaticBitmap, 'Destroy', undefined}}, + {2123, {wxRadioBox, new, 7}}, + {2125, {wxRadioBox, destruct, 0}}, + {2126, {wxRadioBox, create, 7}}, + {2127, {wxRadioBox, enable_2, 2}}, + {2128, {wxRadioBox, enable_1, 1}}, + {2129, {wxRadioBox, getSelection, 0}}, + {2130, {wxRadioBox, getString, 1}}, + {2131, {wxRadioBox, setSelection, 1}}, + {2132, {wxRadioBox, show_2, 2}}, + {2133, {wxRadioBox, show_1, 1}}, + {2134, {wxRadioBox, getColumnCount, 0}}, + {2135, {wxRadioBox, getItemHelpText, 1}}, + {2136, {wxRadioBox, getItemToolTip, 1}}, + {2138, {wxRadioBox, getItemFromPoint, 1}}, + {2139, {wxRadioBox, getRowCount, 0}}, + {2140, {wxRadioBox, isItemEnabled, 1}}, + {2141, {wxRadioBox, isItemShown, 1}}, + {2142, {wxRadioBox, setItemHelpText, 2}}, + {2143, {wxRadioBox, setItemToolTip, 2}}, + {2144, {wxRadioButton, new_0, 0}}, + {2145, {wxRadioButton, new_4, 4}}, + {2146, {wxRadioButton, create, 4}}, + {2147, {wxRadioButton, getValue, 0}}, + {2148, {wxRadioButton, setValue, 1}}, + {2149, {wxRadioButton, 'Destroy', undefined}}, + {2151, {wxSlider, new_6, 6}}, + {2152, {wxSlider, new_0, 0}}, + {2153, {wxSlider, create, 6}}, + {2154, {wxSlider, getLineSize, 0}}, + {2155, {wxSlider, getMax, 0}}, + {2156, {wxSlider, getMin, 0}}, + {2157, {wxSlider, getPageSize, 0}}, + {2158, {wxSlider, getThumbLength, 0}}, + {2159, {wxSlider, getValue, 0}}, + {2160, {wxSlider, setLineSize, 1}}, + {2161, {wxSlider, setPageSize, 1}}, + {2162, {wxSlider, setRange, 2}}, + {2163, {wxSlider, setThumbLength, 1}}, + {2164, {wxSlider, setValue, 1}}, + {2165, {wxSlider, 'Destroy', undefined}}, + {2167, {wxDialog, new_4, 4}}, + {2168, {wxDialog, new_0, 0}}, + {2170, {wxDialog, destruct, 0}}, + {2171, {wxDialog, create, 4}}, + {2172, {wxDialog, createButtonSizer, 1}}, + {2173, {wxDialog, createStdDialogButtonSizer, 1}}, + {2174, {wxDialog, endModal, 1}}, + {2175, {wxDialog, getAffirmativeId, 0}}, + {2176, {wxDialog, getReturnCode, 0}}, + {2177, {wxDialog, isModal, 0}}, + {2178, {wxDialog, setAffirmativeId, 1}}, + {2179, {wxDialog, setReturnCode, 1}}, + {2180, {wxDialog, show, 1}}, + {2181, {wxDialog, showModal, 0}}, + {2182, {wxColourDialog, new_0, 0}}, + {2183, {wxColourDialog, new_2, 2}}, + {2184, {wxColourDialog, destruct, 0}}, + {2185, {wxColourDialog, create, 2}}, + {2186, {wxColourDialog, getColourData, 0}}, + {2187, {wxColourData, new_0, 0}}, + {2188, {wxColourData, new_1, 1}}, + {2189, {wxColourData, destruct, 0}}, + {2190, {wxColourData, getChooseFull, 0}}, + {2191, {wxColourData, getColour, 0}}, + {2193, {wxColourData, getCustomColour, 1}}, + {2194, {wxColourData, setChooseFull, 1}}, + {2195, {wxColourData, setColour, 1}}, + {2196, {wxColourData, setCustomColour, 2}}, + {2197, {wxPalette, new_0, 0}}, + {2198, {wxPalette, new_4, 4}}, + {2200, {wxPalette, destruct, 0}}, + {2201, {wxPalette, create, 4}}, + {2202, {wxPalette, getColoursCount, 0}}, + {2203, {wxPalette, getPixel, 3}}, + {2204, {wxPalette, getRGB, 4}}, + {2205, {wxPalette, isOk, 0}}, + {2209, {wxDirDialog, new, 2}}, + {2210, {wxDirDialog, destruct, 0}}, + {2211, {wxDirDialog, getPath, 0}}, + {2212, {wxDirDialog, getMessage, 0}}, + {2213, {wxDirDialog, setMessage, 1}}, + {2214, {wxDirDialog, setPath, 1}}, + {2218, {wxFileDialog, new, 2}}, + {2219, {wxFileDialog, destruct, 0}}, + {2220, {wxFileDialog, getDirectory, 0}}, + {2221, {wxFileDialog, getFilename, 0}}, + {2222, {wxFileDialog, getFilenames, 1}}, + {2223, {wxFileDialog, getFilterIndex, 0}}, + {2224, {wxFileDialog, getMessage, 0}}, + {2225, {wxFileDialog, getPath, 0}}, + {2226, {wxFileDialog, getPaths, 1}}, + {2227, {wxFileDialog, getWildcard, 0}}, + {2228, {wxFileDialog, setDirectory, 1}}, + {2229, {wxFileDialog, setFilename, 1}}, + {2230, {wxFileDialog, setFilterIndex, 1}}, + {2231, {wxFileDialog, setMessage, 1}}, + {2232, {wxFileDialog, setPath, 1}}, + {2233, {wxFileDialog, setWildcard, 1}}, + {2234, {wxPickerBase, setInternalMargin, 1}}, + {2235, {wxPickerBase, getInternalMargin, 0}}, + {2236, {wxPickerBase, setTextCtrlProportion, 1}}, + {2237, {wxPickerBase, setPickerCtrlProportion, 1}}, + {2238, {wxPickerBase, getTextCtrlProportion, 0}}, + {2239, {wxPickerBase, getPickerCtrlProportion, 0}}, + {2240, {wxPickerBase, hasTextCtrl, 0}}, + {2241, {wxPickerBase, getTextCtrl, 0}}, + {2242, {wxPickerBase, isTextCtrlGrowable, 0}}, + {2243, {wxPickerBase, setPickerCtrlGrowable, 1}}, + {2244, {wxPickerBase, setTextCtrlGrowable, 1}}, + {2245, {wxPickerBase, isPickerCtrlGrowable, 0}}, + {2246, {wxFilePickerCtrl, new_0, 0}}, + {2247, {wxFilePickerCtrl, new_3, 3}}, + {2248, {wxFilePickerCtrl, create, 3}}, + {2249, {wxFilePickerCtrl, getPath, 0}}, + {2250, {wxFilePickerCtrl, setPath, 1}}, + {2251, {wxFilePickerCtrl, 'Destroy', undefined}}, + {2252, {wxDirPickerCtrl, new_0, 0}}, + {2253, {wxDirPickerCtrl, new_3, 3}}, + {2254, {wxDirPickerCtrl, create, 3}}, + {2255, {wxDirPickerCtrl, getPath, 0}}, + {2256, {wxDirPickerCtrl, setPath, 1}}, + {2257, {wxDirPickerCtrl, 'Destroy', undefined}}, + {2258, {wxColourPickerCtrl, new_0, 0}}, + {2259, {wxColourPickerCtrl, new_3, 3}}, + {2260, {wxColourPickerCtrl, create, 3}}, + {2261, {wxColourPickerCtrl, getColour, 0}}, + {2262, {wxColourPickerCtrl, setColour_1_1, 1}}, + {2263, {wxColourPickerCtrl, setColour_1_0, 1}}, + {2264, {wxColourPickerCtrl, 'Destroy', undefined}}, + {2265, {wxDatePickerCtrl, new_0, 0}}, + {2266, {wxDatePickerCtrl, new_3, 3}}, + {2267, {wxDatePickerCtrl, getRange, 2}}, + {2268, {wxDatePickerCtrl, getValue, 0}}, + {2269, {wxDatePickerCtrl, setRange, 2}}, + {2270, {wxDatePickerCtrl, setValue, 1}}, + {2271, {wxDatePickerCtrl, 'Destroy', undefined}}, + {2272, {wxFontPickerCtrl, new_0, 0}}, + {2273, {wxFontPickerCtrl, new_3, 3}}, + {2274, {wxFontPickerCtrl, create, 3}}, + {2275, {wxFontPickerCtrl, getSelectedFont, 0}}, + {2276, {wxFontPickerCtrl, setSelectedFont, 1}}, + {2277, {wxFontPickerCtrl, getMaxPointSize, 0}}, + {2278, {wxFontPickerCtrl, setMaxPointSize, 1}}, + {2279, {wxFontPickerCtrl, 'Destroy', undefined}}, + {2282, {wxFindReplaceDialog, new_0, 0}}, + {2283, {wxFindReplaceDialog, new_4, 4}}, + {2284, {wxFindReplaceDialog, destruct, 0}}, + {2285, {wxFindReplaceDialog, create, 4}}, + {2286, {wxFindReplaceDialog, getData, 0}}, + {2287, {wxFindReplaceData, new_0, 0}}, + {2288, {wxFindReplaceData, new_1, 1}}, + {2289, {wxFindReplaceData, getFindString, 0}}, + {2290, {wxFindReplaceData, getReplaceString, 0}}, + {2291, {wxFindReplaceData, getFlags, 0}}, + {2292, {wxFindReplaceData, setFlags, 1}}, + {2293, {wxFindReplaceData, setFindString, 1}}, + {2294, {wxFindReplaceData, setReplaceString, 1}}, + {2295, {wxFindReplaceData, 'Destroy', undefined}}, + {2296, {wxMultiChoiceDialog, new_0, 0}}, + {2298, {wxMultiChoiceDialog, new_5, 5}}, + {2299, {wxMultiChoiceDialog, getSelections, 0}}, + {2300, {wxMultiChoiceDialog, setSelections, 1}}, + {2301, {wxMultiChoiceDialog, 'Destroy', undefined}}, + {2302, {wxSingleChoiceDialog, new_0, 0}}, + {2304, {wxSingleChoiceDialog, new_5, 5}}, + {2305, {wxSingleChoiceDialog, getSelection, 0}}, + {2306, {wxSingleChoiceDialog, getStringSelection, 0}}, + {2307, {wxSingleChoiceDialog, setSelection, 1}}, + {2308, {wxSingleChoiceDialog, 'Destroy', undefined}}, + {2309, {wxTextEntryDialog, new, 3}}, + {2310, {wxTextEntryDialog, getValue, 0}}, + {2311, {wxTextEntryDialog, setValue, 1}}, + {2312, {wxTextEntryDialog, 'Destroy', undefined}}, + {2313, {wxPasswordEntryDialog, new, 3}}, + {2314, {wxPasswordEntryDialog, 'Destroy', undefined}}, + {2315, {wxFontData, new_0, 0}}, + {2316, {wxFontData, new_1, 1}}, + {2317, {wxFontData, destruct, 0}}, + {2318, {wxFontData, enableEffects, 1}}, + {2319, {wxFontData, getAllowSymbols, 0}}, + {2320, {wxFontData, getColour, 0}}, + {2321, {wxFontData, getChosenFont, 0}}, + {2322, {wxFontData, getEnableEffects, 0}}, + {2323, {wxFontData, getInitialFont, 0}}, + {2324, {wxFontData, getShowHelp, 0}}, + {2325, {wxFontData, setAllowSymbols, 1}}, + {2326, {wxFontData, setChosenFont, 1}}, + {2327, {wxFontData, setColour, 1}}, + {2328, {wxFontData, setInitialFont, 1}}, + {2329, {wxFontData, setRange, 2}}, + {2330, {wxFontData, setShowHelp, 1}}, + {2334, {wxFontDialog, new_0, 0}}, + {2336, {wxFontDialog, new_2, 2}}, + {2338, {wxFontDialog, create, 2}}, + {2339, {wxFontDialog, getFontData, 0}}, + {2341, {wxFontDialog, 'Destroy', undefined}}, + {2342, {wxProgressDialog, new, 3}}, + {2343, {wxProgressDialog, destruct, 0}}, + {2344, {wxProgressDialog, resume, 0}}, + {2345, {wxProgressDialog, update_2, 2}}, + {2346, {wxProgressDialog, update_0, 0}}, + {2347, {wxMessageDialog, new, 3}}, + {2348, {wxMessageDialog, destruct, 0}}, + {2349, {wxPageSetupDialog, new, 2}}, + {2350, {wxPageSetupDialog, destruct, 0}}, + {2351, {wxPageSetupDialog, getPageSetupData, 0}}, + {2352, {wxPageSetupDialog, showModal, 0}}, + {2353, {wxPageSetupDialogData, new_0, 0}}, + {2354, {wxPageSetupDialogData, new_1_0, 1}}, + {2355, {wxPageSetupDialogData, new_1_1, 1}}, + {2356, {wxPageSetupDialogData, destruct, 0}}, + {2357, {wxPageSetupDialogData, enableHelp, 1}}, + {2358, {wxPageSetupDialogData, enableMargins, 1}}, + {2359, {wxPageSetupDialogData, enableOrientation, 1}}, + {2360, {wxPageSetupDialogData, enablePaper, 1}}, + {2361, {wxPageSetupDialogData, enablePrinter, 1}}, + {2362, {wxPageSetupDialogData, getDefaultMinMargins, 0}}, + {2363, {wxPageSetupDialogData, getEnableMargins, 0}}, + {2364, {wxPageSetupDialogData, getEnableOrientation, 0}}, + {2365, {wxPageSetupDialogData, getEnablePaper, 0}}, + {2366, {wxPageSetupDialogData, getEnablePrinter, 0}}, + {2367, {wxPageSetupDialogData, getEnableHelp, 0}}, + {2368, {wxPageSetupDialogData, getDefaultInfo, 0}}, + {2369, {wxPageSetupDialogData, getMarginTopLeft, 0}}, + {2370, {wxPageSetupDialogData, getMarginBottomRight, 0}}, + {2371, {wxPageSetupDialogData, getMinMarginTopLeft, 0}}, + {2372, {wxPageSetupDialogData, getMinMarginBottomRight, 0}}, + {2373, {wxPageSetupDialogData, getPaperId, 0}}, + {2374, {wxPageSetupDialogData, getPaperSize, 0}}, + {2376, {wxPageSetupDialogData, getPrintData, 0}}, + {2377, {wxPageSetupDialogData, isOk, 0}}, + {2378, {wxPageSetupDialogData, setDefaultInfo, 1}}, + {2379, {wxPageSetupDialogData, setDefaultMinMargins, 1}}, + {2380, {wxPageSetupDialogData, setMarginTopLeft, 1}}, + {2381, {wxPageSetupDialogData, setMarginBottomRight, 1}}, + {2382, {wxPageSetupDialogData, setMinMarginTopLeft, 1}}, + {2383, {wxPageSetupDialogData, setMinMarginBottomRight, 1}}, + {2384, {wxPageSetupDialogData, setPaperId, 1}}, + {2385, {wxPageSetupDialogData, setPaperSize_1_1, 1}}, + {2386, {wxPageSetupDialogData, setPaperSize_1_0, 1}}, + {2387, {wxPageSetupDialogData, setPrintData, 1}}, + {2388, {wxPrintDialog, new_2_0, 2}}, + {2389, {wxPrintDialog, new_2_1, 2}}, + {2390, {wxPrintDialog, destruct, 0}}, + {2391, {wxPrintDialog, getPrintDialogData, 0}}, + {2392, {wxPrintDialog, getPrintDC, 0}}, + {2393, {wxPrintDialogData, new_0, 0}}, + {2394, {wxPrintDialogData, new_1_1, 1}}, + {2395, {wxPrintDialogData, new_1_0, 1}}, + {2396, {wxPrintDialogData, destruct, 0}}, + {2397, {wxPrintDialogData, enableHelp, 1}}, + {2398, {wxPrintDialogData, enablePageNumbers, 1}}, + {2399, {wxPrintDialogData, enablePrintToFile, 1}}, + {2400, {wxPrintDialogData, enableSelection, 1}}, + {2401, {wxPrintDialogData, getAllPages, 0}}, + {2402, {wxPrintDialogData, getCollate, 0}}, + {2403, {wxPrintDialogData, getFromPage, 0}}, + {2404, {wxPrintDialogData, getMaxPage, 0}}, + {2405, {wxPrintDialogData, getMinPage, 0}}, + {2406, {wxPrintDialogData, getNoCopies, 0}}, + {2407, {wxPrintDialogData, getPrintData, 0}}, + {2408, {wxPrintDialogData, getPrintToFile, 0}}, + {2409, {wxPrintDialogData, getSelection, 0}}, + {2410, {wxPrintDialogData, getToPage, 0}}, + {2411, {wxPrintDialogData, isOk, 0}}, + {2412, {wxPrintDialogData, setCollate, 1}}, + {2413, {wxPrintDialogData, setFromPage, 1}}, + {2414, {wxPrintDialogData, setMaxPage, 1}}, + {2415, {wxPrintDialogData, setMinPage, 1}}, + {2416, {wxPrintDialogData, setNoCopies, 1}}, + {2417, {wxPrintDialogData, setPrintData, 1}}, + {2418, {wxPrintDialogData, setPrintToFile, 1}}, + {2419, {wxPrintDialogData, setSelection, 1}}, + {2420, {wxPrintDialogData, setToPage, 1}}, + {2421, {wxPrintData, new_0, 0}}, + {2422, {wxPrintData, new_1, 1}}, + {2423, {wxPrintData, destruct, 0}}, + {2424, {wxPrintData, getCollate, 0}}, + {2425, {wxPrintData, getBin, 0}}, + {2426, {wxPrintData, getColour, 0}}, + {2427, {wxPrintData, getDuplex, 0}}, + {2428, {wxPrintData, getNoCopies, 0}}, + {2429, {wxPrintData, getOrientation, 0}}, + {2430, {wxPrintData, getPaperId, 0}}, + {2431, {wxPrintData, getPrinterName, 0}}, + {2432, {wxPrintData, getQuality, 0}}, + {2433, {wxPrintData, isOk, 0}}, + {2434, {wxPrintData, setBin, 1}}, + {2435, {wxPrintData, setCollate, 1}}, + {2436, {wxPrintData, setColour, 1}}, + {2437, {wxPrintData, setDuplex, 1}}, + {2438, {wxPrintData, setNoCopies, 1}}, + {2439, {wxPrintData, setOrientation, 1}}, + {2440, {wxPrintData, setPaperId, 1}}, + {2441, {wxPrintData, setPrinterName, 1}}, + {2442, {wxPrintData, setQuality, 1}}, + {2445, {wxPrintPreview, new_2, 2}}, + {2446, {wxPrintPreview, new_3, 3}}, + {2448, {wxPrintPreview, destruct, 0}}, + {2449, {wxPrintPreview, getCanvas, 0}}, + {2450, {wxPrintPreview, getCurrentPage, 0}}, + {2451, {wxPrintPreview, getFrame, 0}}, + {2452, {wxPrintPreview, getMaxPage, 0}}, + {2453, {wxPrintPreview, getMinPage, 0}}, + {2454, {wxPrintPreview, getPrintout, 0}}, + {2455, {wxPrintPreview, getPrintoutForPrinting, 0}}, + {2456, {wxPrintPreview, isOk, 0}}, + {2457, {wxPrintPreview, paintPage, 2}}, + {2458, {wxPrintPreview, print, 1}}, + {2459, {wxPrintPreview, renderPage, 1}}, + {2460, {wxPrintPreview, setCanvas, 1}}, + {2461, {wxPrintPreview, setCurrentPage, 1}}, + {2462, {wxPrintPreview, setFrame, 1}}, + {2463, {wxPrintPreview, setPrintout, 1}}, + {2464, {wxPrintPreview, setZoom, 1}}, + {2465, {wxPreviewFrame, new, 3}}, + {2466, {wxPreviewFrame, destruct, 0}}, + {2467, {wxPreviewFrame, createControlBar, 0}}, + {2468, {wxPreviewFrame, createCanvas, 0}}, + {2469, {wxPreviewFrame, initialize, 0}}, + {2470, {wxPreviewFrame, onCloseWindow, 1}}, + {2471, {wxPreviewControlBar, new, 4}}, + {2472, {wxPreviewControlBar, destruct, 0}}, + {2473, {wxPreviewControlBar, createButtons, 0}}, + {2474, {wxPreviewControlBar, getPrintPreview, 0}}, + {2475, {wxPreviewControlBar, getZoomControl, 0}}, + {2476, {wxPreviewControlBar, setZoomControl, 1}}, + {2478, {wxPrinter, new, 1}}, + {2479, {wxPrinter, createAbortWindow, 2}}, + {2480, {wxPrinter, getAbort, 0}}, + {2481, {wxPrinter, getLastError, 0}}, + {2482, {wxPrinter, getPrintDialogData, 0}}, + {2483, {wxPrinter, print, 3}}, + {2484, {wxPrinter, printDialog, 1}}, + {2485, {wxPrinter, reportError, 3}}, + {2486, {wxPrinter, setup, 1}}, + {2487, {wxPrinter, 'Destroy', undefined}}, + {2488, {wxXmlResource, new_1, 1}}, + {2489, {wxXmlResource, new_2, 2}}, + {2490, {wxXmlResource, destruct, 0}}, + {2491, {wxXmlResource, attachUnknownControl, 3}}, + {2492, {wxXmlResource, clearHandlers, 0}}, + {2493, {wxXmlResource, compareVersion, 4}}, + {2494, {wxXmlResource, get, 0}}, + {2495, {wxXmlResource, getFlags, 0}}, + {2496, {wxXmlResource, getVersion, 0}}, + {2497, {wxXmlResource, getXRCID, 2}}, + {2498, {wxXmlResource, initAllHandlers, 0}}, + {2499, {wxXmlResource, load, 1}}, + {2500, {wxXmlResource, loadBitmap, 1}}, + {2501, {wxXmlResource, loadDialog_2, 2}}, + {2502, {wxXmlResource, loadDialog_3, 3}}, + {2503, {wxXmlResource, loadFrame_2, 2}}, + {2504, {wxXmlResource, loadFrame_3, 3}}, + {2505, {wxXmlResource, loadIcon, 1}}, + {2506, {wxXmlResource, loadMenu, 1}}, + {2507, {wxXmlResource, loadMenuBar_2, 2}}, + {2508, {wxXmlResource, loadMenuBar_1, 1}}, + {2509, {wxXmlResource, loadPanel_2, 2}}, + {2510, {wxXmlResource, loadPanel_3, 3}}, + {2511, {wxXmlResource, loadToolBar, 2}}, + {2512, {wxXmlResource, set, 1}}, + {2513, {wxXmlResource, setFlags, 1}}, + {2514, {wxXmlResource, unload, 1}}, + {2515, {wxXmlResource, xrcctrl, 3}}, + {2516, {wxHtmlEasyPrinting, new, 1}}, + {2517, {wxHtmlEasyPrinting, destruct, 0}}, + {2518, {wxHtmlEasyPrinting, getPrintData, 0}}, + {2519, {wxHtmlEasyPrinting, getPageSetupData, 0}}, + {2520, {wxHtmlEasyPrinting, previewFile, 1}}, + {2521, {wxHtmlEasyPrinting, previewText, 2}}, + {2522, {wxHtmlEasyPrinting, printFile, 1}}, + {2523, {wxHtmlEasyPrinting, printText, 2}}, + {2524, {wxHtmlEasyPrinting, pageSetup, 0}}, + {2525, {wxHtmlEasyPrinting, setFonts, 3}}, + {2526, {wxHtmlEasyPrinting, setHeader, 2}}, + {2527, {wxHtmlEasyPrinting, setFooter, 2}}, + {2529, {wxGLCanvas, new_2, 2}}, + {2530, {wxGLCanvas, new_3_1, 3}}, + {2531, {wxGLCanvas, new_3_0, 3}}, + {2532, {wxGLCanvas, getContext, 0}}, + {2534, {wxGLCanvas, setCurrent, 0}}, + {2535, {wxGLCanvas, swapBuffers, 0}}, + {2536, {wxGLCanvas, 'Destroy', undefined}}, + {2537, {wxAuiManager, new, 1}}, + {2538, {wxAuiManager, destruct, 0}}, + {2539, {wxAuiManager, addPane_2_1, 2}}, + {2540, {wxAuiManager, addPane_3, 3}}, + {2541, {wxAuiManager, addPane_2_0, 2}}, + {2542, {wxAuiManager, detachPane, 1}}, + {2543, {wxAuiManager, getAllPanes, 0}}, + {2544, {wxAuiManager, getArtProvider, 0}}, + {2545, {wxAuiManager, getDockSizeConstraint, 2}}, + {2546, {wxAuiManager, getFlags, 0}}, + {2547, {wxAuiManager, getManagedWindow, 0}}, + {2548, {wxAuiManager, getManager, 1}}, + {2549, {wxAuiManager, getPane_1_1, 1}}, + {2550, {wxAuiManager, getPane_1_0, 1}}, + {2551, {wxAuiManager, hideHint, 0}}, + {2552, {wxAuiManager, insertPane, 3}}, + {2553, {wxAuiManager, loadPaneInfo, 2}}, + {2554, {wxAuiManager, loadPerspective, 2}}, + {2555, {wxAuiManager, savePaneInfo, 1}}, + {2556, {wxAuiManager, savePerspective, 0}}, + {2557, {wxAuiManager, setArtProvider, 1}}, + {2558, {wxAuiManager, setDockSizeConstraint, 2}}, + {2559, {wxAuiManager, setFlags, 1}}, + {2560, {wxAuiManager, setManagedWindow, 1}}, + {2561, {wxAuiManager, showHint, 1}}, + {2562, {wxAuiManager, unInit, 0}}, + {2563, {wxAuiManager, update, 0}}, + {2564, {wxAuiPaneInfo, new_0, 0}}, + {2565, {wxAuiPaneInfo, new_1, 1}}, + {2566, {wxAuiPaneInfo, destruct, 0}}, + {2567, {wxAuiPaneInfo, bestSize_1, 1}}, + {2568, {wxAuiPaneInfo, bestSize_2, 2}}, + {2569, {wxAuiPaneInfo, bottom, 0}}, + {2570, {wxAuiPaneInfo, bottomDockable, 1}}, + {2571, {wxAuiPaneInfo, caption, 1}}, + {2572, {wxAuiPaneInfo, captionVisible, 1}}, + {2573, {wxAuiPaneInfo, centre, 0}}, + {2574, {wxAuiPaneInfo, centrePane, 0}}, + {2575, {wxAuiPaneInfo, closeButton, 1}}, + {2576, {wxAuiPaneInfo, defaultPane, 0}}, + {2577, {wxAuiPaneInfo, destroyOnClose, 1}}, + {2578, {wxAuiPaneInfo, direction, 1}}, + {2579, {wxAuiPaneInfo, dock, 0}}, + {2580, {wxAuiPaneInfo, dockable, 1}}, + {2581, {wxAuiPaneInfo, fixed, 0}}, + {2582, {wxAuiPaneInfo, float, 0}}, + {2583, {wxAuiPaneInfo, floatable, 1}}, + {2584, {wxAuiPaneInfo, floatingPosition_1, 1}}, + {2585, {wxAuiPaneInfo, floatingPosition_2, 2}}, + {2586, {wxAuiPaneInfo, floatingSize_1, 1}}, + {2587, {wxAuiPaneInfo, floatingSize_2, 2}}, + {2588, {wxAuiPaneInfo, gripper, 1}}, + {2589, {wxAuiPaneInfo, gripperTop, 1}}, + {2590, {wxAuiPaneInfo, hasBorder, 0}}, + {2591, {wxAuiPaneInfo, hasCaption, 0}}, + {2592, {wxAuiPaneInfo, hasCloseButton, 0}}, + {2593, {wxAuiPaneInfo, hasFlag, 1}}, + {2594, {wxAuiPaneInfo, hasGripper, 0}}, + {2595, {wxAuiPaneInfo, hasGripperTop, 0}}, + {2596, {wxAuiPaneInfo, hasMaximizeButton, 0}}, + {2597, {wxAuiPaneInfo, hasMinimizeButton, 0}}, + {2598, {wxAuiPaneInfo, hasPinButton, 0}}, + {2599, {wxAuiPaneInfo, hide, 0}}, + {2600, {wxAuiPaneInfo, isBottomDockable, 0}}, + {2601, {wxAuiPaneInfo, isDocked, 0}}, + {2602, {wxAuiPaneInfo, isFixed, 0}}, + {2603, {wxAuiPaneInfo, isFloatable, 0}}, + {2604, {wxAuiPaneInfo, isFloating, 0}}, + {2605, {wxAuiPaneInfo, isLeftDockable, 0}}, + {2606, {wxAuiPaneInfo, isMovable, 0}}, + {2607, {wxAuiPaneInfo, isOk, 0}}, + {2608, {wxAuiPaneInfo, isResizable, 0}}, + {2609, {wxAuiPaneInfo, isRightDockable, 0}}, + {2610, {wxAuiPaneInfo, isShown, 0}}, + {2611, {wxAuiPaneInfo, isToolbar, 0}}, + {2612, {wxAuiPaneInfo, isTopDockable, 0}}, + {2613, {wxAuiPaneInfo, layer, 1}}, + {2614, {wxAuiPaneInfo, left, 0}}, + {2615, {wxAuiPaneInfo, leftDockable, 1}}, + {2616, {wxAuiPaneInfo, maxSize_1, 1}}, + {2617, {wxAuiPaneInfo, maxSize_2, 2}}, + {2618, {wxAuiPaneInfo, maximizeButton, 1}}, + {2619, {wxAuiPaneInfo, minSize_1, 1}}, + {2620, {wxAuiPaneInfo, minSize_2, 2}}, + {2621, {wxAuiPaneInfo, minimizeButton, 1}}, + {2622, {wxAuiPaneInfo, movable, 1}}, + {2623, {wxAuiPaneInfo, name, 1}}, + {2624, {wxAuiPaneInfo, paneBorder, 1}}, + {2625, {wxAuiPaneInfo, pinButton, 1}}, + {2626, {wxAuiPaneInfo, position, 1}}, + {2627, {wxAuiPaneInfo, resizable, 1}}, + {2628, {wxAuiPaneInfo, right, 0}}, + {2629, {wxAuiPaneInfo, rightDockable, 1}}, + {2630, {wxAuiPaneInfo, row, 1}}, + {2631, {wxAuiPaneInfo, safeSet, 1}}, + {2632, {wxAuiPaneInfo, setFlag, 2}}, + {2633, {wxAuiPaneInfo, show, 1}}, + {2634, {wxAuiPaneInfo, toolbarPane, 0}}, + {2635, {wxAuiPaneInfo, top, 0}}, + {2636, {wxAuiPaneInfo, topDockable, 1}}, + {2637, {wxAuiPaneInfo, window, 1}}, + {2638, {wxAuiNotebook, new_0, 0}}, + {2639, {wxAuiNotebook, new_2, 2}}, + {2640, {wxAuiNotebook, addPage, 3}}, + {2641, {wxAuiNotebook, create, 2}}, + {2642, {wxAuiNotebook, deletePage, 1}}, + {2643, {wxAuiNotebook, getArtProvider, 0}}, + {2644, {wxAuiNotebook, getPage, 1}}, + {2645, {wxAuiNotebook, getPageBitmap, 1}}, + {2646, {wxAuiNotebook, getPageCount, 0}}, + {2647, {wxAuiNotebook, getPageIndex, 1}}, + {2648, {wxAuiNotebook, getPageText, 1}}, + {2649, {wxAuiNotebook, getSelection, 0}}, + {2650, {wxAuiNotebook, insertPage, 4}}, + {2651, {wxAuiNotebook, removePage, 1}}, + {2652, {wxAuiNotebook, setArtProvider, 1}}, + {2653, {wxAuiNotebook, setFont, 1}}, + {2654, {wxAuiNotebook, setPageBitmap, 2}}, + {2655, {wxAuiNotebook, setPageText, 2}}, + {2656, {wxAuiNotebook, setSelection, 1}}, + {2657, {wxAuiNotebook, setTabCtrlHeight, 1}}, + {2658, {wxAuiNotebook, setUniformBitmapSize, 1}}, + {2659, {wxAuiNotebook, 'Destroy', undefined}}, + {2660, {wxMDIParentFrame, new_0, 0}}, + {2661, {wxMDIParentFrame, new_4, 4}}, + {2662, {wxMDIParentFrame, destruct, 0}}, + {2663, {wxMDIParentFrame, activateNext, 0}}, + {2664, {wxMDIParentFrame, activatePrevious, 0}}, + {2665, {wxMDIParentFrame, arrangeIcons, 0}}, + {2666, {wxMDIParentFrame, cascade, 0}}, + {2667, {wxMDIParentFrame, create, 4}}, + {2668, {wxMDIParentFrame, getActiveChild, 0}}, + {2669, {wxMDIParentFrame, getClientWindow, 0}}, + {2670, {wxMDIParentFrame, tile, 1}}, + {2671, {wxMDIChildFrame, new_0, 0}}, + {2672, {wxMDIChildFrame, new_4, 4}}, + {2673, {wxMDIChildFrame, destruct, 0}}, + {2674, {wxMDIChildFrame, activate, 0}}, + {2675, {wxMDIChildFrame, create, 4}}, + {2676, {wxMDIChildFrame, maximize, 1}}, + {2677, {wxMDIChildFrame, restore, 0}}, + {2678, {wxMDIClientWindow, new_0, 0}}, + {2679, {wxMDIClientWindow, new_2, 2}}, + {2680, {wxMDIClientWindow, destruct, 0}}, + {2681, {wxMDIClientWindow, createClient, 2}}, + {2682, {wxLayoutAlgorithm, new, 0}}, + {2683, {wxLayoutAlgorithm, layoutFrame, 2}}, + {2684, {wxLayoutAlgorithm, layoutMDIFrame, 2}}, + {2685, {wxLayoutAlgorithm, layoutWindow, 2}}, + {2686, {wxLayoutAlgorithm, 'Destroy', undefined}}, + {2687, {wxEvent, getId, 0}}, + {2688, {wxEvent, getSkipped, 0}}, + {2689, {wxEvent, getTimestamp, 0}}, + {2690, {wxEvent, isCommandEvent, 0}}, + {2691, {wxEvent, resumePropagation, 1}}, + {2692, {wxEvent, shouldPropagate, 0}}, + {2693, {wxEvent, skip, 1}}, + {2694, {wxEvent, stopPropagation, 0}}, + {2695, {wxCommandEvent, getClientData, 0}}, + {2696, {wxCommandEvent, getExtraLong, 0}}, + {2697, {wxCommandEvent, getInt, 0}}, + {2698, {wxCommandEvent, getSelection, 0}}, + {2699, {wxCommandEvent, getString, 0}}, + {2700, {wxCommandEvent, isChecked, 0}}, + {2701, {wxCommandEvent, isSelection, 0}}, + {2702, {wxCommandEvent, setInt, 1}}, + {2703, {wxCommandEvent, setString, 1}}, + {2704, {wxScrollEvent, getOrientation, 0}}, + {2705, {wxScrollEvent, getPosition, 0}}, + {2706, {wxScrollWinEvent, getOrientation, 0}}, + {2707, {wxScrollWinEvent, getPosition, 0}}, + {2708, {wxMouseEvent, altDown, 0}}, + {2709, {wxMouseEvent, button, 1}}, + {2710, {wxMouseEvent, buttonDClick, 1}}, + {2711, {wxMouseEvent, buttonDown, 1}}, + {2712, {wxMouseEvent, buttonUp, 1}}, + {2713, {wxMouseEvent, cmdDown, 0}}, + {2714, {wxMouseEvent, controlDown, 0}}, + {2715, {wxMouseEvent, dragging, 0}}, + {2716, {wxMouseEvent, entering, 0}}, + {2717, {wxMouseEvent, getButton, 0}}, + {2720, {wxMouseEvent, getPosition, 0}}, + {2721, {wxMouseEvent, getLogicalPosition, 1}}, + {2722, {wxMouseEvent, getLinesPerAction, 0}}, + {2723, {wxMouseEvent, getWheelRotation, 0}}, + {2724, {wxMouseEvent, getWheelDelta, 0}}, + {2725, {wxMouseEvent, getX, 0}}, + {2726, {wxMouseEvent, getY, 0}}, + {2727, {wxMouseEvent, isButton, 0}}, + {2728, {wxMouseEvent, isPageScroll, 0}}, + {2729, {wxMouseEvent, leaving, 0}}, + {2730, {wxMouseEvent, leftDClick, 0}}, + {2731, {wxMouseEvent, leftDown, 0}}, + {2732, {wxMouseEvent, leftIsDown, 0}}, + {2733, {wxMouseEvent, leftUp, 0}}, + {2734, {wxMouseEvent, metaDown, 0}}, + {2735, {wxMouseEvent, middleDClick, 0}}, + {2736, {wxMouseEvent, middleDown, 0}}, + {2737, {wxMouseEvent, middleIsDown, 0}}, + {2738, {wxMouseEvent, middleUp, 0}}, + {2739, {wxMouseEvent, moving, 0}}, + {2740, {wxMouseEvent, rightDClick, 0}}, + {2741, {wxMouseEvent, rightDown, 0}}, + {2742, {wxMouseEvent, rightIsDown, 0}}, + {2743, {wxMouseEvent, rightUp, 0}}, + {2744, {wxMouseEvent, shiftDown, 0}}, + {2745, {wxSetCursorEvent, getCursor, 0}}, + {2746, {wxSetCursorEvent, getX, 0}}, + {2747, {wxSetCursorEvent, getY, 0}}, + {2748, {wxSetCursorEvent, hasCursor, 0}}, + {2749, {wxSetCursorEvent, setCursor, 1}}, + {2750, {wxKeyEvent, altDown, 0}}, + {2751, {wxKeyEvent, cmdDown, 0}}, + {2752, {wxKeyEvent, controlDown, 0}}, + {2753, {wxKeyEvent, getKeyCode, 0}}, + {2754, {wxKeyEvent, getModifiers, 0}}, + {2757, {wxKeyEvent, getPosition, 0}}, + {2758, {wxKeyEvent, getRawKeyCode, 0}}, + {2759, {wxKeyEvent, getRawKeyFlags, 0}}, + {2760, {wxKeyEvent, getUnicodeKey, 0}}, + {2761, {wxKeyEvent, getX, 0}}, + {2762, {wxKeyEvent, getY, 0}}, + {2763, {wxKeyEvent, hasModifiers, 0}}, + {2764, {wxKeyEvent, metaDown, 0}}, + {2765, {wxKeyEvent, shiftDown, 0}}, + {2766, {wxSizeEvent, getSize, 0}}, + {2767, {wxMoveEvent, getPosition, 0}}, + {2768, {wxEraseEvent, getDC, 0}}, + {2769, {wxFocusEvent, getWindow, 0}}, + {2770, {wxChildFocusEvent, getWindow, 0}}, + {2771, {wxMenuEvent, getMenu, 0}}, + {2772, {wxMenuEvent, getMenuId, 0}}, + {2773, {wxMenuEvent, isPopup, 0}}, + {2774, {wxCloseEvent, canVeto, 0}}, + {2775, {wxCloseEvent, getLoggingOff, 0}}, + {2776, {wxCloseEvent, setCanVeto, 1}}, + {2777, {wxCloseEvent, setLoggingOff, 1}}, + {2778, {wxCloseEvent, veto, 1}}, + {2779, {wxShowEvent, setShow, 1}}, + {2780, {wxShowEvent, getShow, 0}}, + {2781, {wxIconizeEvent, iconized, 0}}, + {2782, {wxJoystickEvent, buttonDown, 1}}, + {2783, {wxJoystickEvent, buttonIsDown, 1}}, + {2784, {wxJoystickEvent, buttonUp, 1}}, + {2785, {wxJoystickEvent, getButtonChange, 0}}, + {2786, {wxJoystickEvent, getButtonState, 0}}, + {2787, {wxJoystickEvent, getJoystick, 0}}, + {2788, {wxJoystickEvent, getPosition, 0}}, + {2789, {wxJoystickEvent, getZPosition, 0}}, + {2790, {wxJoystickEvent, isButton, 0}}, + {2791, {wxJoystickEvent, isMove, 0}}, + {2792, {wxJoystickEvent, isZMove, 0}}, + {2793, {wxUpdateUIEvent, canUpdate, 1}}, + {2794, {wxUpdateUIEvent, check, 1}}, + {2795, {wxUpdateUIEvent, enable, 1}}, + {2796, {wxUpdateUIEvent, show, 1}}, + {2797, {wxUpdateUIEvent, getChecked, 0}}, + {2798, {wxUpdateUIEvent, getEnabled, 0}}, + {2799, {wxUpdateUIEvent, getShown, 0}}, + {2800, {wxUpdateUIEvent, getSetChecked, 0}}, + {2801, {wxUpdateUIEvent, getSetEnabled, 0}}, + {2802, {wxUpdateUIEvent, getSetShown, 0}}, + {2803, {wxUpdateUIEvent, getSetText, 0}}, + {2804, {wxUpdateUIEvent, getText, 0}}, + {2805, {wxUpdateUIEvent, getMode, 0}}, + {2806, {wxUpdateUIEvent, getUpdateInterval, 0}}, + {2807, {wxUpdateUIEvent, resetUpdateTime, 0}}, + {2808, {wxUpdateUIEvent, setMode, 1}}, + {2809, {wxUpdateUIEvent, setText, 1}}, + {2810, {wxUpdateUIEvent, setUpdateInterval, 1}}, + {2811, {wxMouseCaptureChangedEvent, getCapturedWindow, 0}}, + {2812, {wxPaletteChangedEvent, setChangedWindow, 1}}, + {2813, {wxPaletteChangedEvent, getChangedWindow, 0}}, + {2814, {wxQueryNewPaletteEvent, setPaletteRealized, 1}}, + {2815, {wxQueryNewPaletteEvent, getPaletteRealized, 0}}, + {2816, {wxNavigationKeyEvent, getDirection, 0}}, + {2817, {wxNavigationKeyEvent, setDirection, 1}}, + {2818, {wxNavigationKeyEvent, isWindowChange, 0}}, + {2819, {wxNavigationKeyEvent, setWindowChange, 1}}, + {2820, {wxNavigationKeyEvent, isFromTab, 0}}, + {2821, {wxNavigationKeyEvent, setFromTab, 1}}, + {2822, {wxNavigationKeyEvent, getCurrentFocus, 0}}, + {2823, {wxNavigationKeyEvent, setCurrentFocus, 1}}, + {2824, {wxHelpEvent, getOrigin, 0}}, + {2825, {wxHelpEvent, getPosition, 0}}, + {2826, {wxHelpEvent, setOrigin, 1}}, + {2827, {wxHelpEvent, setPosition, 1}}, + {2828, {wxContextMenuEvent, getPosition, 0}}, + {2829, {wxContextMenuEvent, setPosition, 1}}, + {2830, {wxIdleEvent, canSend, 1}}, + {2831, {wxIdleEvent, getMode, 0}}, + {2832, {wxIdleEvent, requestMore, 1}}, + {2833, {wxIdleEvent, moreRequested, 0}}, + {2834, {wxIdleEvent, setMode, 1}}, + {2835, {wxGridEvent, altDown, 0}}, + {2836, {wxGridEvent, controlDown, 0}}, + {2837, {wxGridEvent, getCol, 0}}, + {2838, {wxGridEvent, getPosition, 0}}, + {2839, {wxGridEvent, getRow, 0}}, + {2840, {wxGridEvent, metaDown, 0}}, + {2841, {wxGridEvent, selecting, 0}}, + {2842, {wxGridEvent, shiftDown, 0}}, + {2843, {wxNotifyEvent, allow, 0}}, + {2844, {wxNotifyEvent, isAllowed, 0}}, + {2845, {wxNotifyEvent, veto, 0}}, + {2846, {wxSashEvent, getEdge, 0}}, + {2847, {wxSashEvent, getDragRect, 0}}, + {2848, {wxSashEvent, getDragStatus, 0}}, + {2849, {wxListEvent, getCacheFrom, 0}}, + {2850, {wxListEvent, getCacheTo, 0}}, + {2851, {wxListEvent, getKeyCode, 0}}, + {2852, {wxListEvent, getIndex, 0}}, + {2853, {wxListEvent, getColumn, 0}}, + {2854, {wxListEvent, getPoint, 0}}, + {2855, {wxListEvent, getLabel, 0}}, + {2856, {wxListEvent, getText, 0}}, + {2857, {wxListEvent, getImage, 0}}, + {2858, {wxListEvent, getData, 0}}, + {2859, {wxListEvent, getMask, 0}}, + {2860, {wxListEvent, getItem, 0}}, + {2861, {wxListEvent, isEditCancelled, 0}}, + {2862, {wxDateEvent, getDate, 0}}, + {2863, {wxCalendarEvent, getWeekDay, 0}}, + {2864, {wxFileDirPickerEvent, getPath, 0}}, + {2865, {wxColourPickerEvent, getColour, 0}}, + {2866, {wxFontPickerEvent, getFont, 0}}, + {2867, {wxStyledTextEvent, getPosition, 0}}, + {2868, {wxStyledTextEvent, getKey, 0}}, + {2869, {wxStyledTextEvent, getModifiers, 0}}, + {2870, {wxStyledTextEvent, getModificationType, 0}}, + {2871, {wxStyledTextEvent, getText, 0}}, + {2872, {wxStyledTextEvent, getLength, 0}}, + {2873, {wxStyledTextEvent, getLinesAdded, 0}}, + {2874, {wxStyledTextEvent, getLine, 0}}, + {2875, {wxStyledTextEvent, getFoldLevelNow, 0}}, + {2876, {wxStyledTextEvent, getFoldLevelPrev, 0}}, + {2877, {wxStyledTextEvent, getMargin, 0}}, + {2878, {wxStyledTextEvent, getMessage, 0}}, + {2879, {wxStyledTextEvent, getWParam, 0}}, + {2880, {wxStyledTextEvent, getLParam, 0}}, + {2881, {wxStyledTextEvent, getListType, 0}}, + {2882, {wxStyledTextEvent, getX, 0}}, + {2883, {wxStyledTextEvent, getY, 0}}, + {2884, {wxStyledTextEvent, getDragText, 0}}, + {2885, {wxStyledTextEvent, getDragAllowMove, 0}}, + {2886, {wxStyledTextEvent, getDragResult, 0}}, + {2887, {wxStyledTextEvent, getShift, 0}}, + {2888, {wxStyledTextEvent, getControl, 0}}, + {2889, {wxStyledTextEvent, getAlt, 0}}, + {2890, {utils, getKeyState, 1}}, + {2891, {utils, getMousePosition, 2}}, + {2892, {utils, getMouseState, 0}}, + {2893, {utils, setDetectableAutoRepeat, 1}}, + {2894, {utils, bell, 0}}, + {2895, {utils, findMenuItemId, 3}}, + {2896, {utils, genericFindWindowAtPoint, 1}}, + {2897, {utils, findWindowAtPoint, 1}}, + {2898, {utils, beginBusyCursor, 1}}, + {2899, {utils, endBusyCursor, 0}}, + {2900, {utils, isBusy, 0}}, + {2901, {utils, shutdown, 1}}, + {2902, {utils, shell, 1}}, + {2903, {utils, launchDefaultBrowser, 2}}, + {2904, {utils, getEmailAddress, 0}}, + {2905, {utils, getUserId, 0}}, + {2906, {utils, getHomeDir, 0}}, + {2907, {utils, newId, 0}}, + {2908, {utils, registerId, 1}}, + {2909, {utils, getCurrentId, 0}}, + {2910, {utils, getOsDescription, 0}}, + {2911, {utils, isPlatformLittleEndian, 0}}, + {2912, {utils, isPlatform64Bit, 0}}, + {2913, {wxPrintout, new, 1}}, + {2914, {wxPrintout, destruct, 0}}, + {2915, {wxPrintout, getDC, 0}}, + {2916, {wxPrintout, getPageSizeMM, 2}}, + {2917, {wxPrintout, getPageSizePixels, 2}}, + {2918, {wxPrintout, getPaperRectPixels, 0}}, + {2919, {wxPrintout, getPPIPrinter, 2}}, + {2920, {wxPrintout, getPPIScreen, 2}}, + {2921, {wxPrintout, getTitle, 0}}, + {2922, {wxPrintout, isPreview, 0}}, + {2923, {wxPrintout, fitThisSizeToPaper, 1}}, + {2924, {wxPrintout, fitThisSizeToPage, 1}}, + {2925, {wxPrintout, fitThisSizeToPageMargins, 2}}, + {2926, {wxPrintout, mapScreenSizeToPaper, 0}}, + {2927, {wxPrintout, mapScreenSizeToPage, 0}}, + {2928, {wxPrintout, mapScreenSizeToPageMargins, 1}}, + {2929, {wxPrintout, mapScreenSizeToDevice, 0}}, + {2930, {wxPrintout, getLogicalPaperRect, 0}}, + {2931, {wxPrintout, getLogicalPageRect, 0}}, + {2932, {wxPrintout, getLogicalPageMarginsRect, 1}}, + {2933, {wxPrintout, setLogicalOrigin, 2}}, + {2934, {wxPrintout, offsetLogicalOrigin, 2}}, + {2935, {wxStyledTextCtrl, new_2, 2}}, + {2936, {wxStyledTextCtrl, new_0, 0}}, + {2937, {wxStyledTextCtrl, destruct, 0}}, + {2938, {wxStyledTextCtrl, create, 2}}, + {2939, {wxStyledTextCtrl, addText, 1}}, + {2940, {wxStyledTextCtrl, addStyledText, 1}}, + {2941, {wxStyledTextCtrl, insertText, 2}}, + {2942, {wxStyledTextCtrl, clearAll, 0}}, + {2943, {wxStyledTextCtrl, clearDocumentStyle, 0}}, + {2944, {wxStyledTextCtrl, getLength, 0}}, + {2945, {wxStyledTextCtrl, getCharAt, 1}}, + {2946, {wxStyledTextCtrl, getCurrentPos, 0}}, + {2947, {wxStyledTextCtrl, getAnchor, 0}}, + {2948, {wxStyledTextCtrl, getStyleAt, 1}}, + {2949, {wxStyledTextCtrl, redo, 0}}, + {2950, {wxStyledTextCtrl, setUndoCollection, 1}}, + {2951, {wxStyledTextCtrl, selectAll, 0}}, + {2952, {wxStyledTextCtrl, setSavePoint, 0}}, + {2953, {wxStyledTextCtrl, getStyledText, 2}}, + {2954, {wxStyledTextCtrl, canRedo, 0}}, + {2955, {wxStyledTextCtrl, markerLineFromHandle, 1}}, + {2956, {wxStyledTextCtrl, markerDeleteHandle, 1}}, + {2957, {wxStyledTextCtrl, getUndoCollection, 0}}, + {2958, {wxStyledTextCtrl, getViewWhiteSpace, 0}}, + {2959, {wxStyledTextCtrl, setViewWhiteSpace, 1}}, + {2960, {wxStyledTextCtrl, positionFromPoint, 1}}, + {2961, {wxStyledTextCtrl, positionFromPointClose, 2}}, + {2962, {wxStyledTextCtrl, gotoLine, 1}}, + {2963, {wxStyledTextCtrl, gotoPos, 1}}, + {2964, {wxStyledTextCtrl, setAnchor, 1}}, + {2965, {wxStyledTextCtrl, getCurLine, 1}}, + {2966, {wxStyledTextCtrl, getEndStyled, 0}}, + {2967, {wxStyledTextCtrl, convertEOLs, 1}}, + {2968, {wxStyledTextCtrl, getEOLMode, 0}}, + {2969, {wxStyledTextCtrl, setEOLMode, 1}}, + {2970, {wxStyledTextCtrl, startStyling, 2}}, + {2971, {wxStyledTextCtrl, setStyling, 2}}, + {2972, {wxStyledTextCtrl, getBufferedDraw, 0}}, + {2973, {wxStyledTextCtrl, setBufferedDraw, 1}}, + {2974, {wxStyledTextCtrl, setTabWidth, 1}}, + {2975, {wxStyledTextCtrl, getTabWidth, 0}}, + {2976, {wxStyledTextCtrl, setCodePage, 1}}, + {2977, {wxStyledTextCtrl, markerDefine, 3}}, + {2978, {wxStyledTextCtrl, markerSetForeground, 2}}, + {2979, {wxStyledTextCtrl, markerSetBackground, 2}}, + {2980, {wxStyledTextCtrl, markerAdd, 2}}, + {2981, {wxStyledTextCtrl, markerDelete, 2}}, + {2982, {wxStyledTextCtrl, markerDeleteAll, 1}}, + {2983, {wxStyledTextCtrl, markerGet, 1}}, + {2984, {wxStyledTextCtrl, markerNext, 2}}, + {2985, {wxStyledTextCtrl, markerPrevious, 2}}, + {2986, {wxStyledTextCtrl, markerDefineBitmap, 2}}, + {2987, {wxStyledTextCtrl, markerAddSet, 2}}, + {2988, {wxStyledTextCtrl, markerSetAlpha, 2}}, + {2989, {wxStyledTextCtrl, setMarginType, 2}}, + {2990, {wxStyledTextCtrl, getMarginType, 1}}, + {2991, {wxStyledTextCtrl, setMarginWidth, 2}}, + {2992, {wxStyledTextCtrl, getMarginWidth, 1}}, + {2993, {wxStyledTextCtrl, setMarginMask, 2}}, + {2994, {wxStyledTextCtrl, getMarginMask, 1}}, + {2995, {wxStyledTextCtrl, setMarginSensitive, 2}}, + {2996, {wxStyledTextCtrl, getMarginSensitive, 1}}, + {2997, {wxStyledTextCtrl, styleClearAll, 0}}, + {2998, {wxStyledTextCtrl, styleSetForeground, 2}}, + {2999, {wxStyledTextCtrl, styleSetBackground, 2}}, + {3000, {wxStyledTextCtrl, styleSetBold, 2}}, + {3001, {wxStyledTextCtrl, styleSetItalic, 2}}, + {3002, {wxStyledTextCtrl, styleSetSize, 2}}, + {3003, {wxStyledTextCtrl, styleSetFaceName, 2}}, + {3004, {wxStyledTextCtrl, styleSetEOLFilled, 2}}, + {3005, {wxStyledTextCtrl, styleResetDefault, 0}}, + {3006, {wxStyledTextCtrl, styleSetUnderline, 2}}, + {3007, {wxStyledTextCtrl, styleSetCase, 2}}, + {3008, {wxStyledTextCtrl, styleSetHotSpot, 2}}, + {3009, {wxStyledTextCtrl, setSelForeground, 2}}, + {3010, {wxStyledTextCtrl, setSelBackground, 2}}, + {3011, {wxStyledTextCtrl, getSelAlpha, 0}}, + {3012, {wxStyledTextCtrl, setSelAlpha, 1}}, + {3013, {wxStyledTextCtrl, setCaretForeground, 1}}, + {3014, {wxStyledTextCtrl, cmdKeyAssign, 3}}, + {3015, {wxStyledTextCtrl, cmdKeyClear, 2}}, + {3016, {wxStyledTextCtrl, cmdKeyClearAll, 0}}, + {3017, {wxStyledTextCtrl, setStyleBytes, 2}}, + {3018, {wxStyledTextCtrl, styleSetVisible, 2}}, + {3019, {wxStyledTextCtrl, getCaretPeriod, 0}}, + {3020, {wxStyledTextCtrl, setCaretPeriod, 1}}, + {3021, {wxStyledTextCtrl, setWordChars, 1}}, + {3022, {wxStyledTextCtrl, beginUndoAction, 0}}, + {3023, {wxStyledTextCtrl, endUndoAction, 0}}, + {3024, {wxStyledTextCtrl, indicatorSetStyle, 2}}, + {3025, {wxStyledTextCtrl, indicatorGetStyle, 1}}, + {3026, {wxStyledTextCtrl, indicatorSetForeground, 2}}, + {3027, {wxStyledTextCtrl, indicatorGetForeground, 1}}, + {3028, {wxStyledTextCtrl, setWhitespaceForeground, 2}}, + {3029, {wxStyledTextCtrl, setWhitespaceBackground, 2}}, + {3030, {wxStyledTextCtrl, getStyleBits, 0}}, + {3031, {wxStyledTextCtrl, setLineState, 2}}, + {3032, {wxStyledTextCtrl, getLineState, 1}}, + {3033, {wxStyledTextCtrl, getMaxLineState, 0}}, + {3034, {wxStyledTextCtrl, getCaretLineVisible, 0}}, + {3035, {wxStyledTextCtrl, setCaretLineVisible, 1}}, + {3036, {wxStyledTextCtrl, getCaretLineBackground, 0}}, + {3037, {wxStyledTextCtrl, setCaretLineBackground, 1}}, + {3038, {wxStyledTextCtrl, autoCompShow, 2}}, + {3039, {wxStyledTextCtrl, autoCompCancel, 0}}, + {3040, {wxStyledTextCtrl, autoCompActive, 0}}, + {3041, {wxStyledTextCtrl, autoCompPosStart, 0}}, + {3042, {wxStyledTextCtrl, autoCompComplete, 0}}, + {3043, {wxStyledTextCtrl, autoCompStops, 1}}, + {3044, {wxStyledTextCtrl, autoCompSetSeparator, 1}}, + {3045, {wxStyledTextCtrl, autoCompGetSeparator, 0}}, + {3046, {wxStyledTextCtrl, autoCompSelect, 1}}, + {3047, {wxStyledTextCtrl, autoCompSetCancelAtStart, 1}}, + {3048, {wxStyledTextCtrl, autoCompGetCancelAtStart, 0}}, + {3049, {wxStyledTextCtrl, autoCompSetFillUps, 1}}, + {3050, {wxStyledTextCtrl, autoCompSetChooseSingle, 1}}, + {3051, {wxStyledTextCtrl, autoCompGetChooseSingle, 0}}, + {3052, {wxStyledTextCtrl, autoCompSetIgnoreCase, 1}}, + {3053, {wxStyledTextCtrl, autoCompGetIgnoreCase, 0}}, + {3054, {wxStyledTextCtrl, userListShow, 2}}, + {3055, {wxStyledTextCtrl, autoCompSetAutoHide, 1}}, + {3056, {wxStyledTextCtrl, autoCompGetAutoHide, 0}}, + {3057, {wxStyledTextCtrl, autoCompSetDropRestOfWord, 1}}, + {3058, {wxStyledTextCtrl, autoCompGetDropRestOfWord, 0}}, + {3059, {wxStyledTextCtrl, registerImage, 2}}, + {3060, {wxStyledTextCtrl, clearRegisteredImages, 0}}, + {3061, {wxStyledTextCtrl, autoCompGetTypeSeparator, 0}}, + {3062, {wxStyledTextCtrl, autoCompSetTypeSeparator, 1}}, + {3063, {wxStyledTextCtrl, autoCompSetMaxWidth, 1}}, + {3064, {wxStyledTextCtrl, autoCompGetMaxWidth, 0}}, + {3065, {wxStyledTextCtrl, autoCompSetMaxHeight, 1}}, + {3066, {wxStyledTextCtrl, autoCompGetMaxHeight, 0}}, + {3067, {wxStyledTextCtrl, setIndent, 1}}, + {3068, {wxStyledTextCtrl, getIndent, 0}}, + {3069, {wxStyledTextCtrl, setUseTabs, 1}}, + {3070, {wxStyledTextCtrl, getUseTabs, 0}}, + {3071, {wxStyledTextCtrl, setLineIndentation, 2}}, + {3072, {wxStyledTextCtrl, getLineIndentation, 1}}, + {3073, {wxStyledTextCtrl, getLineIndentPosition, 1}}, + {3074, {wxStyledTextCtrl, getColumn, 1}}, + {3075, {wxStyledTextCtrl, setUseHorizontalScrollBar, 1}}, + {3076, {wxStyledTextCtrl, getUseHorizontalScrollBar, 0}}, + {3077, {wxStyledTextCtrl, setIndentationGuides, 1}}, + {3078, {wxStyledTextCtrl, getIndentationGuides, 0}}, + {3079, {wxStyledTextCtrl, setHighlightGuide, 1}}, + {3080, {wxStyledTextCtrl, getHighlightGuide, 0}}, + {3081, {wxStyledTextCtrl, getLineEndPosition, 1}}, + {3082, {wxStyledTextCtrl, getCodePage, 0}}, + {3083, {wxStyledTextCtrl, getCaretForeground, 0}}, + {3084, {wxStyledTextCtrl, getReadOnly, 0}}, + {3085, {wxStyledTextCtrl, setCurrentPos, 1}}, + {3086, {wxStyledTextCtrl, setSelectionStart, 1}}, + {3087, {wxStyledTextCtrl, getSelectionStart, 0}}, + {3088, {wxStyledTextCtrl, setSelectionEnd, 1}}, + {3089, {wxStyledTextCtrl, getSelectionEnd, 0}}, + {3090, {wxStyledTextCtrl, setPrintMagnification, 1}}, + {3091, {wxStyledTextCtrl, getPrintMagnification, 0}}, + {3092, {wxStyledTextCtrl, setPrintColourMode, 1}}, + {3093, {wxStyledTextCtrl, getPrintColourMode, 0}}, + {3094, {wxStyledTextCtrl, findText, 4}}, + {3095, {wxStyledTextCtrl, formatRange, 7}}, + {3096, {wxStyledTextCtrl, getFirstVisibleLine, 0}}, + {3097, {wxStyledTextCtrl, getLine, 1}}, + {3098, {wxStyledTextCtrl, getLineCount, 0}}, + {3099, {wxStyledTextCtrl, setMarginLeft, 1}}, + {3100, {wxStyledTextCtrl, getMarginLeft, 0}}, + {3101, {wxStyledTextCtrl, setMarginRight, 1}}, + {3102, {wxStyledTextCtrl, getMarginRight, 0}}, + {3103, {wxStyledTextCtrl, getModify, 0}}, + {3104, {wxStyledTextCtrl, setSelection, 2}}, + {3105, {wxStyledTextCtrl, getSelectedText, 0}}, + {3106, {wxStyledTextCtrl, getTextRange, 2}}, + {3107, {wxStyledTextCtrl, hideSelection, 1}}, + {3108, {wxStyledTextCtrl, lineFromPosition, 1}}, + {3109, {wxStyledTextCtrl, positionFromLine, 1}}, + {3110, {wxStyledTextCtrl, lineScroll, 2}}, + {3111, {wxStyledTextCtrl, ensureCaretVisible, 0}}, + {3112, {wxStyledTextCtrl, replaceSelection, 1}}, + {3113, {wxStyledTextCtrl, setReadOnly, 1}}, + {3114, {wxStyledTextCtrl, canPaste, 0}}, + {3115, {wxStyledTextCtrl, canUndo, 0}}, + {3116, {wxStyledTextCtrl, emptyUndoBuffer, 0}}, + {3117, {wxStyledTextCtrl, undo, 0}}, + {3118, {wxStyledTextCtrl, cut, 0}}, + {3119, {wxStyledTextCtrl, copy, 0}}, + {3120, {wxStyledTextCtrl, paste, 0}}, + {3121, {wxStyledTextCtrl, clear, 0}}, + {3122, {wxStyledTextCtrl, setText, 1}}, + {3123, {wxStyledTextCtrl, getText, 0}}, + {3124, {wxStyledTextCtrl, getTextLength, 0}}, + {3125, {wxStyledTextCtrl, getOvertype, 0}}, + {3126, {wxStyledTextCtrl, setCaretWidth, 1}}, + {3127, {wxStyledTextCtrl, getCaretWidth, 0}}, + {3128, {wxStyledTextCtrl, setTargetStart, 1}}, + {3129, {wxStyledTextCtrl, getTargetStart, 0}}, + {3130, {wxStyledTextCtrl, setTargetEnd, 1}}, + {3131, {wxStyledTextCtrl, getTargetEnd, 0}}, + {3132, {wxStyledTextCtrl, replaceTarget, 1}}, + {3133, {wxStyledTextCtrl, searchInTarget, 1}}, + {3134, {wxStyledTextCtrl, setSearchFlags, 1}}, + {3135, {wxStyledTextCtrl, getSearchFlags, 0}}, + {3136, {wxStyledTextCtrl, callTipShow, 2}}, + {3137, {wxStyledTextCtrl, callTipCancel, 0}}, + {3138, {wxStyledTextCtrl, callTipActive, 0}}, + {3139, {wxStyledTextCtrl, callTipPosAtStart, 0}}, + {3140, {wxStyledTextCtrl, callTipSetHighlight, 2}}, + {3141, {wxStyledTextCtrl, callTipSetBackground, 1}}, + {3142, {wxStyledTextCtrl, callTipSetForeground, 1}}, + {3143, {wxStyledTextCtrl, callTipSetForegroundHighlight, 1}}, + {3144, {wxStyledTextCtrl, callTipUseStyle, 1}}, + {3145, {wxStyledTextCtrl, visibleFromDocLine, 1}}, + {3146, {wxStyledTextCtrl, docLineFromVisible, 1}}, + {3147, {wxStyledTextCtrl, wrapCount, 1}}, + {3148, {wxStyledTextCtrl, setFoldLevel, 2}}, + {3149, {wxStyledTextCtrl, getFoldLevel, 1}}, + {3150, {wxStyledTextCtrl, getLastChild, 2}}, + {3151, {wxStyledTextCtrl, getFoldParent, 1}}, + {3152, {wxStyledTextCtrl, showLines, 2}}, + {3153, {wxStyledTextCtrl, hideLines, 2}}, + {3154, {wxStyledTextCtrl, getLineVisible, 1}}, + {3155, {wxStyledTextCtrl, setFoldExpanded, 2}}, + {3156, {wxStyledTextCtrl, getFoldExpanded, 1}}, + {3157, {wxStyledTextCtrl, toggleFold, 1}}, + {3158, {wxStyledTextCtrl, ensureVisible, 1}}, + {3159, {wxStyledTextCtrl, setFoldFlags, 1}}, + {3160, {wxStyledTextCtrl, ensureVisibleEnforcePolicy, 1}}, + {3161, {wxStyledTextCtrl, setTabIndents, 1}}, + {3162, {wxStyledTextCtrl, getTabIndents, 0}}, + {3163, {wxStyledTextCtrl, setBackSpaceUnIndents, 1}}, + {3164, {wxStyledTextCtrl, getBackSpaceUnIndents, 0}}, + {3165, {wxStyledTextCtrl, setMouseDwellTime, 1}}, + {3166, {wxStyledTextCtrl, getMouseDwellTime, 0}}, + {3167, {wxStyledTextCtrl, wordStartPosition, 2}}, + {3168, {wxStyledTextCtrl, wordEndPosition, 2}}, + {3169, {wxStyledTextCtrl, setWrapMode, 1}}, + {3170, {wxStyledTextCtrl, getWrapMode, 0}}, + {3171, {wxStyledTextCtrl, setWrapVisualFlags, 1}}, + {3172, {wxStyledTextCtrl, getWrapVisualFlags, 0}}, + {3173, {wxStyledTextCtrl, setWrapVisualFlagsLocation, 1}}, + {3174, {wxStyledTextCtrl, getWrapVisualFlagsLocation, 0}}, + {3175, {wxStyledTextCtrl, setWrapStartIndent, 1}}, + {3176, {wxStyledTextCtrl, getWrapStartIndent, 0}}, + {3177, {wxStyledTextCtrl, setLayoutCache, 1}}, + {3178, {wxStyledTextCtrl, getLayoutCache, 0}}, + {3179, {wxStyledTextCtrl, setScrollWidth, 1}}, + {3180, {wxStyledTextCtrl, getScrollWidth, 0}}, + {3181, {wxStyledTextCtrl, textWidth, 2}}, + {3182, {wxStyledTextCtrl, getEndAtLastLine, 0}}, + {3183, {wxStyledTextCtrl, textHeight, 1}}, + {3184, {wxStyledTextCtrl, setUseVerticalScrollBar, 1}}, + {3185, {wxStyledTextCtrl, getUseVerticalScrollBar, 0}}, + {3186, {wxStyledTextCtrl, appendText, 1}}, + {3187, {wxStyledTextCtrl, getTwoPhaseDraw, 0}}, + {3188, {wxStyledTextCtrl, setTwoPhaseDraw, 1}}, + {3189, {wxStyledTextCtrl, targetFromSelection, 0}}, + {3190, {wxStyledTextCtrl, linesJoin, 0}}, + {3191, {wxStyledTextCtrl, linesSplit, 1}}, + {3192, {wxStyledTextCtrl, setFoldMarginColour, 2}}, + {3193, {wxStyledTextCtrl, setFoldMarginHiColour, 2}}, + {3194, {wxStyledTextCtrl, lineDown, 0}}, + {3195, {wxStyledTextCtrl, lineDownExtend, 0}}, + {3196, {wxStyledTextCtrl, lineUp, 0}}, + {3197, {wxStyledTextCtrl, lineUpExtend, 0}}, + {3198, {wxStyledTextCtrl, charLeft, 0}}, + {3199, {wxStyledTextCtrl, charLeftExtend, 0}}, + {3200, {wxStyledTextCtrl, charRight, 0}}, + {3201, {wxStyledTextCtrl, charRightExtend, 0}}, + {3202, {wxStyledTextCtrl, wordLeft, 0}}, + {3203, {wxStyledTextCtrl, wordLeftExtend, 0}}, + {3204, {wxStyledTextCtrl, wordRight, 0}}, + {3205, {wxStyledTextCtrl, wordRightExtend, 0}}, + {3206, {wxStyledTextCtrl, home, 0}}, + {3207, {wxStyledTextCtrl, homeExtend, 0}}, + {3208, {wxStyledTextCtrl, lineEnd, 0}}, + {3209, {wxStyledTextCtrl, lineEndExtend, 0}}, + {3210, {wxStyledTextCtrl, documentStart, 0}}, + {3211, {wxStyledTextCtrl, documentStartExtend, 0}}, + {3212, {wxStyledTextCtrl, documentEnd, 0}}, + {3213, {wxStyledTextCtrl, documentEndExtend, 0}}, + {3214, {wxStyledTextCtrl, pageUp, 0}}, + {3215, {wxStyledTextCtrl, pageUpExtend, 0}}, + {3216, {wxStyledTextCtrl, pageDown, 0}}, + {3217, {wxStyledTextCtrl, pageDownExtend, 0}}, + {3218, {wxStyledTextCtrl, editToggleOvertype, 0}}, + {3219, {wxStyledTextCtrl, cancel, 0}}, + {3220, {wxStyledTextCtrl, deleteBack, 0}}, + {3221, {wxStyledTextCtrl, tab, 0}}, + {3222, {wxStyledTextCtrl, backTab, 0}}, + {3223, {wxStyledTextCtrl, newLine, 0}}, + {3224, {wxStyledTextCtrl, formFeed, 0}}, + {3225, {wxStyledTextCtrl, vCHome, 0}}, + {3226, {wxStyledTextCtrl, vCHomeExtend, 0}}, + {3227, {wxStyledTextCtrl, zoomIn, 0}}, + {3228, {wxStyledTextCtrl, zoomOut, 0}}, + {3229, {wxStyledTextCtrl, delWordLeft, 0}}, + {3230, {wxStyledTextCtrl, delWordRight, 0}}, + {3231, {wxStyledTextCtrl, lineCut, 0}}, + {3232, {wxStyledTextCtrl, lineDelete, 0}}, + {3233, {wxStyledTextCtrl, lineTranspose, 0}}, + {3234, {wxStyledTextCtrl, lineDuplicate, 0}}, + {3235, {wxStyledTextCtrl, lowerCase, 0}}, + {3236, {wxStyledTextCtrl, upperCase, 0}}, + {3237, {wxStyledTextCtrl, lineScrollDown, 0}}, + {3238, {wxStyledTextCtrl, lineScrollUp, 0}}, + {3239, {wxStyledTextCtrl, deleteBackNotLine, 0}}, + {3240, {wxStyledTextCtrl, homeDisplay, 0}}, + {3241, {wxStyledTextCtrl, homeDisplayExtend, 0}}, + {3242, {wxStyledTextCtrl, lineEndDisplay, 0}}, + {3243, {wxStyledTextCtrl, lineEndDisplayExtend, 0}}, + {3244, {wxStyledTextCtrl, homeWrapExtend, 0}}, + {3245, {wxStyledTextCtrl, lineEndWrap, 0}}, + {3246, {wxStyledTextCtrl, lineEndWrapExtend, 0}}, + {3247, {wxStyledTextCtrl, vCHomeWrap, 0}}, + {3248, {wxStyledTextCtrl, vCHomeWrapExtend, 0}}, + {3249, {wxStyledTextCtrl, lineCopy, 0}}, + {3250, {wxStyledTextCtrl, moveCaretInsideView, 0}}, + {3251, {wxStyledTextCtrl, lineLength, 1}}, + {3252, {wxStyledTextCtrl, braceHighlight, 2}}, + {3253, {wxStyledTextCtrl, braceBadLight, 1}}, + {3254, {wxStyledTextCtrl, braceMatch, 1}}, + {3255, {wxStyledTextCtrl, getViewEOL, 0}}, + {3256, {wxStyledTextCtrl, setViewEOL, 1}}, + {3257, {wxStyledTextCtrl, setModEventMask, 1}}, + {3258, {wxStyledTextCtrl, getEdgeColumn, 0}}, + {3259, {wxStyledTextCtrl, setEdgeColumn, 1}}, + {3260, {wxStyledTextCtrl, getEdgeMode, 0}}, + {3261, {wxStyledTextCtrl, getEdgeColour, 0}}, + {3262, {wxStyledTextCtrl, setEdgeColour, 1}}, + {3263, {wxStyledTextCtrl, searchAnchor, 0}}, + {3264, {wxStyledTextCtrl, searchNext, 2}}, + {3265, {wxStyledTextCtrl, searchPrev, 2}}, + {3266, {wxStyledTextCtrl, linesOnScreen, 0}}, + {3267, {wxStyledTextCtrl, usePopUp, 1}}, + {3268, {wxStyledTextCtrl, selectionIsRectangle, 0}}, + {3269, {wxStyledTextCtrl, setZoom, 1}}, + {3270, {wxStyledTextCtrl, getZoom, 0}}, + {3271, {wxStyledTextCtrl, getModEventMask, 0}}, + {3272, {wxStyledTextCtrl, setSTCFocus, 1}}, + {3273, {wxStyledTextCtrl, getSTCFocus, 0}}, + {3274, {wxStyledTextCtrl, setStatus, 1}}, + {3275, {wxStyledTextCtrl, getStatus, 0}}, + {3276, {wxStyledTextCtrl, setMouseDownCaptures, 1}}, + {3277, {wxStyledTextCtrl, getMouseDownCaptures, 0}}, + {3278, {wxStyledTextCtrl, setSTCCursor, 1}}, + {3279, {wxStyledTextCtrl, getSTCCursor, 0}}, + {3280, {wxStyledTextCtrl, setControlCharSymbol, 1}}, + {3281, {wxStyledTextCtrl, getControlCharSymbol, 0}}, + {3282, {wxStyledTextCtrl, wordPartLeft, 0}}, + {3283, {wxStyledTextCtrl, wordPartLeftExtend, 0}}, + {3284, {wxStyledTextCtrl, wordPartRight, 0}}, + {3285, {wxStyledTextCtrl, wordPartRightExtend, 0}}, + {3286, {wxStyledTextCtrl, setVisiblePolicy, 2}}, + {3287, {wxStyledTextCtrl, delLineLeft, 0}}, + {3288, {wxStyledTextCtrl, delLineRight, 0}}, + {3289, {wxStyledTextCtrl, getXOffset, 0}}, + {3290, {wxStyledTextCtrl, chooseCaretX, 0}}, + {3291, {wxStyledTextCtrl, setXCaretPolicy, 2}}, + {3292, {wxStyledTextCtrl, setYCaretPolicy, 2}}, + {3293, {wxStyledTextCtrl, getPrintWrapMode, 0}}, + {3294, {wxStyledTextCtrl, setHotspotActiveForeground, 2}}, + {3295, {wxStyledTextCtrl, setHotspotActiveBackground, 2}}, + {3296, {wxStyledTextCtrl, setHotspotActiveUnderline, 1}}, + {3297, {wxStyledTextCtrl, setHotspotSingleLine, 1}}, + {3298, {wxStyledTextCtrl, paraDownExtend, 0}}, + {3299, {wxStyledTextCtrl, paraUp, 0}}, + {3300, {wxStyledTextCtrl, paraUpExtend, 0}}, + {3301, {wxStyledTextCtrl, positionBefore, 1}}, + {3302, {wxStyledTextCtrl, positionAfter, 1}}, + {3303, {wxStyledTextCtrl, copyRange, 2}}, + {3304, {wxStyledTextCtrl, copyText, 2}}, + {3305, {wxStyledTextCtrl, setSelectionMode, 1}}, + {3306, {wxStyledTextCtrl, getSelectionMode, 0}}, + {3307, {wxStyledTextCtrl, lineDownRectExtend, 0}}, + {3308, {wxStyledTextCtrl, lineUpRectExtend, 0}}, + {3309, {wxStyledTextCtrl, charLeftRectExtend, 0}}, + {3310, {wxStyledTextCtrl, charRightRectExtend, 0}}, + {3311, {wxStyledTextCtrl, homeRectExtend, 0}}, + {3312, {wxStyledTextCtrl, vCHomeRectExtend, 0}}, + {3313, {wxStyledTextCtrl, lineEndRectExtend, 0}}, + {3314, {wxStyledTextCtrl, pageUpRectExtend, 0}}, + {3315, {wxStyledTextCtrl, pageDownRectExtend, 0}}, + {3316, {wxStyledTextCtrl, stutteredPageUp, 0}}, + {3317, {wxStyledTextCtrl, stutteredPageUpExtend, 0}}, + {3318, {wxStyledTextCtrl, stutteredPageDown, 0}}, + {3319, {wxStyledTextCtrl, stutteredPageDownExtend, 0}}, + {3320, {wxStyledTextCtrl, wordLeftEnd, 0}}, + {3321, {wxStyledTextCtrl, wordLeftEndExtend, 0}}, + {3322, {wxStyledTextCtrl, wordRightEnd, 0}}, + {3323, {wxStyledTextCtrl, wordRightEndExtend, 0}}, + {3324, {wxStyledTextCtrl, setWhitespaceChars, 1}}, + {3325, {wxStyledTextCtrl, setCharsDefault, 0}}, + {3326, {wxStyledTextCtrl, autoCompGetCurrent, 0}}, + {3327, {wxStyledTextCtrl, allocate, 1}}, + {3328, {wxStyledTextCtrl, findColumn, 2}}, + {3329, {wxStyledTextCtrl, getCaretSticky, 0}}, + {3330, {wxStyledTextCtrl, setCaretSticky, 1}}, + {3331, {wxStyledTextCtrl, toggleCaretSticky, 0}}, + {3332, {wxStyledTextCtrl, setPasteConvertEndings, 1}}, + {3333, {wxStyledTextCtrl, getPasteConvertEndings, 0}}, + {3334, {wxStyledTextCtrl, selectionDuplicate, 0}}, + {3335, {wxStyledTextCtrl, setCaretLineBackAlpha, 1}}, + {3336, {wxStyledTextCtrl, getCaretLineBackAlpha, 0}}, + {3337, {wxStyledTextCtrl, startRecord, 0}}, + {3338, {wxStyledTextCtrl, stopRecord, 0}}, + {3339, {wxStyledTextCtrl, setLexer, 1}}, + {3340, {wxStyledTextCtrl, getLexer, 0}}, + {3341, {wxStyledTextCtrl, colourise, 2}}, + {3342, {wxStyledTextCtrl, setProperty, 2}}, + {3343, {wxStyledTextCtrl, setKeyWords, 2}}, + {3344, {wxStyledTextCtrl, setLexerLanguage, 1}}, + {3345, {wxStyledTextCtrl, getProperty, 1}}, + {3346, {wxStyledTextCtrl, getStyleBitsNeeded, 0}}, + {3347, {wxStyledTextCtrl, getCurrentLine, 0}}, + {3348, {wxStyledTextCtrl, styleSetSpec, 2}}, + {3349, {wxStyledTextCtrl, styleSetFont, 2}}, + {3350, {wxStyledTextCtrl, styleSetFontAttr, 7}}, + {3351, {wxStyledTextCtrl, styleSetCharacterSet, 2}}, + {3352, {wxStyledTextCtrl, styleSetFontEncoding, 2}}, + {3353, {wxStyledTextCtrl, cmdKeyExecute, 1}}, + {3354, {wxStyledTextCtrl, setMargins, 2}}, + {3355, {wxStyledTextCtrl, getSelection, 2}}, + {3356, {wxStyledTextCtrl, pointFromPosition, 1}}, + {3357, {wxStyledTextCtrl, scrollToLine, 1}}, + {3358, {wxStyledTextCtrl, scrollToColumn, 1}}, + {3359, {wxStyledTextCtrl, sendMsg, 2}}, + {3360, {wxStyledTextCtrl, setVScrollBar, 1}}, + {3361, {wxStyledTextCtrl, setHScrollBar, 1}}, + {3362, {wxStyledTextCtrl, getLastKeydownProcessed, 0}}, + {3363, {wxStyledTextCtrl, setLastKeydownProcessed, 1}}, + {3364, {wxStyledTextCtrl, saveFile, 1}}, + {3365, {wxStyledTextCtrl, loadFile, 1}}, + {3366, {wxStyledTextCtrl, doDragOver, 3}}, + {3367, {wxStyledTextCtrl, doDropText, 3}}, + {3368, {wxStyledTextCtrl, getUseAntiAliasing, 0}}, + {3369, {wxStyledTextCtrl, addTextRaw, 1}}, + {3370, {wxStyledTextCtrl, insertTextRaw, 2}}, + {3371, {wxStyledTextCtrl, getCurLineRaw, 1}}, + {3372, {wxStyledTextCtrl, getLineRaw, 1}}, + {3373, {wxStyledTextCtrl, getSelectedTextRaw, 0}}, + {3374, {wxStyledTextCtrl, getTextRangeRaw, 2}}, + {3375, {wxStyledTextCtrl, setTextRaw, 1}}, + {3376, {wxStyledTextCtrl, getTextRaw, 0}}, + {3377, {wxStyledTextCtrl, appendTextRaw, 1}}, + {3378, {wxArtProvider, getBitmap, 2}}, + {3379, {wxArtProvider, getIcon, 2}}, + {3380, {wxTreeEvent, getKeyCode, 0}}, + {3381, {wxTreeEvent, getItem, 0}}, + {3382, {wxTreeEvent, getKeyEvent, 0}}, + {3383, {wxTreeEvent, getLabel, 0}}, + {3384, {wxTreeEvent, getOldItem, 0}}, + {3385, {wxTreeEvent, getPoint, 0}}, + {3386, {wxTreeEvent, isEditCancelled, 0}}, + {3387, {wxTreeEvent, setToolTip, 1}}, + {3388, {wxNotebookEvent, getOldSelection, 0}}, + {3389, {wxNotebookEvent, getSelection, 0}}, + {3390, {wxNotebookEvent, setOldSelection, 1}}, + {3391, {wxNotebookEvent, setSelection, 1}}, + {3392, {wxFileDataObject, new, 0}}, + {3393, {wxFileDataObject, addFile, 1}}, + {3394, {wxFileDataObject, getFilenames, 0}}, + {3395, {wxFileDataObject, 'Destroy', undefined}}, + {3396, {wxTextDataObject, new, 1}}, + {3397, {wxTextDataObject, getTextLength, 0}}, + {3398, {wxTextDataObject, getText, 0}}, + {3399, {wxTextDataObject, setText, 1}}, + {3400, {wxTextDataObject, 'Destroy', undefined}}, + {3401, {wxBitmapDataObject, new_1_1, 1}}, + {3402, {wxBitmapDataObject, new_1_0, 1}}, + {3403, {wxBitmapDataObject, getBitmap, 0}}, + {3404, {wxBitmapDataObject, setBitmap, 1}}, + {3405, {wxBitmapDataObject, 'Destroy', undefined}}, + {3407, {wxClipboard, new, 0}}, + {3408, {wxClipboard, destruct, 0}}, + {3409, {wxClipboard, addData, 1}}, + {3410, {wxClipboard, clear, 0}}, + {3411, {wxClipboard, close, 0}}, + {3412, {wxClipboard, flush, 0}}, + {3413, {wxClipboard, getData, 1}}, + {3414, {wxClipboard, isOpened, 0}}, + {3415, {wxClipboard, open, 0}}, + {3416, {wxClipboard, setData, 1}}, + {3418, {wxClipboard, usePrimarySelection, 1}}, + {3419, {wxClipboard, isSupported, 1}}, + {3420, {wxClipboard, get, 0}}, + {3421, {wxSpinEvent, getPosition, 0}}, + {3422, {wxSpinEvent, setPosition, 1}}, + {3423, {wxSplitterWindow, new_0, 0}}, + {3424, {wxSplitterWindow, new_2, 2}}, + {3425, {wxSplitterWindow, destruct, 0}}, + {3426, {wxSplitterWindow, create, 2}}, + {3427, {wxSplitterWindow, getMinimumPaneSize, 0}}, + {3428, {wxSplitterWindow, getSashGravity, 0}}, + {3429, {wxSplitterWindow, getSashPosition, 0}}, + {3430, {wxSplitterWindow, getSplitMode, 0}}, + {3431, {wxSplitterWindow, getWindow1, 0}}, + {3432, {wxSplitterWindow, getWindow2, 0}}, + {3433, {wxSplitterWindow, initialize, 1}}, + {3434, {wxSplitterWindow, isSplit, 0}}, + {3435, {wxSplitterWindow, replaceWindow, 2}}, + {3436, {wxSplitterWindow, setSashGravity, 1}}, + {3437, {wxSplitterWindow, setSashPosition, 2}}, + {3438, {wxSplitterWindow, setSashSize, 1}}, + {3439, {wxSplitterWindow, setMinimumPaneSize, 1}}, + {3440, {wxSplitterWindow, setSplitMode, 1}}, + {3441, {wxSplitterWindow, splitHorizontally, 3}}, + {3442, {wxSplitterWindow, splitVertically, 3}}, + {3443, {wxSplitterWindow, unsplit, 1}}, + {3444, {wxSplitterWindow, updateSize, 0}}, + {3445, {wxSplitterEvent, getSashPosition, 0}}, + {3446, {wxSplitterEvent, getX, 0}}, + {3447, {wxSplitterEvent, getY, 0}}, + {3448, {wxSplitterEvent, getWindowBeingRemoved, 0}}, + {3449, {wxSplitterEvent, setSashPosition, 1}}, + {3450, {wxHtmlWindow, new_0, 0}}, + {3451, {wxHtmlWindow, new_2, 2}}, + {3452, {wxHtmlWindow, appendToPage, 1}}, + {3453, {wxHtmlWindow, getOpenedAnchor, 0}}, + {3454, {wxHtmlWindow, getOpenedPage, 0}}, + {3455, {wxHtmlWindow, getOpenedPageTitle, 0}}, + {3456, {wxHtmlWindow, getRelatedFrame, 0}}, + {3457, {wxHtmlWindow, historyBack, 0}}, + {3458, {wxHtmlWindow, historyCanBack, 0}}, + {3459, {wxHtmlWindow, historyCanForward, 0}}, + {3460, {wxHtmlWindow, historyClear, 0}}, + {3461, {wxHtmlWindow, historyForward, 0}}, + {3462, {wxHtmlWindow, loadFile, 1}}, + {3463, {wxHtmlWindow, loadPage, 1}}, + {3464, {wxHtmlWindow, selectAll, 0}}, + {3465, {wxHtmlWindow, selectionToText, 0}}, + {3466, {wxHtmlWindow, selectLine, 1}}, + {3467, {wxHtmlWindow, selectWord, 1}}, + {3468, {wxHtmlWindow, setBorders, 1}}, + {3469, {wxHtmlWindow, setFonts, 3}}, + {3470, {wxHtmlWindow, setPage, 1}}, + {3471, {wxHtmlWindow, setRelatedFrame, 2}}, + {3472, {wxHtmlWindow, setRelatedStatusBar, 1}}, + {3473, {wxHtmlWindow, toText, 0}}, + {3474, {wxHtmlWindow, 'Destroy', undefined}}, + {3475, {wxHtmlLinkEvent, getLinkInfo, 0}}, + {3476, {wxAuiNotebookEvent, setSelection, 1}}, + {3477, {wxAuiNotebookEvent, getSelection, 0}}, + {3478, {wxAuiNotebookEvent, setOldSelection, 1}}, + {3479, {wxAuiNotebookEvent, getOldSelection, 0}}, + {3480, {wxAuiNotebookEvent, setDragSource, 1}}, + {3481, {wxAuiNotebookEvent, getDragSource, 0}}, + {3482, {wxAuiManagerEvent, setManager, 1}}, + {3483, {wxAuiManagerEvent, getManager, 0}}, + {3484, {wxAuiManagerEvent, setPane, 1}}, + {3485, {wxAuiManagerEvent, getPane, 0}}, + {3486, {wxAuiManagerEvent, setButton, 1}}, + {3487, {wxAuiManagerEvent, getButton, 0}}, + {3488, {wxAuiManagerEvent, setDC, 1}}, + {3489, {wxAuiManagerEvent, getDC, 0}}, + {3490, {wxAuiManagerEvent, veto, 1}}, + {3491, {wxAuiManagerEvent, getVeto, 0}}, + {3492, {wxAuiManagerEvent, setCanVeto, 1}}, + {3493, {wxAuiManagerEvent, canVeto, 0}}, + {3494, {wxLogNull, new, 0}}, + {3495, {wxLogNull, 'Destroy', undefined}}, {-1, {mod, func, -1}} ]. diff --git a/lib/wx/src/gen/wxe_funcs.hrl b/lib/wx/src/gen/wxe_funcs.hrl index eef90961db..98e7fbb767 100644 --- a/lib/wx/src/gen/wxe_funcs.hrl +++ b/lib/wx/src/gen/wxe_funcs.hrl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% This file is generated DO NOT EDIT @@ -1839,1435 +1839,1436 @@ -define(wxTreeCtrl_GetChildrenCount, 2015). -define(wxTreeCtrl_GetCount, 2016). -define(wxTreeCtrl_GetEditControl, 2017). --define(wxTreeCtrl_GetFirstVisibleItem, 2018). --define(wxTreeCtrl_GetImageList, 2019). --define(wxTreeCtrl_GetIndent, 2020). --define(wxTreeCtrl_GetItemBackgroundColour, 2021). --define(wxTreeCtrl_GetItemData, 2022). --define(wxTreeCtrl_GetItemFont, 2023). --define(wxTreeCtrl_GetItemImage_1, 2024). --define(wxTreeCtrl_GetItemImage_2, 2025). --define(wxTreeCtrl_GetItemText, 2026). --define(wxTreeCtrl_GetItemTextColour, 2027). --define(wxTreeCtrl_GetLastChild, 2028). --define(wxTreeCtrl_GetNextSibling, 2029). --define(wxTreeCtrl_GetNextVisible, 2030). --define(wxTreeCtrl_GetItemParent, 2031). --define(wxTreeCtrl_GetPrevSibling, 2032). --define(wxTreeCtrl_GetPrevVisible, 2033). --define(wxTreeCtrl_GetRootItem, 2034). --define(wxTreeCtrl_GetSelection, 2035). --define(wxTreeCtrl_GetSelections, 2036). --define(wxTreeCtrl_GetStateImageList, 2037). --define(wxTreeCtrl_HitTest, 2038). --define(wxTreeCtrl_InsertItem_4_1, 2039). --define(wxTreeCtrl_InsertItem_4_0, 2040). --define(wxTreeCtrl_IsBold, 2041). --define(wxTreeCtrl_IsExpanded, 2042). --define(wxTreeCtrl_IsSelected, 2043). --define(wxTreeCtrl_IsVisible, 2044). --define(wxTreeCtrl_ItemHasChildren, 2045). --define(wxTreeCtrl_PrependItem, 2046). --define(wxTreeCtrl_ScrollTo, 2047). --define(wxTreeCtrl_SelectItem_1, 2048). --define(wxTreeCtrl_SelectItem_2, 2049). --define(wxTreeCtrl_SetIndent, 2050). --define(wxTreeCtrl_SetImageList, 2051). --define(wxTreeCtrl_SetItemBackgroundColour, 2052). --define(wxTreeCtrl_SetItemBold, 2053). --define(wxTreeCtrl_SetItemData, 2054). --define(wxTreeCtrl_SetItemDropHighlight, 2055). --define(wxTreeCtrl_SetItemFont, 2056). --define(wxTreeCtrl_SetItemHasChildren, 2057). --define(wxTreeCtrl_SetItemImage_2, 2058). --define(wxTreeCtrl_SetItemImage_3, 2059). --define(wxTreeCtrl_SetItemText, 2060). --define(wxTreeCtrl_SetItemTextColour, 2061). --define(wxTreeCtrl_SetStateImageList, 2062). --define(wxTreeCtrl_SetWindowStyle, 2063). --define(wxTreeCtrl_SortChildren, 2064). --define(wxTreeCtrl_Toggle, 2065). --define(wxTreeCtrl_ToggleItemSelection, 2066). --define(wxTreeCtrl_Unselect, 2067). --define(wxTreeCtrl_UnselectAll, 2068). --define(wxTreeCtrl_UnselectItem, 2069). --define(wxScrollBar_new_0, 2070). --define(wxScrollBar_new_3, 2071). --define(wxScrollBar_destruct, 2072). --define(wxScrollBar_Create, 2073). --define(wxScrollBar_GetRange, 2074). --define(wxScrollBar_GetPageSize, 2075). --define(wxScrollBar_GetThumbPosition, 2076). --define(wxScrollBar_GetThumbSize, 2077). --define(wxScrollBar_SetThumbPosition, 2078). --define(wxScrollBar_SetScrollbar, 2079). --define(wxSpinButton_new_2, 2081). --define(wxSpinButton_new_0, 2082). --define(wxSpinButton_Create, 2083). --define(wxSpinButton_GetMax, 2084). --define(wxSpinButton_GetMin, 2085). --define(wxSpinButton_GetValue, 2086). --define(wxSpinButton_SetRange, 2087). --define(wxSpinButton_SetValue, 2088). --define(wxSpinButton_destroy, 2089). --define(wxSpinCtrl_new_0, 2090). --define(wxSpinCtrl_new_2, 2091). --define(wxSpinCtrl_Create, 2093). --define(wxSpinCtrl_SetValue_1_1, 2096). --define(wxSpinCtrl_SetValue_1_0, 2097). --define(wxSpinCtrl_GetValue, 2099). --define(wxSpinCtrl_SetRange, 2101). --define(wxSpinCtrl_SetSelection, 2102). --define(wxSpinCtrl_GetMin, 2104). --define(wxSpinCtrl_GetMax, 2106). --define(wxSpinCtrl_destroy, 2107). --define(wxStaticText_new_0, 2108). --define(wxStaticText_new_4, 2109). --define(wxStaticText_Create, 2110). --define(wxStaticText_GetLabel, 2111). --define(wxStaticText_SetLabel, 2112). --define(wxStaticText_Wrap, 2113). --define(wxStaticText_destroy, 2114). --define(wxStaticBitmap_new_0, 2115). --define(wxStaticBitmap_new_4, 2116). --define(wxStaticBitmap_Create, 2117). --define(wxStaticBitmap_GetBitmap, 2118). --define(wxStaticBitmap_SetBitmap, 2119). --define(wxStaticBitmap_destroy, 2120). --define(wxRadioBox_new, 2121). --define(wxRadioBox_destruct, 2123). --define(wxRadioBox_Create, 2124). --define(wxRadioBox_Enable_2, 2125). --define(wxRadioBox_Enable_1, 2126). --define(wxRadioBox_GetSelection, 2127). --define(wxRadioBox_GetString, 2128). --define(wxRadioBox_SetSelection, 2129). --define(wxRadioBox_Show_2, 2130). --define(wxRadioBox_Show_1, 2131). --define(wxRadioBox_GetColumnCount, 2132). --define(wxRadioBox_GetItemHelpText, 2133). --define(wxRadioBox_GetItemToolTip, 2134). --define(wxRadioBox_GetItemFromPoint, 2136). --define(wxRadioBox_GetRowCount, 2137). --define(wxRadioBox_IsItemEnabled, 2138). --define(wxRadioBox_IsItemShown, 2139). --define(wxRadioBox_SetItemHelpText, 2140). --define(wxRadioBox_SetItemToolTip, 2141). --define(wxRadioButton_new_0, 2142). --define(wxRadioButton_new_4, 2143). --define(wxRadioButton_Create, 2144). --define(wxRadioButton_GetValue, 2145). --define(wxRadioButton_SetValue, 2146). --define(wxRadioButton_destroy, 2147). --define(wxSlider_new_6, 2149). --define(wxSlider_new_0, 2150). --define(wxSlider_Create, 2151). --define(wxSlider_GetLineSize, 2152). --define(wxSlider_GetMax, 2153). --define(wxSlider_GetMin, 2154). --define(wxSlider_GetPageSize, 2155). --define(wxSlider_GetThumbLength, 2156). --define(wxSlider_GetValue, 2157). --define(wxSlider_SetLineSize, 2158). --define(wxSlider_SetPageSize, 2159). --define(wxSlider_SetRange, 2160). --define(wxSlider_SetThumbLength, 2161). --define(wxSlider_SetValue, 2162). --define(wxSlider_destroy, 2163). --define(wxDialog_new_4, 2165). --define(wxDialog_new_0, 2166). --define(wxDialog_destruct, 2168). --define(wxDialog_Create, 2169). --define(wxDialog_CreateButtonSizer, 2170). --define(wxDialog_CreateStdDialogButtonSizer, 2171). --define(wxDialog_EndModal, 2172). --define(wxDialog_GetAffirmativeId, 2173). --define(wxDialog_GetReturnCode, 2174). --define(wxDialog_IsModal, 2175). --define(wxDialog_SetAffirmativeId, 2176). --define(wxDialog_SetReturnCode, 2177). --define(wxDialog_Show, 2178). --define(wxDialog_ShowModal, 2179). --define(wxColourDialog_new_0, 2180). --define(wxColourDialog_new_2, 2181). --define(wxColourDialog_destruct, 2182). --define(wxColourDialog_Create, 2183). --define(wxColourDialog_GetColourData, 2184). --define(wxColourData_new_0, 2185). --define(wxColourData_new_1, 2186). --define(wxColourData_destruct, 2187). --define(wxColourData_GetChooseFull, 2188). --define(wxColourData_GetColour, 2189). --define(wxColourData_GetCustomColour, 2191). --define(wxColourData_SetChooseFull, 2192). --define(wxColourData_SetColour, 2193). --define(wxColourData_SetCustomColour, 2194). --define(wxPalette_new_0, 2195). --define(wxPalette_new_4, 2196). --define(wxPalette_destruct, 2198). --define(wxPalette_Create, 2199). --define(wxPalette_GetColoursCount, 2200). --define(wxPalette_GetPixel, 2201). --define(wxPalette_GetRGB, 2202). --define(wxPalette_IsOk, 2203). --define(wxDirDialog_new, 2207). --define(wxDirDialog_destruct, 2208). --define(wxDirDialog_GetPath, 2209). --define(wxDirDialog_GetMessage, 2210). --define(wxDirDialog_SetMessage, 2211). --define(wxDirDialog_SetPath, 2212). --define(wxFileDialog_new, 2216). --define(wxFileDialog_destruct, 2217). --define(wxFileDialog_GetDirectory, 2218). --define(wxFileDialog_GetFilename, 2219). --define(wxFileDialog_GetFilenames, 2220). --define(wxFileDialog_GetFilterIndex, 2221). --define(wxFileDialog_GetMessage, 2222). --define(wxFileDialog_GetPath, 2223). --define(wxFileDialog_GetPaths, 2224). --define(wxFileDialog_GetWildcard, 2225). --define(wxFileDialog_SetDirectory, 2226). --define(wxFileDialog_SetFilename, 2227). --define(wxFileDialog_SetFilterIndex, 2228). --define(wxFileDialog_SetMessage, 2229). --define(wxFileDialog_SetPath, 2230). --define(wxFileDialog_SetWildcard, 2231). --define(wxPickerBase_SetInternalMargin, 2232). --define(wxPickerBase_GetInternalMargin, 2233). --define(wxPickerBase_SetTextCtrlProportion, 2234). --define(wxPickerBase_SetPickerCtrlProportion, 2235). --define(wxPickerBase_GetTextCtrlProportion, 2236). --define(wxPickerBase_GetPickerCtrlProportion, 2237). --define(wxPickerBase_HasTextCtrl, 2238). --define(wxPickerBase_GetTextCtrl, 2239). --define(wxPickerBase_IsTextCtrlGrowable, 2240). --define(wxPickerBase_SetPickerCtrlGrowable, 2241). --define(wxPickerBase_SetTextCtrlGrowable, 2242). --define(wxPickerBase_IsPickerCtrlGrowable, 2243). --define(wxFilePickerCtrl_new_0, 2244). --define(wxFilePickerCtrl_new_3, 2245). --define(wxFilePickerCtrl_Create, 2246). --define(wxFilePickerCtrl_GetPath, 2247). --define(wxFilePickerCtrl_SetPath, 2248). --define(wxFilePickerCtrl_destroy, 2249). --define(wxDirPickerCtrl_new_0, 2250). --define(wxDirPickerCtrl_new_3, 2251). --define(wxDirPickerCtrl_Create, 2252). --define(wxDirPickerCtrl_GetPath, 2253). --define(wxDirPickerCtrl_SetPath, 2254). --define(wxDirPickerCtrl_destroy, 2255). --define(wxColourPickerCtrl_new_0, 2256). --define(wxColourPickerCtrl_new_3, 2257). --define(wxColourPickerCtrl_Create, 2258). --define(wxColourPickerCtrl_GetColour, 2259). --define(wxColourPickerCtrl_SetColour_1_1, 2260). --define(wxColourPickerCtrl_SetColour_1_0, 2261). --define(wxColourPickerCtrl_destroy, 2262). --define(wxDatePickerCtrl_new_0, 2263). --define(wxDatePickerCtrl_new_3, 2264). --define(wxDatePickerCtrl_GetRange, 2265). --define(wxDatePickerCtrl_GetValue, 2266). --define(wxDatePickerCtrl_SetRange, 2267). --define(wxDatePickerCtrl_SetValue, 2268). --define(wxDatePickerCtrl_destroy, 2269). --define(wxFontPickerCtrl_new_0, 2270). --define(wxFontPickerCtrl_new_3, 2271). --define(wxFontPickerCtrl_Create, 2272). --define(wxFontPickerCtrl_GetSelectedFont, 2273). --define(wxFontPickerCtrl_SetSelectedFont, 2274). --define(wxFontPickerCtrl_GetMaxPointSize, 2275). --define(wxFontPickerCtrl_SetMaxPointSize, 2276). --define(wxFontPickerCtrl_destroy, 2277). --define(wxFindReplaceDialog_new_0, 2280). --define(wxFindReplaceDialog_new_4, 2281). --define(wxFindReplaceDialog_destruct, 2282). --define(wxFindReplaceDialog_Create, 2283). --define(wxFindReplaceDialog_GetData, 2284). --define(wxFindReplaceData_new_0, 2285). --define(wxFindReplaceData_new_1, 2286). --define(wxFindReplaceData_GetFindString, 2287). --define(wxFindReplaceData_GetReplaceString, 2288). --define(wxFindReplaceData_GetFlags, 2289). --define(wxFindReplaceData_SetFlags, 2290). --define(wxFindReplaceData_SetFindString, 2291). --define(wxFindReplaceData_SetReplaceString, 2292). --define(wxFindReplaceData_destroy, 2293). --define(wxMultiChoiceDialog_new_0, 2294). --define(wxMultiChoiceDialog_new_5, 2296). --define(wxMultiChoiceDialog_GetSelections, 2297). --define(wxMultiChoiceDialog_SetSelections, 2298). --define(wxMultiChoiceDialog_destroy, 2299). --define(wxSingleChoiceDialog_new_0, 2300). --define(wxSingleChoiceDialog_new_5, 2302). --define(wxSingleChoiceDialog_GetSelection, 2303). --define(wxSingleChoiceDialog_GetStringSelection, 2304). --define(wxSingleChoiceDialog_SetSelection, 2305). --define(wxSingleChoiceDialog_destroy, 2306). --define(wxTextEntryDialog_new, 2307). --define(wxTextEntryDialog_GetValue, 2308). --define(wxTextEntryDialog_SetValue, 2309). --define(wxTextEntryDialog_destroy, 2310). --define(wxPasswordEntryDialog_new, 2311). --define(wxPasswordEntryDialog_destroy, 2312). --define(wxFontData_new_0, 2313). --define(wxFontData_new_1, 2314). --define(wxFontData_destruct, 2315). --define(wxFontData_EnableEffects, 2316). --define(wxFontData_GetAllowSymbols, 2317). --define(wxFontData_GetColour, 2318). --define(wxFontData_GetChosenFont, 2319). --define(wxFontData_GetEnableEffects, 2320). --define(wxFontData_GetInitialFont, 2321). --define(wxFontData_GetShowHelp, 2322). --define(wxFontData_SetAllowSymbols, 2323). --define(wxFontData_SetChosenFont, 2324). --define(wxFontData_SetColour, 2325). --define(wxFontData_SetInitialFont, 2326). --define(wxFontData_SetRange, 2327). --define(wxFontData_SetShowHelp, 2328). --define(wxFontDialog_new_0, 2332). --define(wxFontDialog_new_2, 2334). --define(wxFontDialog_Create, 2336). --define(wxFontDialog_GetFontData, 2337). --define(wxFontDialog_destroy, 2339). --define(wxProgressDialog_new, 2340). --define(wxProgressDialog_destruct, 2341). --define(wxProgressDialog_Resume, 2342). --define(wxProgressDialog_Update_2, 2343). --define(wxProgressDialog_Update_0, 2344). --define(wxMessageDialog_new, 2345). --define(wxMessageDialog_destruct, 2346). --define(wxPageSetupDialog_new, 2347). --define(wxPageSetupDialog_destruct, 2348). --define(wxPageSetupDialog_GetPageSetupData, 2349). --define(wxPageSetupDialog_ShowModal, 2350). --define(wxPageSetupDialogData_new_0, 2351). --define(wxPageSetupDialogData_new_1_0, 2352). --define(wxPageSetupDialogData_new_1_1, 2353). --define(wxPageSetupDialogData_destruct, 2354). --define(wxPageSetupDialogData_EnableHelp, 2355). --define(wxPageSetupDialogData_EnableMargins, 2356). --define(wxPageSetupDialogData_EnableOrientation, 2357). --define(wxPageSetupDialogData_EnablePaper, 2358). --define(wxPageSetupDialogData_EnablePrinter, 2359). --define(wxPageSetupDialogData_GetDefaultMinMargins, 2360). --define(wxPageSetupDialogData_GetEnableMargins, 2361). --define(wxPageSetupDialogData_GetEnableOrientation, 2362). --define(wxPageSetupDialogData_GetEnablePaper, 2363). --define(wxPageSetupDialogData_GetEnablePrinter, 2364). --define(wxPageSetupDialogData_GetEnableHelp, 2365). --define(wxPageSetupDialogData_GetDefaultInfo, 2366). --define(wxPageSetupDialogData_GetMarginTopLeft, 2367). --define(wxPageSetupDialogData_GetMarginBottomRight, 2368). --define(wxPageSetupDialogData_GetMinMarginTopLeft, 2369). --define(wxPageSetupDialogData_GetMinMarginBottomRight, 2370). --define(wxPageSetupDialogData_GetPaperId, 2371). --define(wxPageSetupDialogData_GetPaperSize, 2372). --define(wxPageSetupDialogData_GetPrintData, 2374). --define(wxPageSetupDialogData_IsOk, 2375). --define(wxPageSetupDialogData_SetDefaultInfo, 2376). --define(wxPageSetupDialogData_SetDefaultMinMargins, 2377). --define(wxPageSetupDialogData_SetMarginTopLeft, 2378). --define(wxPageSetupDialogData_SetMarginBottomRight, 2379). --define(wxPageSetupDialogData_SetMinMarginTopLeft, 2380). --define(wxPageSetupDialogData_SetMinMarginBottomRight, 2381). --define(wxPageSetupDialogData_SetPaperId, 2382). --define(wxPageSetupDialogData_SetPaperSize_1_1, 2383). --define(wxPageSetupDialogData_SetPaperSize_1_0, 2384). --define(wxPageSetupDialogData_SetPrintData, 2385). --define(wxPrintDialog_new_2_0, 2386). --define(wxPrintDialog_new_2_1, 2387). --define(wxPrintDialog_destruct, 2388). --define(wxPrintDialog_GetPrintDialogData, 2389). --define(wxPrintDialog_GetPrintDC, 2390). --define(wxPrintDialogData_new_0, 2391). --define(wxPrintDialogData_new_1_1, 2392). --define(wxPrintDialogData_new_1_0, 2393). --define(wxPrintDialogData_destruct, 2394). --define(wxPrintDialogData_EnableHelp, 2395). --define(wxPrintDialogData_EnablePageNumbers, 2396). --define(wxPrintDialogData_EnablePrintToFile, 2397). --define(wxPrintDialogData_EnableSelection, 2398). --define(wxPrintDialogData_GetAllPages, 2399). --define(wxPrintDialogData_GetCollate, 2400). --define(wxPrintDialogData_GetFromPage, 2401). --define(wxPrintDialogData_GetMaxPage, 2402). --define(wxPrintDialogData_GetMinPage, 2403). --define(wxPrintDialogData_GetNoCopies, 2404). --define(wxPrintDialogData_GetPrintData, 2405). --define(wxPrintDialogData_GetPrintToFile, 2406). --define(wxPrintDialogData_GetSelection, 2407). --define(wxPrintDialogData_GetToPage, 2408). --define(wxPrintDialogData_IsOk, 2409). --define(wxPrintDialogData_SetCollate, 2410). --define(wxPrintDialogData_SetFromPage, 2411). --define(wxPrintDialogData_SetMaxPage, 2412). --define(wxPrintDialogData_SetMinPage, 2413). --define(wxPrintDialogData_SetNoCopies, 2414). --define(wxPrintDialogData_SetPrintData, 2415). --define(wxPrintDialogData_SetPrintToFile, 2416). --define(wxPrintDialogData_SetSelection, 2417). --define(wxPrintDialogData_SetToPage, 2418). --define(wxPrintData_new_0, 2419). --define(wxPrintData_new_1, 2420). --define(wxPrintData_destruct, 2421). --define(wxPrintData_GetCollate, 2422). --define(wxPrintData_GetBin, 2423). --define(wxPrintData_GetColour, 2424). --define(wxPrintData_GetDuplex, 2425). --define(wxPrintData_GetNoCopies, 2426). --define(wxPrintData_GetOrientation, 2427). --define(wxPrintData_GetPaperId, 2428). --define(wxPrintData_GetPrinterName, 2429). --define(wxPrintData_GetQuality, 2430). --define(wxPrintData_IsOk, 2431). --define(wxPrintData_SetBin, 2432). --define(wxPrintData_SetCollate, 2433). --define(wxPrintData_SetColour, 2434). --define(wxPrintData_SetDuplex, 2435). --define(wxPrintData_SetNoCopies, 2436). --define(wxPrintData_SetOrientation, 2437). --define(wxPrintData_SetPaperId, 2438). --define(wxPrintData_SetPrinterName, 2439). --define(wxPrintData_SetQuality, 2440). --define(wxPrintPreview_new_2, 2443). --define(wxPrintPreview_new_3, 2444). --define(wxPrintPreview_destruct, 2446). --define(wxPrintPreview_GetCanvas, 2447). --define(wxPrintPreview_GetCurrentPage, 2448). --define(wxPrintPreview_GetFrame, 2449). --define(wxPrintPreview_GetMaxPage, 2450). --define(wxPrintPreview_GetMinPage, 2451). --define(wxPrintPreview_GetPrintout, 2452). --define(wxPrintPreview_GetPrintoutForPrinting, 2453). --define(wxPrintPreview_IsOk, 2454). --define(wxPrintPreview_PaintPage, 2455). --define(wxPrintPreview_Print, 2456). --define(wxPrintPreview_RenderPage, 2457). --define(wxPrintPreview_SetCanvas, 2458). --define(wxPrintPreview_SetCurrentPage, 2459). --define(wxPrintPreview_SetFrame, 2460). --define(wxPrintPreview_SetPrintout, 2461). --define(wxPrintPreview_SetZoom, 2462). --define(wxPreviewFrame_new, 2463). --define(wxPreviewFrame_destruct, 2464). --define(wxPreviewFrame_CreateControlBar, 2465). --define(wxPreviewFrame_CreateCanvas, 2466). --define(wxPreviewFrame_Initialize, 2467). --define(wxPreviewFrame_OnCloseWindow, 2468). --define(wxPreviewControlBar_new, 2469). --define(wxPreviewControlBar_destruct, 2470). --define(wxPreviewControlBar_CreateButtons, 2471). --define(wxPreviewControlBar_GetPrintPreview, 2472). --define(wxPreviewControlBar_GetZoomControl, 2473). --define(wxPreviewControlBar_SetZoomControl, 2474). --define(wxPrinter_new, 2476). --define(wxPrinter_CreateAbortWindow, 2477). --define(wxPrinter_GetAbort, 2478). --define(wxPrinter_GetLastError, 2479). --define(wxPrinter_GetPrintDialogData, 2480). --define(wxPrinter_Print, 2481). --define(wxPrinter_PrintDialog, 2482). --define(wxPrinter_ReportError, 2483). --define(wxPrinter_Setup, 2484). --define(wxPrinter_destroy, 2485). --define(wxXmlResource_new_1, 2486). --define(wxXmlResource_new_2, 2487). --define(wxXmlResource_destruct, 2488). --define(wxXmlResource_AttachUnknownControl, 2489). --define(wxXmlResource_ClearHandlers, 2490). --define(wxXmlResource_CompareVersion, 2491). --define(wxXmlResource_Get, 2492). --define(wxXmlResource_GetFlags, 2493). --define(wxXmlResource_GetVersion, 2494). --define(wxXmlResource_GetXRCID, 2495). --define(wxXmlResource_InitAllHandlers, 2496). --define(wxXmlResource_Load, 2497). --define(wxXmlResource_LoadBitmap, 2498). --define(wxXmlResource_LoadDialog_2, 2499). --define(wxXmlResource_LoadDialog_3, 2500). --define(wxXmlResource_LoadFrame_2, 2501). --define(wxXmlResource_LoadFrame_3, 2502). --define(wxXmlResource_LoadIcon, 2503). --define(wxXmlResource_LoadMenu, 2504). --define(wxXmlResource_LoadMenuBar_2, 2505). --define(wxXmlResource_LoadMenuBar_1, 2506). --define(wxXmlResource_LoadPanel_2, 2507). --define(wxXmlResource_LoadPanel_3, 2508). --define(wxXmlResource_LoadToolBar, 2509). --define(wxXmlResource_Set, 2510). --define(wxXmlResource_SetFlags, 2511). --define(wxXmlResource_Unload, 2512). --define(wxXmlResource_xrcctrl, 2513). --define(wxHtmlEasyPrinting_new, 2514). --define(wxHtmlEasyPrinting_destruct, 2515). --define(wxHtmlEasyPrinting_GetPrintData, 2516). --define(wxHtmlEasyPrinting_GetPageSetupData, 2517). --define(wxHtmlEasyPrinting_PreviewFile, 2518). --define(wxHtmlEasyPrinting_PreviewText, 2519). --define(wxHtmlEasyPrinting_PrintFile, 2520). --define(wxHtmlEasyPrinting_PrintText, 2521). --define(wxHtmlEasyPrinting_PageSetup, 2522). --define(wxHtmlEasyPrinting_SetFonts, 2523). --define(wxHtmlEasyPrinting_SetHeader, 2524). --define(wxHtmlEasyPrinting_SetFooter, 2525). --define(wxGLCanvas_new_2, 2527). --define(wxGLCanvas_new_3_1, 2528). --define(wxGLCanvas_new_3_0, 2529). --define(wxGLCanvas_GetContext, 2530). --define(wxGLCanvas_SetCurrent, 2532). --define(wxGLCanvas_SwapBuffers, 2533). --define(wxGLCanvas_destroy, 2534). --define(wxAuiManager_new, 2535). --define(wxAuiManager_destruct, 2536). --define(wxAuiManager_AddPane_2_1, 2537). --define(wxAuiManager_AddPane_3, 2538). --define(wxAuiManager_AddPane_2_0, 2539). --define(wxAuiManager_DetachPane, 2540). --define(wxAuiManager_GetAllPanes, 2541). --define(wxAuiManager_GetArtProvider, 2542). --define(wxAuiManager_GetDockSizeConstraint, 2543). --define(wxAuiManager_GetFlags, 2544). --define(wxAuiManager_GetManagedWindow, 2545). --define(wxAuiManager_GetManager, 2546). --define(wxAuiManager_GetPane_1_1, 2547). --define(wxAuiManager_GetPane_1_0, 2548). --define(wxAuiManager_HideHint, 2549). --define(wxAuiManager_InsertPane, 2550). --define(wxAuiManager_LoadPaneInfo, 2551). --define(wxAuiManager_LoadPerspective, 2552). --define(wxAuiManager_SavePaneInfo, 2553). --define(wxAuiManager_SavePerspective, 2554). --define(wxAuiManager_SetArtProvider, 2555). --define(wxAuiManager_SetDockSizeConstraint, 2556). --define(wxAuiManager_SetFlags, 2557). --define(wxAuiManager_SetManagedWindow, 2558). --define(wxAuiManager_ShowHint, 2559). --define(wxAuiManager_UnInit, 2560). --define(wxAuiManager_Update, 2561). --define(wxAuiPaneInfo_new_0, 2562). --define(wxAuiPaneInfo_new_1, 2563). --define(wxAuiPaneInfo_destruct, 2564). --define(wxAuiPaneInfo_BestSize_1, 2565). --define(wxAuiPaneInfo_BestSize_2, 2566). --define(wxAuiPaneInfo_Bottom, 2567). --define(wxAuiPaneInfo_BottomDockable, 2568). --define(wxAuiPaneInfo_Caption, 2569). --define(wxAuiPaneInfo_CaptionVisible, 2570). --define(wxAuiPaneInfo_Centre, 2571). --define(wxAuiPaneInfo_CentrePane, 2572). --define(wxAuiPaneInfo_CloseButton, 2573). --define(wxAuiPaneInfo_DefaultPane, 2574). --define(wxAuiPaneInfo_DestroyOnClose, 2575). --define(wxAuiPaneInfo_Direction, 2576). --define(wxAuiPaneInfo_Dock, 2577). --define(wxAuiPaneInfo_Dockable, 2578). --define(wxAuiPaneInfo_Fixed, 2579). --define(wxAuiPaneInfo_Float, 2580). --define(wxAuiPaneInfo_Floatable, 2581). --define(wxAuiPaneInfo_FloatingPosition_1, 2582). --define(wxAuiPaneInfo_FloatingPosition_2, 2583). --define(wxAuiPaneInfo_FloatingSize_1, 2584). --define(wxAuiPaneInfo_FloatingSize_2, 2585). --define(wxAuiPaneInfo_Gripper, 2586). --define(wxAuiPaneInfo_GripperTop, 2587). --define(wxAuiPaneInfo_HasBorder, 2588). --define(wxAuiPaneInfo_HasCaption, 2589). --define(wxAuiPaneInfo_HasCloseButton, 2590). --define(wxAuiPaneInfo_HasFlag, 2591). --define(wxAuiPaneInfo_HasGripper, 2592). --define(wxAuiPaneInfo_HasGripperTop, 2593). --define(wxAuiPaneInfo_HasMaximizeButton, 2594). --define(wxAuiPaneInfo_HasMinimizeButton, 2595). --define(wxAuiPaneInfo_HasPinButton, 2596). --define(wxAuiPaneInfo_Hide, 2597). --define(wxAuiPaneInfo_IsBottomDockable, 2598). --define(wxAuiPaneInfo_IsDocked, 2599). --define(wxAuiPaneInfo_IsFixed, 2600). --define(wxAuiPaneInfo_IsFloatable, 2601). --define(wxAuiPaneInfo_IsFloating, 2602). --define(wxAuiPaneInfo_IsLeftDockable, 2603). --define(wxAuiPaneInfo_IsMovable, 2604). --define(wxAuiPaneInfo_IsOk, 2605). --define(wxAuiPaneInfo_IsResizable, 2606). --define(wxAuiPaneInfo_IsRightDockable, 2607). --define(wxAuiPaneInfo_IsShown, 2608). --define(wxAuiPaneInfo_IsToolbar, 2609). --define(wxAuiPaneInfo_IsTopDockable, 2610). --define(wxAuiPaneInfo_Layer, 2611). --define(wxAuiPaneInfo_Left, 2612). --define(wxAuiPaneInfo_LeftDockable, 2613). --define(wxAuiPaneInfo_MaxSize_1, 2614). --define(wxAuiPaneInfo_MaxSize_2, 2615). --define(wxAuiPaneInfo_MaximizeButton, 2616). --define(wxAuiPaneInfo_MinSize_1, 2617). --define(wxAuiPaneInfo_MinSize_2, 2618). --define(wxAuiPaneInfo_MinimizeButton, 2619). --define(wxAuiPaneInfo_Movable, 2620). --define(wxAuiPaneInfo_Name, 2621). --define(wxAuiPaneInfo_PaneBorder, 2622). --define(wxAuiPaneInfo_PinButton, 2623). --define(wxAuiPaneInfo_Position, 2624). --define(wxAuiPaneInfo_Resizable, 2625). --define(wxAuiPaneInfo_Right, 2626). --define(wxAuiPaneInfo_RightDockable, 2627). --define(wxAuiPaneInfo_Row, 2628). --define(wxAuiPaneInfo_SafeSet, 2629). --define(wxAuiPaneInfo_SetFlag, 2630). --define(wxAuiPaneInfo_Show, 2631). --define(wxAuiPaneInfo_ToolbarPane, 2632). --define(wxAuiPaneInfo_Top, 2633). --define(wxAuiPaneInfo_TopDockable, 2634). --define(wxAuiPaneInfo_Window, 2635). --define(wxAuiNotebook_new_0, 2636). --define(wxAuiNotebook_new_2, 2637). --define(wxAuiNotebook_AddPage, 2638). --define(wxAuiNotebook_Create, 2639). --define(wxAuiNotebook_DeletePage, 2640). --define(wxAuiNotebook_GetArtProvider, 2641). --define(wxAuiNotebook_GetPage, 2642). --define(wxAuiNotebook_GetPageBitmap, 2643). --define(wxAuiNotebook_GetPageCount, 2644). --define(wxAuiNotebook_GetPageIndex, 2645). --define(wxAuiNotebook_GetPageText, 2646). --define(wxAuiNotebook_GetSelection, 2647). --define(wxAuiNotebook_InsertPage, 2648). --define(wxAuiNotebook_RemovePage, 2649). --define(wxAuiNotebook_SetArtProvider, 2650). --define(wxAuiNotebook_SetFont, 2651). --define(wxAuiNotebook_SetPageBitmap, 2652). --define(wxAuiNotebook_SetPageText, 2653). --define(wxAuiNotebook_SetSelection, 2654). --define(wxAuiNotebook_SetTabCtrlHeight, 2655). --define(wxAuiNotebook_SetUniformBitmapSize, 2656). --define(wxAuiNotebook_destroy, 2657). --define(wxMDIParentFrame_new_0, 2658). --define(wxMDIParentFrame_new_4, 2659). --define(wxMDIParentFrame_destruct, 2660). --define(wxMDIParentFrame_ActivateNext, 2661). --define(wxMDIParentFrame_ActivatePrevious, 2662). --define(wxMDIParentFrame_ArrangeIcons, 2663). --define(wxMDIParentFrame_Cascade, 2664). --define(wxMDIParentFrame_Create, 2665). --define(wxMDIParentFrame_GetActiveChild, 2666). --define(wxMDIParentFrame_GetClientWindow, 2667). --define(wxMDIParentFrame_Tile, 2668). --define(wxMDIChildFrame_new_0, 2669). --define(wxMDIChildFrame_new_4, 2670). --define(wxMDIChildFrame_destruct, 2671). --define(wxMDIChildFrame_Activate, 2672). --define(wxMDIChildFrame_Create, 2673). --define(wxMDIChildFrame_Maximize, 2674). --define(wxMDIChildFrame_Restore, 2675). --define(wxMDIClientWindow_new_0, 2676). --define(wxMDIClientWindow_new_2, 2677). --define(wxMDIClientWindow_destruct, 2678). --define(wxMDIClientWindow_CreateClient, 2679). --define(wxLayoutAlgorithm_new, 2680). --define(wxLayoutAlgorithm_LayoutFrame, 2681). --define(wxLayoutAlgorithm_LayoutMDIFrame, 2682). --define(wxLayoutAlgorithm_LayoutWindow, 2683). --define(wxLayoutAlgorithm_destroy, 2684). --define(wxEvent_GetId, 2685). --define(wxEvent_GetSkipped, 2686). --define(wxEvent_GetTimestamp, 2687). --define(wxEvent_IsCommandEvent, 2688). --define(wxEvent_ResumePropagation, 2689). --define(wxEvent_ShouldPropagate, 2690). --define(wxEvent_Skip, 2691). --define(wxEvent_StopPropagation, 2692). --define(wxCommandEvent_getClientData, 2693). --define(wxCommandEvent_GetExtraLong, 2694). --define(wxCommandEvent_GetInt, 2695). --define(wxCommandEvent_GetSelection, 2696). --define(wxCommandEvent_GetString, 2697). --define(wxCommandEvent_IsChecked, 2698). --define(wxCommandEvent_IsSelection, 2699). --define(wxCommandEvent_SetInt, 2700). --define(wxCommandEvent_SetString, 2701). --define(wxScrollEvent_GetOrientation, 2702). --define(wxScrollEvent_GetPosition, 2703). --define(wxScrollWinEvent_GetOrientation, 2704). --define(wxScrollWinEvent_GetPosition, 2705). --define(wxMouseEvent_AltDown, 2706). --define(wxMouseEvent_Button, 2707). --define(wxMouseEvent_ButtonDClick, 2708). --define(wxMouseEvent_ButtonDown, 2709). --define(wxMouseEvent_ButtonUp, 2710). --define(wxMouseEvent_CmdDown, 2711). --define(wxMouseEvent_ControlDown, 2712). --define(wxMouseEvent_Dragging, 2713). --define(wxMouseEvent_Entering, 2714). --define(wxMouseEvent_GetButton, 2715). --define(wxMouseEvent_GetPosition, 2718). --define(wxMouseEvent_GetLogicalPosition, 2719). --define(wxMouseEvent_GetLinesPerAction, 2720). --define(wxMouseEvent_GetWheelRotation, 2721). --define(wxMouseEvent_GetWheelDelta, 2722). --define(wxMouseEvent_GetX, 2723). --define(wxMouseEvent_GetY, 2724). --define(wxMouseEvent_IsButton, 2725). --define(wxMouseEvent_IsPageScroll, 2726). --define(wxMouseEvent_Leaving, 2727). --define(wxMouseEvent_LeftDClick, 2728). --define(wxMouseEvent_LeftDown, 2729). --define(wxMouseEvent_LeftIsDown, 2730). --define(wxMouseEvent_LeftUp, 2731). --define(wxMouseEvent_MetaDown, 2732). --define(wxMouseEvent_MiddleDClick, 2733). --define(wxMouseEvent_MiddleDown, 2734). --define(wxMouseEvent_MiddleIsDown, 2735). --define(wxMouseEvent_MiddleUp, 2736). --define(wxMouseEvent_Moving, 2737). --define(wxMouseEvent_RightDClick, 2738). --define(wxMouseEvent_RightDown, 2739). --define(wxMouseEvent_RightIsDown, 2740). --define(wxMouseEvent_RightUp, 2741). --define(wxMouseEvent_ShiftDown, 2742). --define(wxSetCursorEvent_GetCursor, 2743). --define(wxSetCursorEvent_GetX, 2744). --define(wxSetCursorEvent_GetY, 2745). --define(wxSetCursorEvent_HasCursor, 2746). --define(wxSetCursorEvent_SetCursor, 2747). --define(wxKeyEvent_AltDown, 2748). --define(wxKeyEvent_CmdDown, 2749). --define(wxKeyEvent_ControlDown, 2750). --define(wxKeyEvent_GetKeyCode, 2751). --define(wxKeyEvent_GetModifiers, 2752). --define(wxKeyEvent_GetPosition, 2755). --define(wxKeyEvent_GetRawKeyCode, 2756). --define(wxKeyEvent_GetRawKeyFlags, 2757). --define(wxKeyEvent_GetUnicodeKey, 2758). --define(wxKeyEvent_GetX, 2759). --define(wxKeyEvent_GetY, 2760). --define(wxKeyEvent_HasModifiers, 2761). --define(wxKeyEvent_MetaDown, 2762). --define(wxKeyEvent_ShiftDown, 2763). --define(wxSizeEvent_GetSize, 2764). --define(wxMoveEvent_GetPosition, 2765). --define(wxEraseEvent_GetDC, 2766). --define(wxFocusEvent_GetWindow, 2767). --define(wxChildFocusEvent_GetWindow, 2768). --define(wxMenuEvent_GetMenu, 2769). --define(wxMenuEvent_GetMenuId, 2770). --define(wxMenuEvent_IsPopup, 2771). --define(wxCloseEvent_CanVeto, 2772). --define(wxCloseEvent_GetLoggingOff, 2773). --define(wxCloseEvent_SetCanVeto, 2774). --define(wxCloseEvent_SetLoggingOff, 2775). --define(wxCloseEvent_Veto, 2776). --define(wxShowEvent_SetShow, 2777). --define(wxShowEvent_GetShow, 2778). --define(wxIconizeEvent_Iconized, 2779). --define(wxJoystickEvent_ButtonDown, 2780). --define(wxJoystickEvent_ButtonIsDown, 2781). --define(wxJoystickEvent_ButtonUp, 2782). --define(wxJoystickEvent_GetButtonChange, 2783). --define(wxJoystickEvent_GetButtonState, 2784). --define(wxJoystickEvent_GetJoystick, 2785). --define(wxJoystickEvent_GetPosition, 2786). --define(wxJoystickEvent_GetZPosition, 2787). --define(wxJoystickEvent_IsButton, 2788). --define(wxJoystickEvent_IsMove, 2789). --define(wxJoystickEvent_IsZMove, 2790). --define(wxUpdateUIEvent_CanUpdate, 2791). --define(wxUpdateUIEvent_Check, 2792). --define(wxUpdateUIEvent_Enable, 2793). --define(wxUpdateUIEvent_Show, 2794). --define(wxUpdateUIEvent_GetChecked, 2795). --define(wxUpdateUIEvent_GetEnabled, 2796). --define(wxUpdateUIEvent_GetShown, 2797). --define(wxUpdateUIEvent_GetSetChecked, 2798). --define(wxUpdateUIEvent_GetSetEnabled, 2799). --define(wxUpdateUIEvent_GetSetShown, 2800). --define(wxUpdateUIEvent_GetSetText, 2801). --define(wxUpdateUIEvent_GetText, 2802). --define(wxUpdateUIEvent_GetMode, 2803). --define(wxUpdateUIEvent_GetUpdateInterval, 2804). --define(wxUpdateUIEvent_ResetUpdateTime, 2805). --define(wxUpdateUIEvent_SetMode, 2806). --define(wxUpdateUIEvent_SetText, 2807). --define(wxUpdateUIEvent_SetUpdateInterval, 2808). --define(wxMouseCaptureChangedEvent_GetCapturedWindow, 2809). --define(wxPaletteChangedEvent_SetChangedWindow, 2810). --define(wxPaletteChangedEvent_GetChangedWindow, 2811). --define(wxQueryNewPaletteEvent_SetPaletteRealized, 2812). --define(wxQueryNewPaletteEvent_GetPaletteRealized, 2813). --define(wxNavigationKeyEvent_GetDirection, 2814). --define(wxNavigationKeyEvent_SetDirection, 2815). --define(wxNavigationKeyEvent_IsWindowChange, 2816). --define(wxNavigationKeyEvent_SetWindowChange, 2817). --define(wxNavigationKeyEvent_IsFromTab, 2818). --define(wxNavigationKeyEvent_SetFromTab, 2819). --define(wxNavigationKeyEvent_GetCurrentFocus, 2820). --define(wxNavigationKeyEvent_SetCurrentFocus, 2821). --define(wxHelpEvent_GetOrigin, 2822). --define(wxHelpEvent_GetPosition, 2823). --define(wxHelpEvent_SetOrigin, 2824). --define(wxHelpEvent_SetPosition, 2825). --define(wxContextMenuEvent_GetPosition, 2826). --define(wxContextMenuEvent_SetPosition, 2827). --define(wxIdleEvent_CanSend, 2828). --define(wxIdleEvent_GetMode, 2829). --define(wxIdleEvent_RequestMore, 2830). --define(wxIdleEvent_MoreRequested, 2831). --define(wxIdleEvent_SetMode, 2832). --define(wxGridEvent_AltDown, 2833). --define(wxGridEvent_ControlDown, 2834). --define(wxGridEvent_GetCol, 2835). --define(wxGridEvent_GetPosition, 2836). --define(wxGridEvent_GetRow, 2837). --define(wxGridEvent_MetaDown, 2838). --define(wxGridEvent_Selecting, 2839). --define(wxGridEvent_ShiftDown, 2840). --define(wxNotifyEvent_Allow, 2841). --define(wxNotifyEvent_IsAllowed, 2842). --define(wxNotifyEvent_Veto, 2843). --define(wxSashEvent_GetEdge, 2844). --define(wxSashEvent_GetDragRect, 2845). --define(wxSashEvent_GetDragStatus, 2846). --define(wxListEvent_GetCacheFrom, 2847). --define(wxListEvent_GetCacheTo, 2848). --define(wxListEvent_GetKeyCode, 2849). --define(wxListEvent_GetIndex, 2850). --define(wxListEvent_GetColumn, 2851). --define(wxListEvent_GetPoint, 2852). --define(wxListEvent_GetLabel, 2853). --define(wxListEvent_GetText, 2854). --define(wxListEvent_GetImage, 2855). --define(wxListEvent_GetData, 2856). --define(wxListEvent_GetMask, 2857). --define(wxListEvent_GetItem, 2858). --define(wxListEvent_IsEditCancelled, 2859). --define(wxDateEvent_GetDate, 2860). --define(wxCalendarEvent_GetWeekDay, 2861). --define(wxFileDirPickerEvent_GetPath, 2862). --define(wxColourPickerEvent_GetColour, 2863). --define(wxFontPickerEvent_GetFont, 2864). --define(wxStyledTextEvent_GetPosition, 2865). --define(wxStyledTextEvent_GetKey, 2866). --define(wxStyledTextEvent_GetModifiers, 2867). --define(wxStyledTextEvent_GetModificationType, 2868). --define(wxStyledTextEvent_GetText, 2869). --define(wxStyledTextEvent_GetLength, 2870). --define(wxStyledTextEvent_GetLinesAdded, 2871). --define(wxStyledTextEvent_GetLine, 2872). --define(wxStyledTextEvent_GetFoldLevelNow, 2873). --define(wxStyledTextEvent_GetFoldLevelPrev, 2874). --define(wxStyledTextEvent_GetMargin, 2875). --define(wxStyledTextEvent_GetMessage, 2876). --define(wxStyledTextEvent_GetWParam, 2877). --define(wxStyledTextEvent_GetLParam, 2878). --define(wxStyledTextEvent_GetListType, 2879). --define(wxStyledTextEvent_GetX, 2880). --define(wxStyledTextEvent_GetY, 2881). --define(wxStyledTextEvent_GetDragText, 2882). --define(wxStyledTextEvent_GetDragAllowMove, 2883). --define(wxStyledTextEvent_GetDragResult, 2884). --define(wxStyledTextEvent_GetShift, 2885). --define(wxStyledTextEvent_GetControl, 2886). --define(wxStyledTextEvent_GetAlt, 2887). --define(utils_wxGetKeyState, 2888). --define(utils_wxGetMousePosition, 2889). --define(utils_wxGetMouseState, 2890). --define(utils_wxSetDetectableAutoRepeat, 2891). --define(utils_wxBell, 2892). --define(utils_wxFindMenuItemId, 2893). --define(utils_wxGenericFindWindowAtPoint, 2894). --define(utils_wxFindWindowAtPoint, 2895). --define(utils_wxBeginBusyCursor, 2896). --define(utils_wxEndBusyCursor, 2897). --define(utils_wxIsBusy, 2898). --define(utils_wxShutdown, 2899). --define(utils_wxShell, 2900). --define(utils_wxLaunchDefaultBrowser, 2901). --define(utils_wxGetEmailAddress, 2902). --define(utils_wxGetUserId, 2903). --define(utils_wxGetHomeDir, 2904). --define(utils_wxNewId, 2905). --define(utils_wxRegisterId, 2906). --define(utils_wxGetCurrentId, 2907). --define(utils_wxGetOsDescription, 2908). --define(utils_wxIsPlatformLittleEndian, 2909). --define(utils_wxIsPlatform64Bit, 2910). --define(wxPrintout_new, 2911). --define(wxPrintout_destruct, 2912). --define(wxPrintout_GetDC, 2913). --define(wxPrintout_GetPageSizeMM, 2914). --define(wxPrintout_GetPageSizePixels, 2915). --define(wxPrintout_GetPaperRectPixels, 2916). --define(wxPrintout_GetPPIPrinter, 2917). --define(wxPrintout_GetPPIScreen, 2918). --define(wxPrintout_GetTitle, 2919). --define(wxPrintout_IsPreview, 2920). --define(wxPrintout_FitThisSizeToPaper, 2921). --define(wxPrintout_FitThisSizeToPage, 2922). --define(wxPrintout_FitThisSizeToPageMargins, 2923). --define(wxPrintout_MapScreenSizeToPaper, 2924). --define(wxPrintout_MapScreenSizeToPage, 2925). --define(wxPrintout_MapScreenSizeToPageMargins, 2926). --define(wxPrintout_MapScreenSizeToDevice, 2927). --define(wxPrintout_GetLogicalPaperRect, 2928). --define(wxPrintout_GetLogicalPageRect, 2929). --define(wxPrintout_GetLogicalPageMarginsRect, 2930). --define(wxPrintout_SetLogicalOrigin, 2931). --define(wxPrintout_OffsetLogicalOrigin, 2932). --define(wxStyledTextCtrl_new_2, 2933). --define(wxStyledTextCtrl_new_0, 2934). --define(wxStyledTextCtrl_destruct, 2935). --define(wxStyledTextCtrl_Create, 2936). --define(wxStyledTextCtrl_AddText, 2937). --define(wxStyledTextCtrl_AddStyledText, 2938). --define(wxStyledTextCtrl_InsertText, 2939). --define(wxStyledTextCtrl_ClearAll, 2940). --define(wxStyledTextCtrl_ClearDocumentStyle, 2941). --define(wxStyledTextCtrl_GetLength, 2942). --define(wxStyledTextCtrl_GetCharAt, 2943). --define(wxStyledTextCtrl_GetCurrentPos, 2944). --define(wxStyledTextCtrl_GetAnchor, 2945). --define(wxStyledTextCtrl_GetStyleAt, 2946). --define(wxStyledTextCtrl_Redo, 2947). --define(wxStyledTextCtrl_SetUndoCollection, 2948). --define(wxStyledTextCtrl_SelectAll, 2949). --define(wxStyledTextCtrl_SetSavePoint, 2950). --define(wxStyledTextCtrl_GetStyledText, 2951). --define(wxStyledTextCtrl_CanRedo, 2952). --define(wxStyledTextCtrl_MarkerLineFromHandle, 2953). --define(wxStyledTextCtrl_MarkerDeleteHandle, 2954). --define(wxStyledTextCtrl_GetUndoCollection, 2955). --define(wxStyledTextCtrl_GetViewWhiteSpace, 2956). --define(wxStyledTextCtrl_SetViewWhiteSpace, 2957). --define(wxStyledTextCtrl_PositionFromPoint, 2958). --define(wxStyledTextCtrl_PositionFromPointClose, 2959). --define(wxStyledTextCtrl_GotoLine, 2960). --define(wxStyledTextCtrl_GotoPos, 2961). --define(wxStyledTextCtrl_SetAnchor, 2962). --define(wxStyledTextCtrl_GetCurLine, 2963). --define(wxStyledTextCtrl_GetEndStyled, 2964). --define(wxStyledTextCtrl_ConvertEOLs, 2965). --define(wxStyledTextCtrl_GetEOLMode, 2966). --define(wxStyledTextCtrl_SetEOLMode, 2967). --define(wxStyledTextCtrl_StartStyling, 2968). --define(wxStyledTextCtrl_SetStyling, 2969). --define(wxStyledTextCtrl_GetBufferedDraw, 2970). --define(wxStyledTextCtrl_SetBufferedDraw, 2971). --define(wxStyledTextCtrl_SetTabWidth, 2972). --define(wxStyledTextCtrl_GetTabWidth, 2973). --define(wxStyledTextCtrl_SetCodePage, 2974). --define(wxStyledTextCtrl_MarkerDefine, 2975). --define(wxStyledTextCtrl_MarkerSetForeground, 2976). --define(wxStyledTextCtrl_MarkerSetBackground, 2977). --define(wxStyledTextCtrl_MarkerAdd, 2978). --define(wxStyledTextCtrl_MarkerDelete, 2979). --define(wxStyledTextCtrl_MarkerDeleteAll, 2980). --define(wxStyledTextCtrl_MarkerGet, 2981). --define(wxStyledTextCtrl_MarkerNext, 2982). --define(wxStyledTextCtrl_MarkerPrevious, 2983). --define(wxStyledTextCtrl_MarkerDefineBitmap, 2984). --define(wxStyledTextCtrl_MarkerAddSet, 2985). --define(wxStyledTextCtrl_MarkerSetAlpha, 2986). --define(wxStyledTextCtrl_SetMarginType, 2987). --define(wxStyledTextCtrl_GetMarginType, 2988). --define(wxStyledTextCtrl_SetMarginWidth, 2989). --define(wxStyledTextCtrl_GetMarginWidth, 2990). --define(wxStyledTextCtrl_SetMarginMask, 2991). --define(wxStyledTextCtrl_GetMarginMask, 2992). --define(wxStyledTextCtrl_SetMarginSensitive, 2993). --define(wxStyledTextCtrl_GetMarginSensitive, 2994). --define(wxStyledTextCtrl_StyleClearAll, 2995). --define(wxStyledTextCtrl_StyleSetForeground, 2996). --define(wxStyledTextCtrl_StyleSetBackground, 2997). --define(wxStyledTextCtrl_StyleSetBold, 2998). --define(wxStyledTextCtrl_StyleSetItalic, 2999). --define(wxStyledTextCtrl_StyleSetSize, 3000). --define(wxStyledTextCtrl_StyleSetFaceName, 3001). --define(wxStyledTextCtrl_StyleSetEOLFilled, 3002). --define(wxStyledTextCtrl_StyleResetDefault, 3003). --define(wxStyledTextCtrl_StyleSetUnderline, 3004). --define(wxStyledTextCtrl_StyleSetCase, 3005). --define(wxStyledTextCtrl_StyleSetHotSpot, 3006). --define(wxStyledTextCtrl_SetSelForeground, 3007). --define(wxStyledTextCtrl_SetSelBackground, 3008). --define(wxStyledTextCtrl_GetSelAlpha, 3009). --define(wxStyledTextCtrl_SetSelAlpha, 3010). --define(wxStyledTextCtrl_SetCaretForeground, 3011). --define(wxStyledTextCtrl_CmdKeyAssign, 3012). --define(wxStyledTextCtrl_CmdKeyClear, 3013). --define(wxStyledTextCtrl_CmdKeyClearAll, 3014). --define(wxStyledTextCtrl_SetStyleBytes, 3015). --define(wxStyledTextCtrl_StyleSetVisible, 3016). --define(wxStyledTextCtrl_GetCaretPeriod, 3017). --define(wxStyledTextCtrl_SetCaretPeriod, 3018). --define(wxStyledTextCtrl_SetWordChars, 3019). --define(wxStyledTextCtrl_BeginUndoAction, 3020). --define(wxStyledTextCtrl_EndUndoAction, 3021). --define(wxStyledTextCtrl_IndicatorSetStyle, 3022). --define(wxStyledTextCtrl_IndicatorGetStyle, 3023). --define(wxStyledTextCtrl_IndicatorSetForeground, 3024). --define(wxStyledTextCtrl_IndicatorGetForeground, 3025). --define(wxStyledTextCtrl_SetWhitespaceForeground, 3026). --define(wxStyledTextCtrl_SetWhitespaceBackground, 3027). --define(wxStyledTextCtrl_GetStyleBits, 3028). --define(wxStyledTextCtrl_SetLineState, 3029). --define(wxStyledTextCtrl_GetLineState, 3030). --define(wxStyledTextCtrl_GetMaxLineState, 3031). --define(wxStyledTextCtrl_GetCaretLineVisible, 3032). --define(wxStyledTextCtrl_SetCaretLineVisible, 3033). --define(wxStyledTextCtrl_GetCaretLineBackground, 3034). --define(wxStyledTextCtrl_SetCaretLineBackground, 3035). --define(wxStyledTextCtrl_AutoCompShow, 3036). --define(wxStyledTextCtrl_AutoCompCancel, 3037). --define(wxStyledTextCtrl_AutoCompActive, 3038). --define(wxStyledTextCtrl_AutoCompPosStart, 3039). --define(wxStyledTextCtrl_AutoCompComplete, 3040). --define(wxStyledTextCtrl_AutoCompStops, 3041). --define(wxStyledTextCtrl_AutoCompSetSeparator, 3042). --define(wxStyledTextCtrl_AutoCompGetSeparator, 3043). --define(wxStyledTextCtrl_AutoCompSelect, 3044). --define(wxStyledTextCtrl_AutoCompSetCancelAtStart, 3045). --define(wxStyledTextCtrl_AutoCompGetCancelAtStart, 3046). --define(wxStyledTextCtrl_AutoCompSetFillUps, 3047). --define(wxStyledTextCtrl_AutoCompSetChooseSingle, 3048). --define(wxStyledTextCtrl_AutoCompGetChooseSingle, 3049). --define(wxStyledTextCtrl_AutoCompSetIgnoreCase, 3050). --define(wxStyledTextCtrl_AutoCompGetIgnoreCase, 3051). --define(wxStyledTextCtrl_UserListShow, 3052). --define(wxStyledTextCtrl_AutoCompSetAutoHide, 3053). --define(wxStyledTextCtrl_AutoCompGetAutoHide, 3054). --define(wxStyledTextCtrl_AutoCompSetDropRestOfWord, 3055). --define(wxStyledTextCtrl_AutoCompGetDropRestOfWord, 3056). --define(wxStyledTextCtrl_RegisterImage, 3057). --define(wxStyledTextCtrl_ClearRegisteredImages, 3058). --define(wxStyledTextCtrl_AutoCompGetTypeSeparator, 3059). --define(wxStyledTextCtrl_AutoCompSetTypeSeparator, 3060). --define(wxStyledTextCtrl_AutoCompSetMaxWidth, 3061). --define(wxStyledTextCtrl_AutoCompGetMaxWidth, 3062). --define(wxStyledTextCtrl_AutoCompSetMaxHeight, 3063). --define(wxStyledTextCtrl_AutoCompGetMaxHeight, 3064). --define(wxStyledTextCtrl_SetIndent, 3065). --define(wxStyledTextCtrl_GetIndent, 3066). --define(wxStyledTextCtrl_SetUseTabs, 3067). --define(wxStyledTextCtrl_GetUseTabs, 3068). --define(wxStyledTextCtrl_SetLineIndentation, 3069). --define(wxStyledTextCtrl_GetLineIndentation, 3070). --define(wxStyledTextCtrl_GetLineIndentPosition, 3071). --define(wxStyledTextCtrl_GetColumn, 3072). --define(wxStyledTextCtrl_SetUseHorizontalScrollBar, 3073). --define(wxStyledTextCtrl_GetUseHorizontalScrollBar, 3074). --define(wxStyledTextCtrl_SetIndentationGuides, 3075). --define(wxStyledTextCtrl_GetIndentationGuides, 3076). --define(wxStyledTextCtrl_SetHighlightGuide, 3077). --define(wxStyledTextCtrl_GetHighlightGuide, 3078). --define(wxStyledTextCtrl_GetLineEndPosition, 3079). --define(wxStyledTextCtrl_GetCodePage, 3080). --define(wxStyledTextCtrl_GetCaretForeground, 3081). --define(wxStyledTextCtrl_GetReadOnly, 3082). --define(wxStyledTextCtrl_SetCurrentPos, 3083). --define(wxStyledTextCtrl_SetSelectionStart, 3084). --define(wxStyledTextCtrl_GetSelectionStart, 3085). --define(wxStyledTextCtrl_SetSelectionEnd, 3086). --define(wxStyledTextCtrl_GetSelectionEnd, 3087). --define(wxStyledTextCtrl_SetPrintMagnification, 3088). --define(wxStyledTextCtrl_GetPrintMagnification, 3089). --define(wxStyledTextCtrl_SetPrintColourMode, 3090). --define(wxStyledTextCtrl_GetPrintColourMode, 3091). --define(wxStyledTextCtrl_FindText, 3092). --define(wxStyledTextCtrl_FormatRange, 3093). --define(wxStyledTextCtrl_GetFirstVisibleLine, 3094). --define(wxStyledTextCtrl_GetLine, 3095). --define(wxStyledTextCtrl_GetLineCount, 3096). --define(wxStyledTextCtrl_SetMarginLeft, 3097). --define(wxStyledTextCtrl_GetMarginLeft, 3098). --define(wxStyledTextCtrl_SetMarginRight, 3099). --define(wxStyledTextCtrl_GetMarginRight, 3100). --define(wxStyledTextCtrl_GetModify, 3101). --define(wxStyledTextCtrl_SetSelection, 3102). --define(wxStyledTextCtrl_GetSelectedText, 3103). --define(wxStyledTextCtrl_GetTextRange, 3104). --define(wxStyledTextCtrl_HideSelection, 3105). --define(wxStyledTextCtrl_LineFromPosition, 3106). --define(wxStyledTextCtrl_PositionFromLine, 3107). --define(wxStyledTextCtrl_LineScroll, 3108). --define(wxStyledTextCtrl_EnsureCaretVisible, 3109). --define(wxStyledTextCtrl_ReplaceSelection, 3110). --define(wxStyledTextCtrl_SetReadOnly, 3111). --define(wxStyledTextCtrl_CanPaste, 3112). --define(wxStyledTextCtrl_CanUndo, 3113). --define(wxStyledTextCtrl_EmptyUndoBuffer, 3114). --define(wxStyledTextCtrl_Undo, 3115). --define(wxStyledTextCtrl_Cut, 3116). --define(wxStyledTextCtrl_Copy, 3117). --define(wxStyledTextCtrl_Paste, 3118). --define(wxStyledTextCtrl_Clear, 3119). --define(wxStyledTextCtrl_SetText, 3120). --define(wxStyledTextCtrl_GetText, 3121). --define(wxStyledTextCtrl_GetTextLength, 3122). --define(wxStyledTextCtrl_GetOvertype, 3123). --define(wxStyledTextCtrl_SetCaretWidth, 3124). --define(wxStyledTextCtrl_GetCaretWidth, 3125). --define(wxStyledTextCtrl_SetTargetStart, 3126). --define(wxStyledTextCtrl_GetTargetStart, 3127). --define(wxStyledTextCtrl_SetTargetEnd, 3128). --define(wxStyledTextCtrl_GetTargetEnd, 3129). --define(wxStyledTextCtrl_ReplaceTarget, 3130). --define(wxStyledTextCtrl_SearchInTarget, 3131). --define(wxStyledTextCtrl_SetSearchFlags, 3132). --define(wxStyledTextCtrl_GetSearchFlags, 3133). --define(wxStyledTextCtrl_CallTipShow, 3134). --define(wxStyledTextCtrl_CallTipCancel, 3135). --define(wxStyledTextCtrl_CallTipActive, 3136). --define(wxStyledTextCtrl_CallTipPosAtStart, 3137). --define(wxStyledTextCtrl_CallTipSetHighlight, 3138). --define(wxStyledTextCtrl_CallTipSetBackground, 3139). --define(wxStyledTextCtrl_CallTipSetForeground, 3140). --define(wxStyledTextCtrl_CallTipSetForegroundHighlight, 3141). --define(wxStyledTextCtrl_CallTipUseStyle, 3142). --define(wxStyledTextCtrl_VisibleFromDocLine, 3143). --define(wxStyledTextCtrl_DocLineFromVisible, 3144). --define(wxStyledTextCtrl_WrapCount, 3145). --define(wxStyledTextCtrl_SetFoldLevel, 3146). --define(wxStyledTextCtrl_GetFoldLevel, 3147). --define(wxStyledTextCtrl_GetLastChild, 3148). --define(wxStyledTextCtrl_GetFoldParent, 3149). --define(wxStyledTextCtrl_ShowLines, 3150). --define(wxStyledTextCtrl_HideLines, 3151). --define(wxStyledTextCtrl_GetLineVisible, 3152). --define(wxStyledTextCtrl_SetFoldExpanded, 3153). --define(wxStyledTextCtrl_GetFoldExpanded, 3154). --define(wxStyledTextCtrl_ToggleFold, 3155). --define(wxStyledTextCtrl_EnsureVisible, 3156). --define(wxStyledTextCtrl_SetFoldFlags, 3157). --define(wxStyledTextCtrl_EnsureVisibleEnforcePolicy, 3158). --define(wxStyledTextCtrl_SetTabIndents, 3159). --define(wxStyledTextCtrl_GetTabIndents, 3160). --define(wxStyledTextCtrl_SetBackSpaceUnIndents, 3161). --define(wxStyledTextCtrl_GetBackSpaceUnIndents, 3162). --define(wxStyledTextCtrl_SetMouseDwellTime, 3163). --define(wxStyledTextCtrl_GetMouseDwellTime, 3164). --define(wxStyledTextCtrl_WordStartPosition, 3165). --define(wxStyledTextCtrl_WordEndPosition, 3166). --define(wxStyledTextCtrl_SetWrapMode, 3167). --define(wxStyledTextCtrl_GetWrapMode, 3168). --define(wxStyledTextCtrl_SetWrapVisualFlags, 3169). --define(wxStyledTextCtrl_GetWrapVisualFlags, 3170). --define(wxStyledTextCtrl_SetWrapVisualFlagsLocation, 3171). --define(wxStyledTextCtrl_GetWrapVisualFlagsLocation, 3172). --define(wxStyledTextCtrl_SetWrapStartIndent, 3173). --define(wxStyledTextCtrl_GetWrapStartIndent, 3174). --define(wxStyledTextCtrl_SetLayoutCache, 3175). --define(wxStyledTextCtrl_GetLayoutCache, 3176). --define(wxStyledTextCtrl_SetScrollWidth, 3177). --define(wxStyledTextCtrl_GetScrollWidth, 3178). --define(wxStyledTextCtrl_TextWidth, 3179). --define(wxStyledTextCtrl_GetEndAtLastLine, 3180). --define(wxStyledTextCtrl_TextHeight, 3181). --define(wxStyledTextCtrl_SetUseVerticalScrollBar, 3182). --define(wxStyledTextCtrl_GetUseVerticalScrollBar, 3183). --define(wxStyledTextCtrl_AppendText, 3184). --define(wxStyledTextCtrl_GetTwoPhaseDraw, 3185). --define(wxStyledTextCtrl_SetTwoPhaseDraw, 3186). --define(wxStyledTextCtrl_TargetFromSelection, 3187). --define(wxStyledTextCtrl_LinesJoin, 3188). --define(wxStyledTextCtrl_LinesSplit, 3189). --define(wxStyledTextCtrl_SetFoldMarginColour, 3190). --define(wxStyledTextCtrl_SetFoldMarginHiColour, 3191). --define(wxStyledTextCtrl_LineDown, 3192). --define(wxStyledTextCtrl_LineDownExtend, 3193). --define(wxStyledTextCtrl_LineUp, 3194). --define(wxStyledTextCtrl_LineUpExtend, 3195). --define(wxStyledTextCtrl_CharLeft, 3196). --define(wxStyledTextCtrl_CharLeftExtend, 3197). --define(wxStyledTextCtrl_CharRight, 3198). --define(wxStyledTextCtrl_CharRightExtend, 3199). --define(wxStyledTextCtrl_WordLeft, 3200). --define(wxStyledTextCtrl_WordLeftExtend, 3201). --define(wxStyledTextCtrl_WordRight, 3202). --define(wxStyledTextCtrl_WordRightExtend, 3203). --define(wxStyledTextCtrl_Home, 3204). --define(wxStyledTextCtrl_HomeExtend, 3205). --define(wxStyledTextCtrl_LineEnd, 3206). --define(wxStyledTextCtrl_LineEndExtend, 3207). --define(wxStyledTextCtrl_DocumentStart, 3208). --define(wxStyledTextCtrl_DocumentStartExtend, 3209). --define(wxStyledTextCtrl_DocumentEnd, 3210). --define(wxStyledTextCtrl_DocumentEndExtend, 3211). --define(wxStyledTextCtrl_PageUp, 3212). --define(wxStyledTextCtrl_PageUpExtend, 3213). --define(wxStyledTextCtrl_PageDown, 3214). --define(wxStyledTextCtrl_PageDownExtend, 3215). --define(wxStyledTextCtrl_EditToggleOvertype, 3216). --define(wxStyledTextCtrl_Cancel, 3217). --define(wxStyledTextCtrl_DeleteBack, 3218). --define(wxStyledTextCtrl_Tab, 3219). --define(wxStyledTextCtrl_BackTab, 3220). --define(wxStyledTextCtrl_NewLine, 3221). --define(wxStyledTextCtrl_FormFeed, 3222). --define(wxStyledTextCtrl_VCHome, 3223). --define(wxStyledTextCtrl_VCHomeExtend, 3224). --define(wxStyledTextCtrl_ZoomIn, 3225). --define(wxStyledTextCtrl_ZoomOut, 3226). --define(wxStyledTextCtrl_DelWordLeft, 3227). --define(wxStyledTextCtrl_DelWordRight, 3228). --define(wxStyledTextCtrl_LineCut, 3229). --define(wxStyledTextCtrl_LineDelete, 3230). --define(wxStyledTextCtrl_LineTranspose, 3231). --define(wxStyledTextCtrl_LineDuplicate, 3232). --define(wxStyledTextCtrl_LowerCase, 3233). --define(wxStyledTextCtrl_UpperCase, 3234). --define(wxStyledTextCtrl_LineScrollDown, 3235). --define(wxStyledTextCtrl_LineScrollUp, 3236). --define(wxStyledTextCtrl_DeleteBackNotLine, 3237). --define(wxStyledTextCtrl_HomeDisplay, 3238). --define(wxStyledTextCtrl_HomeDisplayExtend, 3239). --define(wxStyledTextCtrl_LineEndDisplay, 3240). --define(wxStyledTextCtrl_LineEndDisplayExtend, 3241). --define(wxStyledTextCtrl_HomeWrapExtend, 3242). --define(wxStyledTextCtrl_LineEndWrap, 3243). --define(wxStyledTextCtrl_LineEndWrapExtend, 3244). --define(wxStyledTextCtrl_VCHomeWrap, 3245). --define(wxStyledTextCtrl_VCHomeWrapExtend, 3246). --define(wxStyledTextCtrl_LineCopy, 3247). --define(wxStyledTextCtrl_MoveCaretInsideView, 3248). --define(wxStyledTextCtrl_LineLength, 3249). --define(wxStyledTextCtrl_BraceHighlight, 3250). --define(wxStyledTextCtrl_BraceBadLight, 3251). --define(wxStyledTextCtrl_BraceMatch, 3252). --define(wxStyledTextCtrl_GetViewEOL, 3253). --define(wxStyledTextCtrl_SetViewEOL, 3254). --define(wxStyledTextCtrl_SetModEventMask, 3255). --define(wxStyledTextCtrl_GetEdgeColumn, 3256). --define(wxStyledTextCtrl_SetEdgeColumn, 3257). --define(wxStyledTextCtrl_GetEdgeMode, 3258). --define(wxStyledTextCtrl_GetEdgeColour, 3259). --define(wxStyledTextCtrl_SetEdgeColour, 3260). --define(wxStyledTextCtrl_SearchAnchor, 3261). --define(wxStyledTextCtrl_SearchNext, 3262). --define(wxStyledTextCtrl_SearchPrev, 3263). --define(wxStyledTextCtrl_LinesOnScreen, 3264). --define(wxStyledTextCtrl_UsePopUp, 3265). --define(wxStyledTextCtrl_SelectionIsRectangle, 3266). --define(wxStyledTextCtrl_SetZoom, 3267). --define(wxStyledTextCtrl_GetZoom, 3268). --define(wxStyledTextCtrl_GetModEventMask, 3269). --define(wxStyledTextCtrl_SetSTCFocus, 3270). --define(wxStyledTextCtrl_GetSTCFocus, 3271). --define(wxStyledTextCtrl_SetStatus, 3272). --define(wxStyledTextCtrl_GetStatus, 3273). --define(wxStyledTextCtrl_SetMouseDownCaptures, 3274). --define(wxStyledTextCtrl_GetMouseDownCaptures, 3275). --define(wxStyledTextCtrl_SetSTCCursor, 3276). --define(wxStyledTextCtrl_GetSTCCursor, 3277). --define(wxStyledTextCtrl_SetControlCharSymbol, 3278). --define(wxStyledTextCtrl_GetControlCharSymbol, 3279). --define(wxStyledTextCtrl_WordPartLeft, 3280). --define(wxStyledTextCtrl_WordPartLeftExtend, 3281). --define(wxStyledTextCtrl_WordPartRight, 3282). --define(wxStyledTextCtrl_WordPartRightExtend, 3283). --define(wxStyledTextCtrl_SetVisiblePolicy, 3284). --define(wxStyledTextCtrl_DelLineLeft, 3285). --define(wxStyledTextCtrl_DelLineRight, 3286). --define(wxStyledTextCtrl_GetXOffset, 3287). --define(wxStyledTextCtrl_ChooseCaretX, 3288). --define(wxStyledTextCtrl_SetXCaretPolicy, 3289). --define(wxStyledTextCtrl_SetYCaretPolicy, 3290). --define(wxStyledTextCtrl_GetPrintWrapMode, 3291). --define(wxStyledTextCtrl_SetHotspotActiveForeground, 3292). --define(wxStyledTextCtrl_SetHotspotActiveBackground, 3293). --define(wxStyledTextCtrl_SetHotspotActiveUnderline, 3294). --define(wxStyledTextCtrl_SetHotspotSingleLine, 3295). --define(wxStyledTextCtrl_ParaDownExtend, 3296). --define(wxStyledTextCtrl_ParaUp, 3297). --define(wxStyledTextCtrl_ParaUpExtend, 3298). --define(wxStyledTextCtrl_PositionBefore, 3299). --define(wxStyledTextCtrl_PositionAfter, 3300). --define(wxStyledTextCtrl_CopyRange, 3301). --define(wxStyledTextCtrl_CopyText, 3302). --define(wxStyledTextCtrl_SetSelectionMode, 3303). --define(wxStyledTextCtrl_GetSelectionMode, 3304). --define(wxStyledTextCtrl_LineDownRectExtend, 3305). --define(wxStyledTextCtrl_LineUpRectExtend, 3306). --define(wxStyledTextCtrl_CharLeftRectExtend, 3307). --define(wxStyledTextCtrl_CharRightRectExtend, 3308). --define(wxStyledTextCtrl_HomeRectExtend, 3309). --define(wxStyledTextCtrl_VCHomeRectExtend, 3310). --define(wxStyledTextCtrl_LineEndRectExtend, 3311). --define(wxStyledTextCtrl_PageUpRectExtend, 3312). --define(wxStyledTextCtrl_PageDownRectExtend, 3313). --define(wxStyledTextCtrl_StutteredPageUp, 3314). --define(wxStyledTextCtrl_StutteredPageUpExtend, 3315). --define(wxStyledTextCtrl_StutteredPageDown, 3316). --define(wxStyledTextCtrl_StutteredPageDownExtend, 3317). --define(wxStyledTextCtrl_WordLeftEnd, 3318). --define(wxStyledTextCtrl_WordLeftEndExtend, 3319). --define(wxStyledTextCtrl_WordRightEnd, 3320). --define(wxStyledTextCtrl_WordRightEndExtend, 3321). --define(wxStyledTextCtrl_SetWhitespaceChars, 3322). --define(wxStyledTextCtrl_SetCharsDefault, 3323). --define(wxStyledTextCtrl_AutoCompGetCurrent, 3324). --define(wxStyledTextCtrl_Allocate, 3325). --define(wxStyledTextCtrl_FindColumn, 3326). --define(wxStyledTextCtrl_GetCaretSticky, 3327). --define(wxStyledTextCtrl_SetCaretSticky, 3328). --define(wxStyledTextCtrl_ToggleCaretSticky, 3329). --define(wxStyledTextCtrl_SetPasteConvertEndings, 3330). --define(wxStyledTextCtrl_GetPasteConvertEndings, 3331). --define(wxStyledTextCtrl_SelectionDuplicate, 3332). --define(wxStyledTextCtrl_SetCaretLineBackAlpha, 3333). --define(wxStyledTextCtrl_GetCaretLineBackAlpha, 3334). --define(wxStyledTextCtrl_StartRecord, 3335). --define(wxStyledTextCtrl_StopRecord, 3336). --define(wxStyledTextCtrl_SetLexer, 3337). --define(wxStyledTextCtrl_GetLexer, 3338). --define(wxStyledTextCtrl_Colourise, 3339). --define(wxStyledTextCtrl_SetProperty, 3340). --define(wxStyledTextCtrl_SetKeyWords, 3341). --define(wxStyledTextCtrl_SetLexerLanguage, 3342). --define(wxStyledTextCtrl_GetProperty, 3343). --define(wxStyledTextCtrl_GetStyleBitsNeeded, 3344). --define(wxStyledTextCtrl_GetCurrentLine, 3345). --define(wxStyledTextCtrl_StyleSetSpec, 3346). --define(wxStyledTextCtrl_StyleSetFont, 3347). --define(wxStyledTextCtrl_StyleSetFontAttr, 3348). --define(wxStyledTextCtrl_StyleSetCharacterSet, 3349). --define(wxStyledTextCtrl_StyleSetFontEncoding, 3350). --define(wxStyledTextCtrl_CmdKeyExecute, 3351). --define(wxStyledTextCtrl_SetMargins, 3352). --define(wxStyledTextCtrl_GetSelection, 3353). --define(wxStyledTextCtrl_PointFromPosition, 3354). --define(wxStyledTextCtrl_ScrollToLine, 3355). --define(wxStyledTextCtrl_ScrollToColumn, 3356). --define(wxStyledTextCtrl_SendMsg, 3357). --define(wxStyledTextCtrl_SetVScrollBar, 3358). --define(wxStyledTextCtrl_SetHScrollBar, 3359). --define(wxStyledTextCtrl_GetLastKeydownProcessed, 3360). --define(wxStyledTextCtrl_SetLastKeydownProcessed, 3361). --define(wxStyledTextCtrl_SaveFile, 3362). --define(wxStyledTextCtrl_LoadFile, 3363). --define(wxStyledTextCtrl_DoDragOver, 3364). --define(wxStyledTextCtrl_DoDropText, 3365). --define(wxStyledTextCtrl_GetUseAntiAliasing, 3366). --define(wxStyledTextCtrl_AddTextRaw, 3367). --define(wxStyledTextCtrl_InsertTextRaw, 3368). --define(wxStyledTextCtrl_GetCurLineRaw, 3369). --define(wxStyledTextCtrl_GetLineRaw, 3370). --define(wxStyledTextCtrl_GetSelectedTextRaw, 3371). --define(wxStyledTextCtrl_GetTextRangeRaw, 3372). --define(wxStyledTextCtrl_SetTextRaw, 3373). --define(wxStyledTextCtrl_GetTextRaw, 3374). --define(wxStyledTextCtrl_AppendTextRaw, 3375). --define(wxArtProvider_GetBitmap, 3376). --define(wxArtProvider_GetIcon, 3377). --define(wxTreeEvent_GetKeyCode, 3378). --define(wxTreeEvent_GetItem, 3379). --define(wxTreeEvent_GetKeyEvent, 3380). --define(wxTreeEvent_GetLabel, 3381). --define(wxTreeEvent_GetOldItem, 3382). --define(wxTreeEvent_GetPoint, 3383). --define(wxTreeEvent_IsEditCancelled, 3384). --define(wxTreeEvent_SetToolTip, 3385). --define(wxNotebookEvent_GetOldSelection, 3386). --define(wxNotebookEvent_GetSelection, 3387). --define(wxNotebookEvent_SetOldSelection, 3388). --define(wxNotebookEvent_SetSelection, 3389). --define(wxFileDataObject_new, 3390). --define(wxFileDataObject_AddFile, 3391). --define(wxFileDataObject_GetFilenames, 3392). --define(wxFileDataObject_destroy, 3393). --define(wxTextDataObject_new, 3394). --define(wxTextDataObject_GetTextLength, 3395). --define(wxTextDataObject_GetText, 3396). --define(wxTextDataObject_SetText, 3397). --define(wxTextDataObject_destroy, 3398). --define(wxBitmapDataObject_new_1_1, 3399). --define(wxBitmapDataObject_new_1_0, 3400). --define(wxBitmapDataObject_GetBitmap, 3401). --define(wxBitmapDataObject_SetBitmap, 3402). --define(wxBitmapDataObject_destroy, 3403). --define(wxClipboard_new, 3405). --define(wxClipboard_destruct, 3406). --define(wxClipboard_AddData, 3407). --define(wxClipboard_Clear, 3408). --define(wxClipboard_Close, 3409). --define(wxClipboard_Flush, 3410). --define(wxClipboard_GetData, 3411). --define(wxClipboard_IsOpened, 3412). --define(wxClipboard_Open, 3413). --define(wxClipboard_SetData, 3414). --define(wxClipboard_UsePrimarySelection, 3416). --define(wxClipboard_IsSupported, 3417). --define(wxClipboard_Get, 3418). --define(wxSpinEvent_GetPosition, 3419). --define(wxSpinEvent_SetPosition, 3420). --define(wxSplitterWindow_new_0, 3421). --define(wxSplitterWindow_new_2, 3422). --define(wxSplitterWindow_destruct, 3423). --define(wxSplitterWindow_Create, 3424). --define(wxSplitterWindow_GetMinimumPaneSize, 3425). --define(wxSplitterWindow_GetSashGravity, 3426). --define(wxSplitterWindow_GetSashPosition, 3427). --define(wxSplitterWindow_GetSplitMode, 3428). --define(wxSplitterWindow_GetWindow1, 3429). --define(wxSplitterWindow_GetWindow2, 3430). --define(wxSplitterWindow_Initialize, 3431). --define(wxSplitterWindow_IsSplit, 3432). --define(wxSplitterWindow_ReplaceWindow, 3433). --define(wxSplitterWindow_SetSashGravity, 3434). --define(wxSplitterWindow_SetSashPosition, 3435). --define(wxSplitterWindow_SetSashSize, 3436). --define(wxSplitterWindow_SetMinimumPaneSize, 3437). --define(wxSplitterWindow_SetSplitMode, 3438). --define(wxSplitterWindow_SplitHorizontally, 3439). --define(wxSplitterWindow_SplitVertically, 3440). --define(wxSplitterWindow_Unsplit, 3441). --define(wxSplitterWindow_UpdateSize, 3442). --define(wxSplitterEvent_GetSashPosition, 3443). --define(wxSplitterEvent_GetX, 3444). --define(wxSplitterEvent_GetY, 3445). --define(wxSplitterEvent_GetWindowBeingRemoved, 3446). --define(wxSplitterEvent_SetSashPosition, 3447). --define(wxHtmlWindow_new_0, 3448). --define(wxHtmlWindow_new_2, 3449). --define(wxHtmlWindow_AppendToPage, 3450). --define(wxHtmlWindow_GetOpenedAnchor, 3451). --define(wxHtmlWindow_GetOpenedPage, 3452). --define(wxHtmlWindow_GetOpenedPageTitle, 3453). --define(wxHtmlWindow_GetRelatedFrame, 3454). --define(wxHtmlWindow_HistoryBack, 3455). --define(wxHtmlWindow_HistoryCanBack, 3456). --define(wxHtmlWindow_HistoryCanForward, 3457). --define(wxHtmlWindow_HistoryClear, 3458). --define(wxHtmlWindow_HistoryForward, 3459). --define(wxHtmlWindow_LoadFile, 3460). --define(wxHtmlWindow_LoadPage, 3461). --define(wxHtmlWindow_SelectAll, 3462). --define(wxHtmlWindow_SelectionToText, 3463). --define(wxHtmlWindow_SelectLine, 3464). --define(wxHtmlWindow_SelectWord, 3465). --define(wxHtmlWindow_SetBorders, 3466). --define(wxHtmlWindow_SetFonts, 3467). --define(wxHtmlWindow_SetPage, 3468). --define(wxHtmlWindow_SetRelatedFrame, 3469). --define(wxHtmlWindow_SetRelatedStatusBar, 3470). --define(wxHtmlWindow_ToText, 3471). --define(wxHtmlWindow_destroy, 3472). --define(wxHtmlLinkEvent_GetLinkInfo, 3473). --define(wxAuiNotebookEvent_SetSelection, 3474). --define(wxAuiNotebookEvent_GetSelection, 3475). --define(wxAuiNotebookEvent_SetOldSelection, 3476). --define(wxAuiNotebookEvent_GetOldSelection, 3477). --define(wxAuiNotebookEvent_SetDragSource, 3478). --define(wxAuiNotebookEvent_GetDragSource, 3479). --define(wxAuiManagerEvent_SetManager, 3480). --define(wxAuiManagerEvent_GetManager, 3481). --define(wxAuiManagerEvent_SetPane, 3482). --define(wxAuiManagerEvent_GetPane, 3483). --define(wxAuiManagerEvent_SetButton, 3484). --define(wxAuiManagerEvent_GetButton, 3485). --define(wxAuiManagerEvent_SetDC, 3486). --define(wxAuiManagerEvent_GetDC, 3487). --define(wxAuiManagerEvent_Veto, 3488). --define(wxAuiManagerEvent_GetVeto, 3489). --define(wxAuiManagerEvent_SetCanVeto, 3490). --define(wxAuiManagerEvent_CanVeto, 3491). --define(wxLogNull_new, 3492). --define(wxLogNull_destroy, 3493). +-define(wxTreeCtrl_GetFirstChild, 2018). +-define(wxTreeCtrl_GetNextChild, 2019). +-define(wxTreeCtrl_GetFirstVisibleItem, 2020). +-define(wxTreeCtrl_GetImageList, 2021). +-define(wxTreeCtrl_GetIndent, 2022). +-define(wxTreeCtrl_GetItemBackgroundColour, 2023). +-define(wxTreeCtrl_GetItemData, 2024). +-define(wxTreeCtrl_GetItemFont, 2025). +-define(wxTreeCtrl_GetItemImage_1, 2026). +-define(wxTreeCtrl_GetItemImage_2, 2027). +-define(wxTreeCtrl_GetItemText, 2028). +-define(wxTreeCtrl_GetItemTextColour, 2029). +-define(wxTreeCtrl_GetLastChild, 2030). +-define(wxTreeCtrl_GetNextSibling, 2031). +-define(wxTreeCtrl_GetNextVisible, 2032). +-define(wxTreeCtrl_GetItemParent, 2033). +-define(wxTreeCtrl_GetPrevSibling, 2034). +-define(wxTreeCtrl_GetPrevVisible, 2035). +-define(wxTreeCtrl_GetRootItem, 2036). +-define(wxTreeCtrl_GetSelection, 2037). +-define(wxTreeCtrl_GetSelections, 2038). +-define(wxTreeCtrl_GetStateImageList, 2039). +-define(wxTreeCtrl_HitTest, 2040). +-define(wxTreeCtrl_InsertItem, 2042). +-define(wxTreeCtrl_IsBold, 2043). +-define(wxTreeCtrl_IsExpanded, 2044). +-define(wxTreeCtrl_IsSelected, 2045). +-define(wxTreeCtrl_IsVisible, 2046). +-define(wxTreeCtrl_ItemHasChildren, 2047). +-define(wxTreeCtrl_PrependItem, 2048). +-define(wxTreeCtrl_ScrollTo, 2049). +-define(wxTreeCtrl_SelectItem_1, 2050). +-define(wxTreeCtrl_SelectItem_2, 2051). +-define(wxTreeCtrl_SetIndent, 2052). +-define(wxTreeCtrl_SetImageList, 2053). +-define(wxTreeCtrl_SetItemBackgroundColour, 2054). +-define(wxTreeCtrl_SetItemBold, 2055). +-define(wxTreeCtrl_SetItemData, 2056). +-define(wxTreeCtrl_SetItemDropHighlight, 2057). +-define(wxTreeCtrl_SetItemFont, 2058). +-define(wxTreeCtrl_SetItemHasChildren, 2059). +-define(wxTreeCtrl_SetItemImage_2, 2060). +-define(wxTreeCtrl_SetItemImage_3, 2061). +-define(wxTreeCtrl_SetItemText, 2062). +-define(wxTreeCtrl_SetItemTextColour, 2063). +-define(wxTreeCtrl_SetStateImageList, 2064). +-define(wxTreeCtrl_SetWindowStyle, 2065). +-define(wxTreeCtrl_SortChildren, 2066). +-define(wxTreeCtrl_Toggle, 2067). +-define(wxTreeCtrl_ToggleItemSelection, 2068). +-define(wxTreeCtrl_Unselect, 2069). +-define(wxTreeCtrl_UnselectAll, 2070). +-define(wxTreeCtrl_UnselectItem, 2071). +-define(wxScrollBar_new_0, 2072). +-define(wxScrollBar_new_3, 2073). +-define(wxScrollBar_destruct, 2074). +-define(wxScrollBar_Create, 2075). +-define(wxScrollBar_GetRange, 2076). +-define(wxScrollBar_GetPageSize, 2077). +-define(wxScrollBar_GetThumbPosition, 2078). +-define(wxScrollBar_GetThumbSize, 2079). +-define(wxScrollBar_SetThumbPosition, 2080). +-define(wxScrollBar_SetScrollbar, 2081). +-define(wxSpinButton_new_2, 2083). +-define(wxSpinButton_new_0, 2084). +-define(wxSpinButton_Create, 2085). +-define(wxSpinButton_GetMax, 2086). +-define(wxSpinButton_GetMin, 2087). +-define(wxSpinButton_GetValue, 2088). +-define(wxSpinButton_SetRange, 2089). +-define(wxSpinButton_SetValue, 2090). +-define(wxSpinButton_destroy, 2091). +-define(wxSpinCtrl_new_0, 2092). +-define(wxSpinCtrl_new_2, 2093). +-define(wxSpinCtrl_Create, 2095). +-define(wxSpinCtrl_SetValue_1_1, 2098). +-define(wxSpinCtrl_SetValue_1_0, 2099). +-define(wxSpinCtrl_GetValue, 2101). +-define(wxSpinCtrl_SetRange, 2103). +-define(wxSpinCtrl_SetSelection, 2104). +-define(wxSpinCtrl_GetMin, 2106). +-define(wxSpinCtrl_GetMax, 2108). +-define(wxSpinCtrl_destroy, 2109). +-define(wxStaticText_new_0, 2110). +-define(wxStaticText_new_4, 2111). +-define(wxStaticText_Create, 2112). +-define(wxStaticText_GetLabel, 2113). +-define(wxStaticText_SetLabel, 2114). +-define(wxStaticText_Wrap, 2115). +-define(wxStaticText_destroy, 2116). +-define(wxStaticBitmap_new_0, 2117). +-define(wxStaticBitmap_new_4, 2118). +-define(wxStaticBitmap_Create, 2119). +-define(wxStaticBitmap_GetBitmap, 2120). +-define(wxStaticBitmap_SetBitmap, 2121). +-define(wxStaticBitmap_destroy, 2122). +-define(wxRadioBox_new, 2123). +-define(wxRadioBox_destruct, 2125). +-define(wxRadioBox_Create, 2126). +-define(wxRadioBox_Enable_2, 2127). +-define(wxRadioBox_Enable_1, 2128). +-define(wxRadioBox_GetSelection, 2129). +-define(wxRadioBox_GetString, 2130). +-define(wxRadioBox_SetSelection, 2131). +-define(wxRadioBox_Show_2, 2132). +-define(wxRadioBox_Show_1, 2133). +-define(wxRadioBox_GetColumnCount, 2134). +-define(wxRadioBox_GetItemHelpText, 2135). +-define(wxRadioBox_GetItemToolTip, 2136). +-define(wxRadioBox_GetItemFromPoint, 2138). +-define(wxRadioBox_GetRowCount, 2139). +-define(wxRadioBox_IsItemEnabled, 2140). +-define(wxRadioBox_IsItemShown, 2141). +-define(wxRadioBox_SetItemHelpText, 2142). +-define(wxRadioBox_SetItemToolTip, 2143). +-define(wxRadioButton_new_0, 2144). +-define(wxRadioButton_new_4, 2145). +-define(wxRadioButton_Create, 2146). +-define(wxRadioButton_GetValue, 2147). +-define(wxRadioButton_SetValue, 2148). +-define(wxRadioButton_destroy, 2149). +-define(wxSlider_new_6, 2151). +-define(wxSlider_new_0, 2152). +-define(wxSlider_Create, 2153). +-define(wxSlider_GetLineSize, 2154). +-define(wxSlider_GetMax, 2155). +-define(wxSlider_GetMin, 2156). +-define(wxSlider_GetPageSize, 2157). +-define(wxSlider_GetThumbLength, 2158). +-define(wxSlider_GetValue, 2159). +-define(wxSlider_SetLineSize, 2160). +-define(wxSlider_SetPageSize, 2161). +-define(wxSlider_SetRange, 2162). +-define(wxSlider_SetThumbLength, 2163). +-define(wxSlider_SetValue, 2164). +-define(wxSlider_destroy, 2165). +-define(wxDialog_new_4, 2167). +-define(wxDialog_new_0, 2168). +-define(wxDialog_destruct, 2170). +-define(wxDialog_Create, 2171). +-define(wxDialog_CreateButtonSizer, 2172). +-define(wxDialog_CreateStdDialogButtonSizer, 2173). +-define(wxDialog_EndModal, 2174). +-define(wxDialog_GetAffirmativeId, 2175). +-define(wxDialog_GetReturnCode, 2176). +-define(wxDialog_IsModal, 2177). +-define(wxDialog_SetAffirmativeId, 2178). +-define(wxDialog_SetReturnCode, 2179). +-define(wxDialog_Show, 2180). +-define(wxDialog_ShowModal, 2181). +-define(wxColourDialog_new_0, 2182). +-define(wxColourDialog_new_2, 2183). +-define(wxColourDialog_destruct, 2184). +-define(wxColourDialog_Create, 2185). +-define(wxColourDialog_GetColourData, 2186). +-define(wxColourData_new_0, 2187). +-define(wxColourData_new_1, 2188). +-define(wxColourData_destruct, 2189). +-define(wxColourData_GetChooseFull, 2190). +-define(wxColourData_GetColour, 2191). +-define(wxColourData_GetCustomColour, 2193). +-define(wxColourData_SetChooseFull, 2194). +-define(wxColourData_SetColour, 2195). +-define(wxColourData_SetCustomColour, 2196). +-define(wxPalette_new_0, 2197). +-define(wxPalette_new_4, 2198). +-define(wxPalette_destruct, 2200). +-define(wxPalette_Create, 2201). +-define(wxPalette_GetColoursCount, 2202). +-define(wxPalette_GetPixel, 2203). +-define(wxPalette_GetRGB, 2204). +-define(wxPalette_IsOk, 2205). +-define(wxDirDialog_new, 2209). +-define(wxDirDialog_destruct, 2210). +-define(wxDirDialog_GetPath, 2211). +-define(wxDirDialog_GetMessage, 2212). +-define(wxDirDialog_SetMessage, 2213). +-define(wxDirDialog_SetPath, 2214). +-define(wxFileDialog_new, 2218). +-define(wxFileDialog_destruct, 2219). +-define(wxFileDialog_GetDirectory, 2220). +-define(wxFileDialog_GetFilename, 2221). +-define(wxFileDialog_GetFilenames, 2222). +-define(wxFileDialog_GetFilterIndex, 2223). +-define(wxFileDialog_GetMessage, 2224). +-define(wxFileDialog_GetPath, 2225). +-define(wxFileDialog_GetPaths, 2226). +-define(wxFileDialog_GetWildcard, 2227). +-define(wxFileDialog_SetDirectory, 2228). +-define(wxFileDialog_SetFilename, 2229). +-define(wxFileDialog_SetFilterIndex, 2230). +-define(wxFileDialog_SetMessage, 2231). +-define(wxFileDialog_SetPath, 2232). +-define(wxFileDialog_SetWildcard, 2233). +-define(wxPickerBase_SetInternalMargin, 2234). +-define(wxPickerBase_GetInternalMargin, 2235). +-define(wxPickerBase_SetTextCtrlProportion, 2236). +-define(wxPickerBase_SetPickerCtrlProportion, 2237). +-define(wxPickerBase_GetTextCtrlProportion, 2238). +-define(wxPickerBase_GetPickerCtrlProportion, 2239). +-define(wxPickerBase_HasTextCtrl, 2240). +-define(wxPickerBase_GetTextCtrl, 2241). +-define(wxPickerBase_IsTextCtrlGrowable, 2242). +-define(wxPickerBase_SetPickerCtrlGrowable, 2243). +-define(wxPickerBase_SetTextCtrlGrowable, 2244). +-define(wxPickerBase_IsPickerCtrlGrowable, 2245). +-define(wxFilePickerCtrl_new_0, 2246). +-define(wxFilePickerCtrl_new_3, 2247). +-define(wxFilePickerCtrl_Create, 2248). +-define(wxFilePickerCtrl_GetPath, 2249). +-define(wxFilePickerCtrl_SetPath, 2250). +-define(wxFilePickerCtrl_destroy, 2251). +-define(wxDirPickerCtrl_new_0, 2252). +-define(wxDirPickerCtrl_new_3, 2253). +-define(wxDirPickerCtrl_Create, 2254). +-define(wxDirPickerCtrl_GetPath, 2255). +-define(wxDirPickerCtrl_SetPath, 2256). +-define(wxDirPickerCtrl_destroy, 2257). +-define(wxColourPickerCtrl_new_0, 2258). +-define(wxColourPickerCtrl_new_3, 2259). +-define(wxColourPickerCtrl_Create, 2260). +-define(wxColourPickerCtrl_GetColour, 2261). +-define(wxColourPickerCtrl_SetColour_1_1, 2262). +-define(wxColourPickerCtrl_SetColour_1_0, 2263). +-define(wxColourPickerCtrl_destroy, 2264). +-define(wxDatePickerCtrl_new_0, 2265). +-define(wxDatePickerCtrl_new_3, 2266). +-define(wxDatePickerCtrl_GetRange, 2267). +-define(wxDatePickerCtrl_GetValue, 2268). +-define(wxDatePickerCtrl_SetRange, 2269). +-define(wxDatePickerCtrl_SetValue, 2270). +-define(wxDatePickerCtrl_destroy, 2271). +-define(wxFontPickerCtrl_new_0, 2272). +-define(wxFontPickerCtrl_new_3, 2273). +-define(wxFontPickerCtrl_Create, 2274). +-define(wxFontPickerCtrl_GetSelectedFont, 2275). +-define(wxFontPickerCtrl_SetSelectedFont, 2276). +-define(wxFontPickerCtrl_GetMaxPointSize, 2277). +-define(wxFontPickerCtrl_SetMaxPointSize, 2278). +-define(wxFontPickerCtrl_destroy, 2279). +-define(wxFindReplaceDialog_new_0, 2282). +-define(wxFindReplaceDialog_new_4, 2283). +-define(wxFindReplaceDialog_destruct, 2284). +-define(wxFindReplaceDialog_Create, 2285). +-define(wxFindReplaceDialog_GetData, 2286). +-define(wxFindReplaceData_new_0, 2287). +-define(wxFindReplaceData_new_1, 2288). +-define(wxFindReplaceData_GetFindString, 2289). +-define(wxFindReplaceData_GetReplaceString, 2290). +-define(wxFindReplaceData_GetFlags, 2291). +-define(wxFindReplaceData_SetFlags, 2292). +-define(wxFindReplaceData_SetFindString, 2293). +-define(wxFindReplaceData_SetReplaceString, 2294). +-define(wxFindReplaceData_destroy, 2295). +-define(wxMultiChoiceDialog_new_0, 2296). +-define(wxMultiChoiceDialog_new_5, 2298). +-define(wxMultiChoiceDialog_GetSelections, 2299). +-define(wxMultiChoiceDialog_SetSelections, 2300). +-define(wxMultiChoiceDialog_destroy, 2301). +-define(wxSingleChoiceDialog_new_0, 2302). +-define(wxSingleChoiceDialog_new_5, 2304). +-define(wxSingleChoiceDialog_GetSelection, 2305). +-define(wxSingleChoiceDialog_GetStringSelection, 2306). +-define(wxSingleChoiceDialog_SetSelection, 2307). +-define(wxSingleChoiceDialog_destroy, 2308). +-define(wxTextEntryDialog_new, 2309). +-define(wxTextEntryDialog_GetValue, 2310). +-define(wxTextEntryDialog_SetValue, 2311). +-define(wxTextEntryDialog_destroy, 2312). +-define(wxPasswordEntryDialog_new, 2313). +-define(wxPasswordEntryDialog_destroy, 2314). +-define(wxFontData_new_0, 2315). +-define(wxFontData_new_1, 2316). +-define(wxFontData_destruct, 2317). +-define(wxFontData_EnableEffects, 2318). +-define(wxFontData_GetAllowSymbols, 2319). +-define(wxFontData_GetColour, 2320). +-define(wxFontData_GetChosenFont, 2321). +-define(wxFontData_GetEnableEffects, 2322). +-define(wxFontData_GetInitialFont, 2323). +-define(wxFontData_GetShowHelp, 2324). +-define(wxFontData_SetAllowSymbols, 2325). +-define(wxFontData_SetChosenFont, 2326). +-define(wxFontData_SetColour, 2327). +-define(wxFontData_SetInitialFont, 2328). +-define(wxFontData_SetRange, 2329). +-define(wxFontData_SetShowHelp, 2330). +-define(wxFontDialog_new_0, 2334). +-define(wxFontDialog_new_2, 2336). +-define(wxFontDialog_Create, 2338). +-define(wxFontDialog_GetFontData, 2339). +-define(wxFontDialog_destroy, 2341). +-define(wxProgressDialog_new, 2342). +-define(wxProgressDialog_destruct, 2343). +-define(wxProgressDialog_Resume, 2344). +-define(wxProgressDialog_Update_2, 2345). +-define(wxProgressDialog_Update_0, 2346). +-define(wxMessageDialog_new, 2347). +-define(wxMessageDialog_destruct, 2348). +-define(wxPageSetupDialog_new, 2349). +-define(wxPageSetupDialog_destruct, 2350). +-define(wxPageSetupDialog_GetPageSetupData, 2351). +-define(wxPageSetupDialog_ShowModal, 2352). +-define(wxPageSetupDialogData_new_0, 2353). +-define(wxPageSetupDialogData_new_1_0, 2354). +-define(wxPageSetupDialogData_new_1_1, 2355). +-define(wxPageSetupDialogData_destruct, 2356). +-define(wxPageSetupDialogData_EnableHelp, 2357). +-define(wxPageSetupDialogData_EnableMargins, 2358). +-define(wxPageSetupDialogData_EnableOrientation, 2359). +-define(wxPageSetupDialogData_EnablePaper, 2360). +-define(wxPageSetupDialogData_EnablePrinter, 2361). +-define(wxPageSetupDialogData_GetDefaultMinMargins, 2362). +-define(wxPageSetupDialogData_GetEnableMargins, 2363). +-define(wxPageSetupDialogData_GetEnableOrientation, 2364). +-define(wxPageSetupDialogData_GetEnablePaper, 2365). +-define(wxPageSetupDialogData_GetEnablePrinter, 2366). +-define(wxPageSetupDialogData_GetEnableHelp, 2367). +-define(wxPageSetupDialogData_GetDefaultInfo, 2368). +-define(wxPageSetupDialogData_GetMarginTopLeft, 2369). +-define(wxPageSetupDialogData_GetMarginBottomRight, 2370). +-define(wxPageSetupDialogData_GetMinMarginTopLeft, 2371). +-define(wxPageSetupDialogData_GetMinMarginBottomRight, 2372). +-define(wxPageSetupDialogData_GetPaperId, 2373). +-define(wxPageSetupDialogData_GetPaperSize, 2374). +-define(wxPageSetupDialogData_GetPrintData, 2376). +-define(wxPageSetupDialogData_IsOk, 2377). +-define(wxPageSetupDialogData_SetDefaultInfo, 2378). +-define(wxPageSetupDialogData_SetDefaultMinMargins, 2379). +-define(wxPageSetupDialogData_SetMarginTopLeft, 2380). +-define(wxPageSetupDialogData_SetMarginBottomRight, 2381). +-define(wxPageSetupDialogData_SetMinMarginTopLeft, 2382). +-define(wxPageSetupDialogData_SetMinMarginBottomRight, 2383). +-define(wxPageSetupDialogData_SetPaperId, 2384). +-define(wxPageSetupDialogData_SetPaperSize_1_1, 2385). +-define(wxPageSetupDialogData_SetPaperSize_1_0, 2386). +-define(wxPageSetupDialogData_SetPrintData, 2387). +-define(wxPrintDialog_new_2_0, 2388). +-define(wxPrintDialog_new_2_1, 2389). +-define(wxPrintDialog_destruct, 2390). +-define(wxPrintDialog_GetPrintDialogData, 2391). +-define(wxPrintDialog_GetPrintDC, 2392). +-define(wxPrintDialogData_new_0, 2393). +-define(wxPrintDialogData_new_1_1, 2394). +-define(wxPrintDialogData_new_1_0, 2395). +-define(wxPrintDialogData_destruct, 2396). +-define(wxPrintDialogData_EnableHelp, 2397). +-define(wxPrintDialogData_EnablePageNumbers, 2398). +-define(wxPrintDialogData_EnablePrintToFile, 2399). +-define(wxPrintDialogData_EnableSelection, 2400). +-define(wxPrintDialogData_GetAllPages, 2401). +-define(wxPrintDialogData_GetCollate, 2402). +-define(wxPrintDialogData_GetFromPage, 2403). +-define(wxPrintDialogData_GetMaxPage, 2404). +-define(wxPrintDialogData_GetMinPage, 2405). +-define(wxPrintDialogData_GetNoCopies, 2406). +-define(wxPrintDialogData_GetPrintData, 2407). +-define(wxPrintDialogData_GetPrintToFile, 2408). +-define(wxPrintDialogData_GetSelection, 2409). +-define(wxPrintDialogData_GetToPage, 2410). +-define(wxPrintDialogData_IsOk, 2411). +-define(wxPrintDialogData_SetCollate, 2412). +-define(wxPrintDialogData_SetFromPage, 2413). +-define(wxPrintDialogData_SetMaxPage, 2414). +-define(wxPrintDialogData_SetMinPage, 2415). +-define(wxPrintDialogData_SetNoCopies, 2416). +-define(wxPrintDialogData_SetPrintData, 2417). +-define(wxPrintDialogData_SetPrintToFile, 2418). +-define(wxPrintDialogData_SetSelection, 2419). +-define(wxPrintDialogData_SetToPage, 2420). +-define(wxPrintData_new_0, 2421). +-define(wxPrintData_new_1, 2422). +-define(wxPrintData_destruct, 2423). +-define(wxPrintData_GetCollate, 2424). +-define(wxPrintData_GetBin, 2425). +-define(wxPrintData_GetColour, 2426). +-define(wxPrintData_GetDuplex, 2427). +-define(wxPrintData_GetNoCopies, 2428). +-define(wxPrintData_GetOrientation, 2429). +-define(wxPrintData_GetPaperId, 2430). +-define(wxPrintData_GetPrinterName, 2431). +-define(wxPrintData_GetQuality, 2432). +-define(wxPrintData_IsOk, 2433). +-define(wxPrintData_SetBin, 2434). +-define(wxPrintData_SetCollate, 2435). +-define(wxPrintData_SetColour, 2436). +-define(wxPrintData_SetDuplex, 2437). +-define(wxPrintData_SetNoCopies, 2438). +-define(wxPrintData_SetOrientation, 2439). +-define(wxPrintData_SetPaperId, 2440). +-define(wxPrintData_SetPrinterName, 2441). +-define(wxPrintData_SetQuality, 2442). +-define(wxPrintPreview_new_2, 2445). +-define(wxPrintPreview_new_3, 2446). +-define(wxPrintPreview_destruct, 2448). +-define(wxPrintPreview_GetCanvas, 2449). +-define(wxPrintPreview_GetCurrentPage, 2450). +-define(wxPrintPreview_GetFrame, 2451). +-define(wxPrintPreview_GetMaxPage, 2452). +-define(wxPrintPreview_GetMinPage, 2453). +-define(wxPrintPreview_GetPrintout, 2454). +-define(wxPrintPreview_GetPrintoutForPrinting, 2455). +-define(wxPrintPreview_IsOk, 2456). +-define(wxPrintPreview_PaintPage, 2457). +-define(wxPrintPreview_Print, 2458). +-define(wxPrintPreview_RenderPage, 2459). +-define(wxPrintPreview_SetCanvas, 2460). +-define(wxPrintPreview_SetCurrentPage, 2461). +-define(wxPrintPreview_SetFrame, 2462). +-define(wxPrintPreview_SetPrintout, 2463). +-define(wxPrintPreview_SetZoom, 2464). +-define(wxPreviewFrame_new, 2465). +-define(wxPreviewFrame_destruct, 2466). +-define(wxPreviewFrame_CreateControlBar, 2467). +-define(wxPreviewFrame_CreateCanvas, 2468). +-define(wxPreviewFrame_Initialize, 2469). +-define(wxPreviewFrame_OnCloseWindow, 2470). +-define(wxPreviewControlBar_new, 2471). +-define(wxPreviewControlBar_destruct, 2472). +-define(wxPreviewControlBar_CreateButtons, 2473). +-define(wxPreviewControlBar_GetPrintPreview, 2474). +-define(wxPreviewControlBar_GetZoomControl, 2475). +-define(wxPreviewControlBar_SetZoomControl, 2476). +-define(wxPrinter_new, 2478). +-define(wxPrinter_CreateAbortWindow, 2479). +-define(wxPrinter_GetAbort, 2480). +-define(wxPrinter_GetLastError, 2481). +-define(wxPrinter_GetPrintDialogData, 2482). +-define(wxPrinter_Print, 2483). +-define(wxPrinter_PrintDialog, 2484). +-define(wxPrinter_ReportError, 2485). +-define(wxPrinter_Setup, 2486). +-define(wxPrinter_destroy, 2487). +-define(wxXmlResource_new_1, 2488). +-define(wxXmlResource_new_2, 2489). +-define(wxXmlResource_destruct, 2490). +-define(wxXmlResource_AttachUnknownControl, 2491). +-define(wxXmlResource_ClearHandlers, 2492). +-define(wxXmlResource_CompareVersion, 2493). +-define(wxXmlResource_Get, 2494). +-define(wxXmlResource_GetFlags, 2495). +-define(wxXmlResource_GetVersion, 2496). +-define(wxXmlResource_GetXRCID, 2497). +-define(wxXmlResource_InitAllHandlers, 2498). +-define(wxXmlResource_Load, 2499). +-define(wxXmlResource_LoadBitmap, 2500). +-define(wxXmlResource_LoadDialog_2, 2501). +-define(wxXmlResource_LoadDialog_3, 2502). +-define(wxXmlResource_LoadFrame_2, 2503). +-define(wxXmlResource_LoadFrame_3, 2504). +-define(wxXmlResource_LoadIcon, 2505). +-define(wxXmlResource_LoadMenu, 2506). +-define(wxXmlResource_LoadMenuBar_2, 2507). +-define(wxXmlResource_LoadMenuBar_1, 2508). +-define(wxXmlResource_LoadPanel_2, 2509). +-define(wxXmlResource_LoadPanel_3, 2510). +-define(wxXmlResource_LoadToolBar, 2511). +-define(wxXmlResource_Set, 2512). +-define(wxXmlResource_SetFlags, 2513). +-define(wxXmlResource_Unload, 2514). +-define(wxXmlResource_xrcctrl, 2515). +-define(wxHtmlEasyPrinting_new, 2516). +-define(wxHtmlEasyPrinting_destruct, 2517). +-define(wxHtmlEasyPrinting_GetPrintData, 2518). +-define(wxHtmlEasyPrinting_GetPageSetupData, 2519). +-define(wxHtmlEasyPrinting_PreviewFile, 2520). +-define(wxHtmlEasyPrinting_PreviewText, 2521). +-define(wxHtmlEasyPrinting_PrintFile, 2522). +-define(wxHtmlEasyPrinting_PrintText, 2523). +-define(wxHtmlEasyPrinting_PageSetup, 2524). +-define(wxHtmlEasyPrinting_SetFonts, 2525). +-define(wxHtmlEasyPrinting_SetHeader, 2526). +-define(wxHtmlEasyPrinting_SetFooter, 2527). +-define(wxGLCanvas_new_2, 2529). +-define(wxGLCanvas_new_3_1, 2530). +-define(wxGLCanvas_new_3_0, 2531). +-define(wxGLCanvas_GetContext, 2532). +-define(wxGLCanvas_SetCurrent, 2534). +-define(wxGLCanvas_SwapBuffers, 2535). +-define(wxGLCanvas_destroy, 2536). +-define(wxAuiManager_new, 2537). +-define(wxAuiManager_destruct, 2538). +-define(wxAuiManager_AddPane_2_1, 2539). +-define(wxAuiManager_AddPane_3, 2540). +-define(wxAuiManager_AddPane_2_0, 2541). +-define(wxAuiManager_DetachPane, 2542). +-define(wxAuiManager_GetAllPanes, 2543). +-define(wxAuiManager_GetArtProvider, 2544). +-define(wxAuiManager_GetDockSizeConstraint, 2545). +-define(wxAuiManager_GetFlags, 2546). +-define(wxAuiManager_GetManagedWindow, 2547). +-define(wxAuiManager_GetManager, 2548). +-define(wxAuiManager_GetPane_1_1, 2549). +-define(wxAuiManager_GetPane_1_0, 2550). +-define(wxAuiManager_HideHint, 2551). +-define(wxAuiManager_InsertPane, 2552). +-define(wxAuiManager_LoadPaneInfo, 2553). +-define(wxAuiManager_LoadPerspective, 2554). +-define(wxAuiManager_SavePaneInfo, 2555). +-define(wxAuiManager_SavePerspective, 2556). +-define(wxAuiManager_SetArtProvider, 2557). +-define(wxAuiManager_SetDockSizeConstraint, 2558). +-define(wxAuiManager_SetFlags, 2559). +-define(wxAuiManager_SetManagedWindow, 2560). +-define(wxAuiManager_ShowHint, 2561). +-define(wxAuiManager_UnInit, 2562). +-define(wxAuiManager_Update, 2563). +-define(wxAuiPaneInfo_new_0, 2564). +-define(wxAuiPaneInfo_new_1, 2565). +-define(wxAuiPaneInfo_destruct, 2566). +-define(wxAuiPaneInfo_BestSize_1, 2567). +-define(wxAuiPaneInfo_BestSize_2, 2568). +-define(wxAuiPaneInfo_Bottom, 2569). +-define(wxAuiPaneInfo_BottomDockable, 2570). +-define(wxAuiPaneInfo_Caption, 2571). +-define(wxAuiPaneInfo_CaptionVisible, 2572). +-define(wxAuiPaneInfo_Centre, 2573). +-define(wxAuiPaneInfo_CentrePane, 2574). +-define(wxAuiPaneInfo_CloseButton, 2575). +-define(wxAuiPaneInfo_DefaultPane, 2576). +-define(wxAuiPaneInfo_DestroyOnClose, 2577). +-define(wxAuiPaneInfo_Direction, 2578). +-define(wxAuiPaneInfo_Dock, 2579). +-define(wxAuiPaneInfo_Dockable, 2580). +-define(wxAuiPaneInfo_Fixed, 2581). +-define(wxAuiPaneInfo_Float, 2582). +-define(wxAuiPaneInfo_Floatable, 2583). +-define(wxAuiPaneInfo_FloatingPosition_1, 2584). +-define(wxAuiPaneInfo_FloatingPosition_2, 2585). +-define(wxAuiPaneInfo_FloatingSize_1, 2586). +-define(wxAuiPaneInfo_FloatingSize_2, 2587). +-define(wxAuiPaneInfo_Gripper, 2588). +-define(wxAuiPaneInfo_GripperTop, 2589). +-define(wxAuiPaneInfo_HasBorder, 2590). +-define(wxAuiPaneInfo_HasCaption, 2591). +-define(wxAuiPaneInfo_HasCloseButton, 2592). +-define(wxAuiPaneInfo_HasFlag, 2593). +-define(wxAuiPaneInfo_HasGripper, 2594). +-define(wxAuiPaneInfo_HasGripperTop, 2595). +-define(wxAuiPaneInfo_HasMaximizeButton, 2596). +-define(wxAuiPaneInfo_HasMinimizeButton, 2597). +-define(wxAuiPaneInfo_HasPinButton, 2598). +-define(wxAuiPaneInfo_Hide, 2599). +-define(wxAuiPaneInfo_IsBottomDockable, 2600). +-define(wxAuiPaneInfo_IsDocked, 2601). +-define(wxAuiPaneInfo_IsFixed, 2602). +-define(wxAuiPaneInfo_IsFloatable, 2603). +-define(wxAuiPaneInfo_IsFloating, 2604). +-define(wxAuiPaneInfo_IsLeftDockable, 2605). +-define(wxAuiPaneInfo_IsMovable, 2606). +-define(wxAuiPaneInfo_IsOk, 2607). +-define(wxAuiPaneInfo_IsResizable, 2608). +-define(wxAuiPaneInfo_IsRightDockable, 2609). +-define(wxAuiPaneInfo_IsShown, 2610). +-define(wxAuiPaneInfo_IsToolbar, 2611). +-define(wxAuiPaneInfo_IsTopDockable, 2612). +-define(wxAuiPaneInfo_Layer, 2613). +-define(wxAuiPaneInfo_Left, 2614). +-define(wxAuiPaneInfo_LeftDockable, 2615). +-define(wxAuiPaneInfo_MaxSize_1, 2616). +-define(wxAuiPaneInfo_MaxSize_2, 2617). +-define(wxAuiPaneInfo_MaximizeButton, 2618). +-define(wxAuiPaneInfo_MinSize_1, 2619). +-define(wxAuiPaneInfo_MinSize_2, 2620). +-define(wxAuiPaneInfo_MinimizeButton, 2621). +-define(wxAuiPaneInfo_Movable, 2622). +-define(wxAuiPaneInfo_Name, 2623). +-define(wxAuiPaneInfo_PaneBorder, 2624). +-define(wxAuiPaneInfo_PinButton, 2625). +-define(wxAuiPaneInfo_Position, 2626). +-define(wxAuiPaneInfo_Resizable, 2627). +-define(wxAuiPaneInfo_Right, 2628). +-define(wxAuiPaneInfo_RightDockable, 2629). +-define(wxAuiPaneInfo_Row, 2630). +-define(wxAuiPaneInfo_SafeSet, 2631). +-define(wxAuiPaneInfo_SetFlag, 2632). +-define(wxAuiPaneInfo_Show, 2633). +-define(wxAuiPaneInfo_ToolbarPane, 2634). +-define(wxAuiPaneInfo_Top, 2635). +-define(wxAuiPaneInfo_TopDockable, 2636). +-define(wxAuiPaneInfo_Window, 2637). +-define(wxAuiNotebook_new_0, 2638). +-define(wxAuiNotebook_new_2, 2639). +-define(wxAuiNotebook_AddPage, 2640). +-define(wxAuiNotebook_Create, 2641). +-define(wxAuiNotebook_DeletePage, 2642). +-define(wxAuiNotebook_GetArtProvider, 2643). +-define(wxAuiNotebook_GetPage, 2644). +-define(wxAuiNotebook_GetPageBitmap, 2645). +-define(wxAuiNotebook_GetPageCount, 2646). +-define(wxAuiNotebook_GetPageIndex, 2647). +-define(wxAuiNotebook_GetPageText, 2648). +-define(wxAuiNotebook_GetSelection, 2649). +-define(wxAuiNotebook_InsertPage, 2650). +-define(wxAuiNotebook_RemovePage, 2651). +-define(wxAuiNotebook_SetArtProvider, 2652). +-define(wxAuiNotebook_SetFont, 2653). +-define(wxAuiNotebook_SetPageBitmap, 2654). +-define(wxAuiNotebook_SetPageText, 2655). +-define(wxAuiNotebook_SetSelection, 2656). +-define(wxAuiNotebook_SetTabCtrlHeight, 2657). +-define(wxAuiNotebook_SetUniformBitmapSize, 2658). +-define(wxAuiNotebook_destroy, 2659). +-define(wxMDIParentFrame_new_0, 2660). +-define(wxMDIParentFrame_new_4, 2661). +-define(wxMDIParentFrame_destruct, 2662). +-define(wxMDIParentFrame_ActivateNext, 2663). +-define(wxMDIParentFrame_ActivatePrevious, 2664). +-define(wxMDIParentFrame_ArrangeIcons, 2665). +-define(wxMDIParentFrame_Cascade, 2666). +-define(wxMDIParentFrame_Create, 2667). +-define(wxMDIParentFrame_GetActiveChild, 2668). +-define(wxMDIParentFrame_GetClientWindow, 2669). +-define(wxMDIParentFrame_Tile, 2670). +-define(wxMDIChildFrame_new_0, 2671). +-define(wxMDIChildFrame_new_4, 2672). +-define(wxMDIChildFrame_destruct, 2673). +-define(wxMDIChildFrame_Activate, 2674). +-define(wxMDIChildFrame_Create, 2675). +-define(wxMDIChildFrame_Maximize, 2676). +-define(wxMDIChildFrame_Restore, 2677). +-define(wxMDIClientWindow_new_0, 2678). +-define(wxMDIClientWindow_new_2, 2679). +-define(wxMDIClientWindow_destruct, 2680). +-define(wxMDIClientWindow_CreateClient, 2681). +-define(wxLayoutAlgorithm_new, 2682). +-define(wxLayoutAlgorithm_LayoutFrame, 2683). +-define(wxLayoutAlgorithm_LayoutMDIFrame, 2684). +-define(wxLayoutAlgorithm_LayoutWindow, 2685). +-define(wxLayoutAlgorithm_destroy, 2686). +-define(wxEvent_GetId, 2687). +-define(wxEvent_GetSkipped, 2688). +-define(wxEvent_GetTimestamp, 2689). +-define(wxEvent_IsCommandEvent, 2690). +-define(wxEvent_ResumePropagation, 2691). +-define(wxEvent_ShouldPropagate, 2692). +-define(wxEvent_Skip, 2693). +-define(wxEvent_StopPropagation, 2694). +-define(wxCommandEvent_getClientData, 2695). +-define(wxCommandEvent_GetExtraLong, 2696). +-define(wxCommandEvent_GetInt, 2697). +-define(wxCommandEvent_GetSelection, 2698). +-define(wxCommandEvent_GetString, 2699). +-define(wxCommandEvent_IsChecked, 2700). +-define(wxCommandEvent_IsSelection, 2701). +-define(wxCommandEvent_SetInt, 2702). +-define(wxCommandEvent_SetString, 2703). +-define(wxScrollEvent_GetOrientation, 2704). +-define(wxScrollEvent_GetPosition, 2705). +-define(wxScrollWinEvent_GetOrientation, 2706). +-define(wxScrollWinEvent_GetPosition, 2707). +-define(wxMouseEvent_AltDown, 2708). +-define(wxMouseEvent_Button, 2709). +-define(wxMouseEvent_ButtonDClick, 2710). +-define(wxMouseEvent_ButtonDown, 2711). +-define(wxMouseEvent_ButtonUp, 2712). +-define(wxMouseEvent_CmdDown, 2713). +-define(wxMouseEvent_ControlDown, 2714). +-define(wxMouseEvent_Dragging, 2715). +-define(wxMouseEvent_Entering, 2716). +-define(wxMouseEvent_GetButton, 2717). +-define(wxMouseEvent_GetPosition, 2720). +-define(wxMouseEvent_GetLogicalPosition, 2721). +-define(wxMouseEvent_GetLinesPerAction, 2722). +-define(wxMouseEvent_GetWheelRotation, 2723). +-define(wxMouseEvent_GetWheelDelta, 2724). +-define(wxMouseEvent_GetX, 2725). +-define(wxMouseEvent_GetY, 2726). +-define(wxMouseEvent_IsButton, 2727). +-define(wxMouseEvent_IsPageScroll, 2728). +-define(wxMouseEvent_Leaving, 2729). +-define(wxMouseEvent_LeftDClick, 2730). +-define(wxMouseEvent_LeftDown, 2731). +-define(wxMouseEvent_LeftIsDown, 2732). +-define(wxMouseEvent_LeftUp, 2733). +-define(wxMouseEvent_MetaDown, 2734). +-define(wxMouseEvent_MiddleDClick, 2735). +-define(wxMouseEvent_MiddleDown, 2736). +-define(wxMouseEvent_MiddleIsDown, 2737). +-define(wxMouseEvent_MiddleUp, 2738). +-define(wxMouseEvent_Moving, 2739). +-define(wxMouseEvent_RightDClick, 2740). +-define(wxMouseEvent_RightDown, 2741). +-define(wxMouseEvent_RightIsDown, 2742). +-define(wxMouseEvent_RightUp, 2743). +-define(wxMouseEvent_ShiftDown, 2744). +-define(wxSetCursorEvent_GetCursor, 2745). +-define(wxSetCursorEvent_GetX, 2746). +-define(wxSetCursorEvent_GetY, 2747). +-define(wxSetCursorEvent_HasCursor, 2748). +-define(wxSetCursorEvent_SetCursor, 2749). +-define(wxKeyEvent_AltDown, 2750). +-define(wxKeyEvent_CmdDown, 2751). +-define(wxKeyEvent_ControlDown, 2752). +-define(wxKeyEvent_GetKeyCode, 2753). +-define(wxKeyEvent_GetModifiers, 2754). +-define(wxKeyEvent_GetPosition, 2757). +-define(wxKeyEvent_GetRawKeyCode, 2758). +-define(wxKeyEvent_GetRawKeyFlags, 2759). +-define(wxKeyEvent_GetUnicodeKey, 2760). +-define(wxKeyEvent_GetX, 2761). +-define(wxKeyEvent_GetY, 2762). +-define(wxKeyEvent_HasModifiers, 2763). +-define(wxKeyEvent_MetaDown, 2764). +-define(wxKeyEvent_ShiftDown, 2765). +-define(wxSizeEvent_GetSize, 2766). +-define(wxMoveEvent_GetPosition, 2767). +-define(wxEraseEvent_GetDC, 2768). +-define(wxFocusEvent_GetWindow, 2769). +-define(wxChildFocusEvent_GetWindow, 2770). +-define(wxMenuEvent_GetMenu, 2771). +-define(wxMenuEvent_GetMenuId, 2772). +-define(wxMenuEvent_IsPopup, 2773). +-define(wxCloseEvent_CanVeto, 2774). +-define(wxCloseEvent_GetLoggingOff, 2775). +-define(wxCloseEvent_SetCanVeto, 2776). +-define(wxCloseEvent_SetLoggingOff, 2777). +-define(wxCloseEvent_Veto, 2778). +-define(wxShowEvent_SetShow, 2779). +-define(wxShowEvent_GetShow, 2780). +-define(wxIconizeEvent_Iconized, 2781). +-define(wxJoystickEvent_ButtonDown, 2782). +-define(wxJoystickEvent_ButtonIsDown, 2783). +-define(wxJoystickEvent_ButtonUp, 2784). +-define(wxJoystickEvent_GetButtonChange, 2785). +-define(wxJoystickEvent_GetButtonState, 2786). +-define(wxJoystickEvent_GetJoystick, 2787). +-define(wxJoystickEvent_GetPosition, 2788). +-define(wxJoystickEvent_GetZPosition, 2789). +-define(wxJoystickEvent_IsButton, 2790). +-define(wxJoystickEvent_IsMove, 2791). +-define(wxJoystickEvent_IsZMove, 2792). +-define(wxUpdateUIEvent_CanUpdate, 2793). +-define(wxUpdateUIEvent_Check, 2794). +-define(wxUpdateUIEvent_Enable, 2795). +-define(wxUpdateUIEvent_Show, 2796). +-define(wxUpdateUIEvent_GetChecked, 2797). +-define(wxUpdateUIEvent_GetEnabled, 2798). +-define(wxUpdateUIEvent_GetShown, 2799). +-define(wxUpdateUIEvent_GetSetChecked, 2800). +-define(wxUpdateUIEvent_GetSetEnabled, 2801). +-define(wxUpdateUIEvent_GetSetShown, 2802). +-define(wxUpdateUIEvent_GetSetText, 2803). +-define(wxUpdateUIEvent_GetText, 2804). +-define(wxUpdateUIEvent_GetMode, 2805). +-define(wxUpdateUIEvent_GetUpdateInterval, 2806). +-define(wxUpdateUIEvent_ResetUpdateTime, 2807). +-define(wxUpdateUIEvent_SetMode, 2808). +-define(wxUpdateUIEvent_SetText, 2809). +-define(wxUpdateUIEvent_SetUpdateInterval, 2810). +-define(wxMouseCaptureChangedEvent_GetCapturedWindow, 2811). +-define(wxPaletteChangedEvent_SetChangedWindow, 2812). +-define(wxPaletteChangedEvent_GetChangedWindow, 2813). +-define(wxQueryNewPaletteEvent_SetPaletteRealized, 2814). +-define(wxQueryNewPaletteEvent_GetPaletteRealized, 2815). +-define(wxNavigationKeyEvent_GetDirection, 2816). +-define(wxNavigationKeyEvent_SetDirection, 2817). +-define(wxNavigationKeyEvent_IsWindowChange, 2818). +-define(wxNavigationKeyEvent_SetWindowChange, 2819). +-define(wxNavigationKeyEvent_IsFromTab, 2820). +-define(wxNavigationKeyEvent_SetFromTab, 2821). +-define(wxNavigationKeyEvent_GetCurrentFocus, 2822). +-define(wxNavigationKeyEvent_SetCurrentFocus, 2823). +-define(wxHelpEvent_GetOrigin, 2824). +-define(wxHelpEvent_GetPosition, 2825). +-define(wxHelpEvent_SetOrigin, 2826). +-define(wxHelpEvent_SetPosition, 2827). +-define(wxContextMenuEvent_GetPosition, 2828). +-define(wxContextMenuEvent_SetPosition, 2829). +-define(wxIdleEvent_CanSend, 2830). +-define(wxIdleEvent_GetMode, 2831). +-define(wxIdleEvent_RequestMore, 2832). +-define(wxIdleEvent_MoreRequested, 2833). +-define(wxIdleEvent_SetMode, 2834). +-define(wxGridEvent_AltDown, 2835). +-define(wxGridEvent_ControlDown, 2836). +-define(wxGridEvent_GetCol, 2837). +-define(wxGridEvent_GetPosition, 2838). +-define(wxGridEvent_GetRow, 2839). +-define(wxGridEvent_MetaDown, 2840). +-define(wxGridEvent_Selecting, 2841). +-define(wxGridEvent_ShiftDown, 2842). +-define(wxNotifyEvent_Allow, 2843). +-define(wxNotifyEvent_IsAllowed, 2844). +-define(wxNotifyEvent_Veto, 2845). +-define(wxSashEvent_GetEdge, 2846). +-define(wxSashEvent_GetDragRect, 2847). +-define(wxSashEvent_GetDragStatus, 2848). +-define(wxListEvent_GetCacheFrom, 2849). +-define(wxListEvent_GetCacheTo, 2850). +-define(wxListEvent_GetKeyCode, 2851). +-define(wxListEvent_GetIndex, 2852). +-define(wxListEvent_GetColumn, 2853). +-define(wxListEvent_GetPoint, 2854). +-define(wxListEvent_GetLabel, 2855). +-define(wxListEvent_GetText, 2856). +-define(wxListEvent_GetImage, 2857). +-define(wxListEvent_GetData, 2858). +-define(wxListEvent_GetMask, 2859). +-define(wxListEvent_GetItem, 2860). +-define(wxListEvent_IsEditCancelled, 2861). +-define(wxDateEvent_GetDate, 2862). +-define(wxCalendarEvent_GetWeekDay, 2863). +-define(wxFileDirPickerEvent_GetPath, 2864). +-define(wxColourPickerEvent_GetColour, 2865). +-define(wxFontPickerEvent_GetFont, 2866). +-define(wxStyledTextEvent_GetPosition, 2867). +-define(wxStyledTextEvent_GetKey, 2868). +-define(wxStyledTextEvent_GetModifiers, 2869). +-define(wxStyledTextEvent_GetModificationType, 2870). +-define(wxStyledTextEvent_GetText, 2871). +-define(wxStyledTextEvent_GetLength, 2872). +-define(wxStyledTextEvent_GetLinesAdded, 2873). +-define(wxStyledTextEvent_GetLine, 2874). +-define(wxStyledTextEvent_GetFoldLevelNow, 2875). +-define(wxStyledTextEvent_GetFoldLevelPrev, 2876). +-define(wxStyledTextEvent_GetMargin, 2877). +-define(wxStyledTextEvent_GetMessage, 2878). +-define(wxStyledTextEvent_GetWParam, 2879). +-define(wxStyledTextEvent_GetLParam, 2880). +-define(wxStyledTextEvent_GetListType, 2881). +-define(wxStyledTextEvent_GetX, 2882). +-define(wxStyledTextEvent_GetY, 2883). +-define(wxStyledTextEvent_GetDragText, 2884). +-define(wxStyledTextEvent_GetDragAllowMove, 2885). +-define(wxStyledTextEvent_GetDragResult, 2886). +-define(wxStyledTextEvent_GetShift, 2887). +-define(wxStyledTextEvent_GetControl, 2888). +-define(wxStyledTextEvent_GetAlt, 2889). +-define(utils_wxGetKeyState, 2890). +-define(utils_wxGetMousePosition, 2891). +-define(utils_wxGetMouseState, 2892). +-define(utils_wxSetDetectableAutoRepeat, 2893). +-define(utils_wxBell, 2894). +-define(utils_wxFindMenuItemId, 2895). +-define(utils_wxGenericFindWindowAtPoint, 2896). +-define(utils_wxFindWindowAtPoint, 2897). +-define(utils_wxBeginBusyCursor, 2898). +-define(utils_wxEndBusyCursor, 2899). +-define(utils_wxIsBusy, 2900). +-define(utils_wxShutdown, 2901). +-define(utils_wxShell, 2902). +-define(utils_wxLaunchDefaultBrowser, 2903). +-define(utils_wxGetEmailAddress, 2904). +-define(utils_wxGetUserId, 2905). +-define(utils_wxGetHomeDir, 2906). +-define(utils_wxNewId, 2907). +-define(utils_wxRegisterId, 2908). +-define(utils_wxGetCurrentId, 2909). +-define(utils_wxGetOsDescription, 2910). +-define(utils_wxIsPlatformLittleEndian, 2911). +-define(utils_wxIsPlatform64Bit, 2912). +-define(wxPrintout_new, 2913). +-define(wxPrintout_destruct, 2914). +-define(wxPrintout_GetDC, 2915). +-define(wxPrintout_GetPageSizeMM, 2916). +-define(wxPrintout_GetPageSizePixels, 2917). +-define(wxPrintout_GetPaperRectPixels, 2918). +-define(wxPrintout_GetPPIPrinter, 2919). +-define(wxPrintout_GetPPIScreen, 2920). +-define(wxPrintout_GetTitle, 2921). +-define(wxPrintout_IsPreview, 2922). +-define(wxPrintout_FitThisSizeToPaper, 2923). +-define(wxPrintout_FitThisSizeToPage, 2924). +-define(wxPrintout_FitThisSizeToPageMargins, 2925). +-define(wxPrintout_MapScreenSizeToPaper, 2926). +-define(wxPrintout_MapScreenSizeToPage, 2927). +-define(wxPrintout_MapScreenSizeToPageMargins, 2928). +-define(wxPrintout_MapScreenSizeToDevice, 2929). +-define(wxPrintout_GetLogicalPaperRect, 2930). +-define(wxPrintout_GetLogicalPageRect, 2931). +-define(wxPrintout_GetLogicalPageMarginsRect, 2932). +-define(wxPrintout_SetLogicalOrigin, 2933). +-define(wxPrintout_OffsetLogicalOrigin, 2934). +-define(wxStyledTextCtrl_new_2, 2935). +-define(wxStyledTextCtrl_new_0, 2936). +-define(wxStyledTextCtrl_destruct, 2937). +-define(wxStyledTextCtrl_Create, 2938). +-define(wxStyledTextCtrl_AddText, 2939). +-define(wxStyledTextCtrl_AddStyledText, 2940). +-define(wxStyledTextCtrl_InsertText, 2941). +-define(wxStyledTextCtrl_ClearAll, 2942). +-define(wxStyledTextCtrl_ClearDocumentStyle, 2943). +-define(wxStyledTextCtrl_GetLength, 2944). +-define(wxStyledTextCtrl_GetCharAt, 2945). +-define(wxStyledTextCtrl_GetCurrentPos, 2946). +-define(wxStyledTextCtrl_GetAnchor, 2947). +-define(wxStyledTextCtrl_GetStyleAt, 2948). +-define(wxStyledTextCtrl_Redo, 2949). +-define(wxStyledTextCtrl_SetUndoCollection, 2950). +-define(wxStyledTextCtrl_SelectAll, 2951). +-define(wxStyledTextCtrl_SetSavePoint, 2952). +-define(wxStyledTextCtrl_GetStyledText, 2953). +-define(wxStyledTextCtrl_CanRedo, 2954). +-define(wxStyledTextCtrl_MarkerLineFromHandle, 2955). +-define(wxStyledTextCtrl_MarkerDeleteHandle, 2956). +-define(wxStyledTextCtrl_GetUndoCollection, 2957). +-define(wxStyledTextCtrl_GetViewWhiteSpace, 2958). +-define(wxStyledTextCtrl_SetViewWhiteSpace, 2959). +-define(wxStyledTextCtrl_PositionFromPoint, 2960). +-define(wxStyledTextCtrl_PositionFromPointClose, 2961). +-define(wxStyledTextCtrl_GotoLine, 2962). +-define(wxStyledTextCtrl_GotoPos, 2963). +-define(wxStyledTextCtrl_SetAnchor, 2964). +-define(wxStyledTextCtrl_GetCurLine, 2965). +-define(wxStyledTextCtrl_GetEndStyled, 2966). +-define(wxStyledTextCtrl_ConvertEOLs, 2967). +-define(wxStyledTextCtrl_GetEOLMode, 2968). +-define(wxStyledTextCtrl_SetEOLMode, 2969). +-define(wxStyledTextCtrl_StartStyling, 2970). +-define(wxStyledTextCtrl_SetStyling, 2971). +-define(wxStyledTextCtrl_GetBufferedDraw, 2972). +-define(wxStyledTextCtrl_SetBufferedDraw, 2973). +-define(wxStyledTextCtrl_SetTabWidth, 2974). +-define(wxStyledTextCtrl_GetTabWidth, 2975). +-define(wxStyledTextCtrl_SetCodePage, 2976). +-define(wxStyledTextCtrl_MarkerDefine, 2977). +-define(wxStyledTextCtrl_MarkerSetForeground, 2978). +-define(wxStyledTextCtrl_MarkerSetBackground, 2979). +-define(wxStyledTextCtrl_MarkerAdd, 2980). +-define(wxStyledTextCtrl_MarkerDelete, 2981). +-define(wxStyledTextCtrl_MarkerDeleteAll, 2982). +-define(wxStyledTextCtrl_MarkerGet, 2983). +-define(wxStyledTextCtrl_MarkerNext, 2984). +-define(wxStyledTextCtrl_MarkerPrevious, 2985). +-define(wxStyledTextCtrl_MarkerDefineBitmap, 2986). +-define(wxStyledTextCtrl_MarkerAddSet, 2987). +-define(wxStyledTextCtrl_MarkerSetAlpha, 2988). +-define(wxStyledTextCtrl_SetMarginType, 2989). +-define(wxStyledTextCtrl_GetMarginType, 2990). +-define(wxStyledTextCtrl_SetMarginWidth, 2991). +-define(wxStyledTextCtrl_GetMarginWidth, 2992). +-define(wxStyledTextCtrl_SetMarginMask, 2993). +-define(wxStyledTextCtrl_GetMarginMask, 2994). +-define(wxStyledTextCtrl_SetMarginSensitive, 2995). +-define(wxStyledTextCtrl_GetMarginSensitive, 2996). +-define(wxStyledTextCtrl_StyleClearAll, 2997). +-define(wxStyledTextCtrl_StyleSetForeground, 2998). +-define(wxStyledTextCtrl_StyleSetBackground, 2999). +-define(wxStyledTextCtrl_StyleSetBold, 3000). +-define(wxStyledTextCtrl_StyleSetItalic, 3001). +-define(wxStyledTextCtrl_StyleSetSize, 3002). +-define(wxStyledTextCtrl_StyleSetFaceName, 3003). +-define(wxStyledTextCtrl_StyleSetEOLFilled, 3004). +-define(wxStyledTextCtrl_StyleResetDefault, 3005). +-define(wxStyledTextCtrl_StyleSetUnderline, 3006). +-define(wxStyledTextCtrl_StyleSetCase, 3007). +-define(wxStyledTextCtrl_StyleSetHotSpot, 3008). +-define(wxStyledTextCtrl_SetSelForeground, 3009). +-define(wxStyledTextCtrl_SetSelBackground, 3010). +-define(wxStyledTextCtrl_GetSelAlpha, 3011). +-define(wxStyledTextCtrl_SetSelAlpha, 3012). +-define(wxStyledTextCtrl_SetCaretForeground, 3013). +-define(wxStyledTextCtrl_CmdKeyAssign, 3014). +-define(wxStyledTextCtrl_CmdKeyClear, 3015). +-define(wxStyledTextCtrl_CmdKeyClearAll, 3016). +-define(wxStyledTextCtrl_SetStyleBytes, 3017). +-define(wxStyledTextCtrl_StyleSetVisible, 3018). +-define(wxStyledTextCtrl_GetCaretPeriod, 3019). +-define(wxStyledTextCtrl_SetCaretPeriod, 3020). +-define(wxStyledTextCtrl_SetWordChars, 3021). +-define(wxStyledTextCtrl_BeginUndoAction, 3022). +-define(wxStyledTextCtrl_EndUndoAction, 3023). +-define(wxStyledTextCtrl_IndicatorSetStyle, 3024). +-define(wxStyledTextCtrl_IndicatorGetStyle, 3025). +-define(wxStyledTextCtrl_IndicatorSetForeground, 3026). +-define(wxStyledTextCtrl_IndicatorGetForeground, 3027). +-define(wxStyledTextCtrl_SetWhitespaceForeground, 3028). +-define(wxStyledTextCtrl_SetWhitespaceBackground, 3029). +-define(wxStyledTextCtrl_GetStyleBits, 3030). +-define(wxStyledTextCtrl_SetLineState, 3031). +-define(wxStyledTextCtrl_GetLineState, 3032). +-define(wxStyledTextCtrl_GetMaxLineState, 3033). +-define(wxStyledTextCtrl_GetCaretLineVisible, 3034). +-define(wxStyledTextCtrl_SetCaretLineVisible, 3035). +-define(wxStyledTextCtrl_GetCaretLineBackground, 3036). +-define(wxStyledTextCtrl_SetCaretLineBackground, 3037). +-define(wxStyledTextCtrl_AutoCompShow, 3038). +-define(wxStyledTextCtrl_AutoCompCancel, 3039). +-define(wxStyledTextCtrl_AutoCompActive, 3040). +-define(wxStyledTextCtrl_AutoCompPosStart, 3041). +-define(wxStyledTextCtrl_AutoCompComplete, 3042). +-define(wxStyledTextCtrl_AutoCompStops, 3043). +-define(wxStyledTextCtrl_AutoCompSetSeparator, 3044). +-define(wxStyledTextCtrl_AutoCompGetSeparator, 3045). +-define(wxStyledTextCtrl_AutoCompSelect, 3046). +-define(wxStyledTextCtrl_AutoCompSetCancelAtStart, 3047). +-define(wxStyledTextCtrl_AutoCompGetCancelAtStart, 3048). +-define(wxStyledTextCtrl_AutoCompSetFillUps, 3049). +-define(wxStyledTextCtrl_AutoCompSetChooseSingle, 3050). +-define(wxStyledTextCtrl_AutoCompGetChooseSingle, 3051). +-define(wxStyledTextCtrl_AutoCompSetIgnoreCase, 3052). +-define(wxStyledTextCtrl_AutoCompGetIgnoreCase, 3053). +-define(wxStyledTextCtrl_UserListShow, 3054). +-define(wxStyledTextCtrl_AutoCompSetAutoHide, 3055). +-define(wxStyledTextCtrl_AutoCompGetAutoHide, 3056). +-define(wxStyledTextCtrl_AutoCompSetDropRestOfWord, 3057). +-define(wxStyledTextCtrl_AutoCompGetDropRestOfWord, 3058). +-define(wxStyledTextCtrl_RegisterImage, 3059). +-define(wxStyledTextCtrl_ClearRegisteredImages, 3060). +-define(wxStyledTextCtrl_AutoCompGetTypeSeparator, 3061). +-define(wxStyledTextCtrl_AutoCompSetTypeSeparator, 3062). +-define(wxStyledTextCtrl_AutoCompSetMaxWidth, 3063). +-define(wxStyledTextCtrl_AutoCompGetMaxWidth, 3064). +-define(wxStyledTextCtrl_AutoCompSetMaxHeight, 3065). +-define(wxStyledTextCtrl_AutoCompGetMaxHeight, 3066). +-define(wxStyledTextCtrl_SetIndent, 3067). +-define(wxStyledTextCtrl_GetIndent, 3068). +-define(wxStyledTextCtrl_SetUseTabs, 3069). +-define(wxStyledTextCtrl_GetUseTabs, 3070). +-define(wxStyledTextCtrl_SetLineIndentation, 3071). +-define(wxStyledTextCtrl_GetLineIndentation, 3072). +-define(wxStyledTextCtrl_GetLineIndentPosition, 3073). +-define(wxStyledTextCtrl_GetColumn, 3074). +-define(wxStyledTextCtrl_SetUseHorizontalScrollBar, 3075). +-define(wxStyledTextCtrl_GetUseHorizontalScrollBar, 3076). +-define(wxStyledTextCtrl_SetIndentationGuides, 3077). +-define(wxStyledTextCtrl_GetIndentationGuides, 3078). +-define(wxStyledTextCtrl_SetHighlightGuide, 3079). +-define(wxStyledTextCtrl_GetHighlightGuide, 3080). +-define(wxStyledTextCtrl_GetLineEndPosition, 3081). +-define(wxStyledTextCtrl_GetCodePage, 3082). +-define(wxStyledTextCtrl_GetCaretForeground, 3083). +-define(wxStyledTextCtrl_GetReadOnly, 3084). +-define(wxStyledTextCtrl_SetCurrentPos, 3085). +-define(wxStyledTextCtrl_SetSelectionStart, 3086). +-define(wxStyledTextCtrl_GetSelectionStart, 3087). +-define(wxStyledTextCtrl_SetSelectionEnd, 3088). +-define(wxStyledTextCtrl_GetSelectionEnd, 3089). +-define(wxStyledTextCtrl_SetPrintMagnification, 3090). +-define(wxStyledTextCtrl_GetPrintMagnification, 3091). +-define(wxStyledTextCtrl_SetPrintColourMode, 3092). +-define(wxStyledTextCtrl_GetPrintColourMode, 3093). +-define(wxStyledTextCtrl_FindText, 3094). +-define(wxStyledTextCtrl_FormatRange, 3095). +-define(wxStyledTextCtrl_GetFirstVisibleLine, 3096). +-define(wxStyledTextCtrl_GetLine, 3097). +-define(wxStyledTextCtrl_GetLineCount, 3098). +-define(wxStyledTextCtrl_SetMarginLeft, 3099). +-define(wxStyledTextCtrl_GetMarginLeft, 3100). +-define(wxStyledTextCtrl_SetMarginRight, 3101). +-define(wxStyledTextCtrl_GetMarginRight, 3102). +-define(wxStyledTextCtrl_GetModify, 3103). +-define(wxStyledTextCtrl_SetSelection, 3104). +-define(wxStyledTextCtrl_GetSelectedText, 3105). +-define(wxStyledTextCtrl_GetTextRange, 3106). +-define(wxStyledTextCtrl_HideSelection, 3107). +-define(wxStyledTextCtrl_LineFromPosition, 3108). +-define(wxStyledTextCtrl_PositionFromLine, 3109). +-define(wxStyledTextCtrl_LineScroll, 3110). +-define(wxStyledTextCtrl_EnsureCaretVisible, 3111). +-define(wxStyledTextCtrl_ReplaceSelection, 3112). +-define(wxStyledTextCtrl_SetReadOnly, 3113). +-define(wxStyledTextCtrl_CanPaste, 3114). +-define(wxStyledTextCtrl_CanUndo, 3115). +-define(wxStyledTextCtrl_EmptyUndoBuffer, 3116). +-define(wxStyledTextCtrl_Undo, 3117). +-define(wxStyledTextCtrl_Cut, 3118). +-define(wxStyledTextCtrl_Copy, 3119). +-define(wxStyledTextCtrl_Paste, 3120). +-define(wxStyledTextCtrl_Clear, 3121). +-define(wxStyledTextCtrl_SetText, 3122). +-define(wxStyledTextCtrl_GetText, 3123). +-define(wxStyledTextCtrl_GetTextLength, 3124). +-define(wxStyledTextCtrl_GetOvertype, 3125). +-define(wxStyledTextCtrl_SetCaretWidth, 3126). +-define(wxStyledTextCtrl_GetCaretWidth, 3127). +-define(wxStyledTextCtrl_SetTargetStart, 3128). +-define(wxStyledTextCtrl_GetTargetStart, 3129). +-define(wxStyledTextCtrl_SetTargetEnd, 3130). +-define(wxStyledTextCtrl_GetTargetEnd, 3131). +-define(wxStyledTextCtrl_ReplaceTarget, 3132). +-define(wxStyledTextCtrl_SearchInTarget, 3133). +-define(wxStyledTextCtrl_SetSearchFlags, 3134). +-define(wxStyledTextCtrl_GetSearchFlags, 3135). +-define(wxStyledTextCtrl_CallTipShow, 3136). +-define(wxStyledTextCtrl_CallTipCancel, 3137). +-define(wxStyledTextCtrl_CallTipActive, 3138). +-define(wxStyledTextCtrl_CallTipPosAtStart, 3139). +-define(wxStyledTextCtrl_CallTipSetHighlight, 3140). +-define(wxStyledTextCtrl_CallTipSetBackground, 3141). +-define(wxStyledTextCtrl_CallTipSetForeground, 3142). +-define(wxStyledTextCtrl_CallTipSetForegroundHighlight, 3143). +-define(wxStyledTextCtrl_CallTipUseStyle, 3144). +-define(wxStyledTextCtrl_VisibleFromDocLine, 3145). +-define(wxStyledTextCtrl_DocLineFromVisible, 3146). +-define(wxStyledTextCtrl_WrapCount, 3147). +-define(wxStyledTextCtrl_SetFoldLevel, 3148). +-define(wxStyledTextCtrl_GetFoldLevel, 3149). +-define(wxStyledTextCtrl_GetLastChild, 3150). +-define(wxStyledTextCtrl_GetFoldParent, 3151). +-define(wxStyledTextCtrl_ShowLines, 3152). +-define(wxStyledTextCtrl_HideLines, 3153). +-define(wxStyledTextCtrl_GetLineVisible, 3154). +-define(wxStyledTextCtrl_SetFoldExpanded, 3155). +-define(wxStyledTextCtrl_GetFoldExpanded, 3156). +-define(wxStyledTextCtrl_ToggleFold, 3157). +-define(wxStyledTextCtrl_EnsureVisible, 3158). +-define(wxStyledTextCtrl_SetFoldFlags, 3159). +-define(wxStyledTextCtrl_EnsureVisibleEnforcePolicy, 3160). +-define(wxStyledTextCtrl_SetTabIndents, 3161). +-define(wxStyledTextCtrl_GetTabIndents, 3162). +-define(wxStyledTextCtrl_SetBackSpaceUnIndents, 3163). +-define(wxStyledTextCtrl_GetBackSpaceUnIndents, 3164). +-define(wxStyledTextCtrl_SetMouseDwellTime, 3165). +-define(wxStyledTextCtrl_GetMouseDwellTime, 3166). +-define(wxStyledTextCtrl_WordStartPosition, 3167). +-define(wxStyledTextCtrl_WordEndPosition, 3168). +-define(wxStyledTextCtrl_SetWrapMode, 3169). +-define(wxStyledTextCtrl_GetWrapMode, 3170). +-define(wxStyledTextCtrl_SetWrapVisualFlags, 3171). +-define(wxStyledTextCtrl_GetWrapVisualFlags, 3172). +-define(wxStyledTextCtrl_SetWrapVisualFlagsLocation, 3173). +-define(wxStyledTextCtrl_GetWrapVisualFlagsLocation, 3174). +-define(wxStyledTextCtrl_SetWrapStartIndent, 3175). +-define(wxStyledTextCtrl_GetWrapStartIndent, 3176). +-define(wxStyledTextCtrl_SetLayoutCache, 3177). +-define(wxStyledTextCtrl_GetLayoutCache, 3178). +-define(wxStyledTextCtrl_SetScrollWidth, 3179). +-define(wxStyledTextCtrl_GetScrollWidth, 3180). +-define(wxStyledTextCtrl_TextWidth, 3181). +-define(wxStyledTextCtrl_GetEndAtLastLine, 3182). +-define(wxStyledTextCtrl_TextHeight, 3183). +-define(wxStyledTextCtrl_SetUseVerticalScrollBar, 3184). +-define(wxStyledTextCtrl_GetUseVerticalScrollBar, 3185). +-define(wxStyledTextCtrl_AppendText, 3186). +-define(wxStyledTextCtrl_GetTwoPhaseDraw, 3187). +-define(wxStyledTextCtrl_SetTwoPhaseDraw, 3188). +-define(wxStyledTextCtrl_TargetFromSelection, 3189). +-define(wxStyledTextCtrl_LinesJoin, 3190). +-define(wxStyledTextCtrl_LinesSplit, 3191). +-define(wxStyledTextCtrl_SetFoldMarginColour, 3192). +-define(wxStyledTextCtrl_SetFoldMarginHiColour, 3193). +-define(wxStyledTextCtrl_LineDown, 3194). +-define(wxStyledTextCtrl_LineDownExtend, 3195). +-define(wxStyledTextCtrl_LineUp, 3196). +-define(wxStyledTextCtrl_LineUpExtend, 3197). +-define(wxStyledTextCtrl_CharLeft, 3198). +-define(wxStyledTextCtrl_CharLeftExtend, 3199). +-define(wxStyledTextCtrl_CharRight, 3200). +-define(wxStyledTextCtrl_CharRightExtend, 3201). +-define(wxStyledTextCtrl_WordLeft, 3202). +-define(wxStyledTextCtrl_WordLeftExtend, 3203). +-define(wxStyledTextCtrl_WordRight, 3204). +-define(wxStyledTextCtrl_WordRightExtend, 3205). +-define(wxStyledTextCtrl_Home, 3206). +-define(wxStyledTextCtrl_HomeExtend, 3207). +-define(wxStyledTextCtrl_LineEnd, 3208). +-define(wxStyledTextCtrl_LineEndExtend, 3209). +-define(wxStyledTextCtrl_DocumentStart, 3210). +-define(wxStyledTextCtrl_DocumentStartExtend, 3211). +-define(wxStyledTextCtrl_DocumentEnd, 3212). +-define(wxStyledTextCtrl_DocumentEndExtend, 3213). +-define(wxStyledTextCtrl_PageUp, 3214). +-define(wxStyledTextCtrl_PageUpExtend, 3215). +-define(wxStyledTextCtrl_PageDown, 3216). +-define(wxStyledTextCtrl_PageDownExtend, 3217). +-define(wxStyledTextCtrl_EditToggleOvertype, 3218). +-define(wxStyledTextCtrl_Cancel, 3219). +-define(wxStyledTextCtrl_DeleteBack, 3220). +-define(wxStyledTextCtrl_Tab, 3221). +-define(wxStyledTextCtrl_BackTab, 3222). +-define(wxStyledTextCtrl_NewLine, 3223). +-define(wxStyledTextCtrl_FormFeed, 3224). +-define(wxStyledTextCtrl_VCHome, 3225). +-define(wxStyledTextCtrl_VCHomeExtend, 3226). +-define(wxStyledTextCtrl_ZoomIn, 3227). +-define(wxStyledTextCtrl_ZoomOut, 3228). +-define(wxStyledTextCtrl_DelWordLeft, 3229). +-define(wxStyledTextCtrl_DelWordRight, 3230). +-define(wxStyledTextCtrl_LineCut, 3231). +-define(wxStyledTextCtrl_LineDelete, 3232). +-define(wxStyledTextCtrl_LineTranspose, 3233). +-define(wxStyledTextCtrl_LineDuplicate, 3234). +-define(wxStyledTextCtrl_LowerCase, 3235). +-define(wxStyledTextCtrl_UpperCase, 3236). +-define(wxStyledTextCtrl_LineScrollDown, 3237). +-define(wxStyledTextCtrl_LineScrollUp, 3238). +-define(wxStyledTextCtrl_DeleteBackNotLine, 3239). +-define(wxStyledTextCtrl_HomeDisplay, 3240). +-define(wxStyledTextCtrl_HomeDisplayExtend, 3241). +-define(wxStyledTextCtrl_LineEndDisplay, 3242). +-define(wxStyledTextCtrl_LineEndDisplayExtend, 3243). +-define(wxStyledTextCtrl_HomeWrapExtend, 3244). +-define(wxStyledTextCtrl_LineEndWrap, 3245). +-define(wxStyledTextCtrl_LineEndWrapExtend, 3246). +-define(wxStyledTextCtrl_VCHomeWrap, 3247). +-define(wxStyledTextCtrl_VCHomeWrapExtend, 3248). +-define(wxStyledTextCtrl_LineCopy, 3249). +-define(wxStyledTextCtrl_MoveCaretInsideView, 3250). +-define(wxStyledTextCtrl_LineLength, 3251). +-define(wxStyledTextCtrl_BraceHighlight, 3252). +-define(wxStyledTextCtrl_BraceBadLight, 3253). +-define(wxStyledTextCtrl_BraceMatch, 3254). +-define(wxStyledTextCtrl_GetViewEOL, 3255). +-define(wxStyledTextCtrl_SetViewEOL, 3256). +-define(wxStyledTextCtrl_SetModEventMask, 3257). +-define(wxStyledTextCtrl_GetEdgeColumn, 3258). +-define(wxStyledTextCtrl_SetEdgeColumn, 3259). +-define(wxStyledTextCtrl_GetEdgeMode, 3260). +-define(wxStyledTextCtrl_GetEdgeColour, 3261). +-define(wxStyledTextCtrl_SetEdgeColour, 3262). +-define(wxStyledTextCtrl_SearchAnchor, 3263). +-define(wxStyledTextCtrl_SearchNext, 3264). +-define(wxStyledTextCtrl_SearchPrev, 3265). +-define(wxStyledTextCtrl_LinesOnScreen, 3266). +-define(wxStyledTextCtrl_UsePopUp, 3267). +-define(wxStyledTextCtrl_SelectionIsRectangle, 3268). +-define(wxStyledTextCtrl_SetZoom, 3269). +-define(wxStyledTextCtrl_GetZoom, 3270). +-define(wxStyledTextCtrl_GetModEventMask, 3271). +-define(wxStyledTextCtrl_SetSTCFocus, 3272). +-define(wxStyledTextCtrl_GetSTCFocus, 3273). +-define(wxStyledTextCtrl_SetStatus, 3274). +-define(wxStyledTextCtrl_GetStatus, 3275). +-define(wxStyledTextCtrl_SetMouseDownCaptures, 3276). +-define(wxStyledTextCtrl_GetMouseDownCaptures, 3277). +-define(wxStyledTextCtrl_SetSTCCursor, 3278). +-define(wxStyledTextCtrl_GetSTCCursor, 3279). +-define(wxStyledTextCtrl_SetControlCharSymbol, 3280). +-define(wxStyledTextCtrl_GetControlCharSymbol, 3281). +-define(wxStyledTextCtrl_WordPartLeft, 3282). +-define(wxStyledTextCtrl_WordPartLeftExtend, 3283). +-define(wxStyledTextCtrl_WordPartRight, 3284). +-define(wxStyledTextCtrl_WordPartRightExtend, 3285). +-define(wxStyledTextCtrl_SetVisiblePolicy, 3286). +-define(wxStyledTextCtrl_DelLineLeft, 3287). +-define(wxStyledTextCtrl_DelLineRight, 3288). +-define(wxStyledTextCtrl_GetXOffset, 3289). +-define(wxStyledTextCtrl_ChooseCaretX, 3290). +-define(wxStyledTextCtrl_SetXCaretPolicy, 3291). +-define(wxStyledTextCtrl_SetYCaretPolicy, 3292). +-define(wxStyledTextCtrl_GetPrintWrapMode, 3293). +-define(wxStyledTextCtrl_SetHotspotActiveForeground, 3294). +-define(wxStyledTextCtrl_SetHotspotActiveBackground, 3295). +-define(wxStyledTextCtrl_SetHotspotActiveUnderline, 3296). +-define(wxStyledTextCtrl_SetHotspotSingleLine, 3297). +-define(wxStyledTextCtrl_ParaDownExtend, 3298). +-define(wxStyledTextCtrl_ParaUp, 3299). +-define(wxStyledTextCtrl_ParaUpExtend, 3300). +-define(wxStyledTextCtrl_PositionBefore, 3301). +-define(wxStyledTextCtrl_PositionAfter, 3302). +-define(wxStyledTextCtrl_CopyRange, 3303). +-define(wxStyledTextCtrl_CopyText, 3304). +-define(wxStyledTextCtrl_SetSelectionMode, 3305). +-define(wxStyledTextCtrl_GetSelectionMode, 3306). +-define(wxStyledTextCtrl_LineDownRectExtend, 3307). +-define(wxStyledTextCtrl_LineUpRectExtend, 3308). +-define(wxStyledTextCtrl_CharLeftRectExtend, 3309). +-define(wxStyledTextCtrl_CharRightRectExtend, 3310). +-define(wxStyledTextCtrl_HomeRectExtend, 3311). +-define(wxStyledTextCtrl_VCHomeRectExtend, 3312). +-define(wxStyledTextCtrl_LineEndRectExtend, 3313). +-define(wxStyledTextCtrl_PageUpRectExtend, 3314). +-define(wxStyledTextCtrl_PageDownRectExtend, 3315). +-define(wxStyledTextCtrl_StutteredPageUp, 3316). +-define(wxStyledTextCtrl_StutteredPageUpExtend, 3317). +-define(wxStyledTextCtrl_StutteredPageDown, 3318). +-define(wxStyledTextCtrl_StutteredPageDownExtend, 3319). +-define(wxStyledTextCtrl_WordLeftEnd, 3320). +-define(wxStyledTextCtrl_WordLeftEndExtend, 3321). +-define(wxStyledTextCtrl_WordRightEnd, 3322). +-define(wxStyledTextCtrl_WordRightEndExtend, 3323). +-define(wxStyledTextCtrl_SetWhitespaceChars, 3324). +-define(wxStyledTextCtrl_SetCharsDefault, 3325). +-define(wxStyledTextCtrl_AutoCompGetCurrent, 3326). +-define(wxStyledTextCtrl_Allocate, 3327). +-define(wxStyledTextCtrl_FindColumn, 3328). +-define(wxStyledTextCtrl_GetCaretSticky, 3329). +-define(wxStyledTextCtrl_SetCaretSticky, 3330). +-define(wxStyledTextCtrl_ToggleCaretSticky, 3331). +-define(wxStyledTextCtrl_SetPasteConvertEndings, 3332). +-define(wxStyledTextCtrl_GetPasteConvertEndings, 3333). +-define(wxStyledTextCtrl_SelectionDuplicate, 3334). +-define(wxStyledTextCtrl_SetCaretLineBackAlpha, 3335). +-define(wxStyledTextCtrl_GetCaretLineBackAlpha, 3336). +-define(wxStyledTextCtrl_StartRecord, 3337). +-define(wxStyledTextCtrl_StopRecord, 3338). +-define(wxStyledTextCtrl_SetLexer, 3339). +-define(wxStyledTextCtrl_GetLexer, 3340). +-define(wxStyledTextCtrl_Colourise, 3341). +-define(wxStyledTextCtrl_SetProperty, 3342). +-define(wxStyledTextCtrl_SetKeyWords, 3343). +-define(wxStyledTextCtrl_SetLexerLanguage, 3344). +-define(wxStyledTextCtrl_GetProperty, 3345). +-define(wxStyledTextCtrl_GetStyleBitsNeeded, 3346). +-define(wxStyledTextCtrl_GetCurrentLine, 3347). +-define(wxStyledTextCtrl_StyleSetSpec, 3348). +-define(wxStyledTextCtrl_StyleSetFont, 3349). +-define(wxStyledTextCtrl_StyleSetFontAttr, 3350). +-define(wxStyledTextCtrl_StyleSetCharacterSet, 3351). +-define(wxStyledTextCtrl_StyleSetFontEncoding, 3352). +-define(wxStyledTextCtrl_CmdKeyExecute, 3353). +-define(wxStyledTextCtrl_SetMargins, 3354). +-define(wxStyledTextCtrl_GetSelection, 3355). +-define(wxStyledTextCtrl_PointFromPosition, 3356). +-define(wxStyledTextCtrl_ScrollToLine, 3357). +-define(wxStyledTextCtrl_ScrollToColumn, 3358). +-define(wxStyledTextCtrl_SendMsg, 3359). +-define(wxStyledTextCtrl_SetVScrollBar, 3360). +-define(wxStyledTextCtrl_SetHScrollBar, 3361). +-define(wxStyledTextCtrl_GetLastKeydownProcessed, 3362). +-define(wxStyledTextCtrl_SetLastKeydownProcessed, 3363). +-define(wxStyledTextCtrl_SaveFile, 3364). +-define(wxStyledTextCtrl_LoadFile, 3365). +-define(wxStyledTextCtrl_DoDragOver, 3366). +-define(wxStyledTextCtrl_DoDropText, 3367). +-define(wxStyledTextCtrl_GetUseAntiAliasing, 3368). +-define(wxStyledTextCtrl_AddTextRaw, 3369). +-define(wxStyledTextCtrl_InsertTextRaw, 3370). +-define(wxStyledTextCtrl_GetCurLineRaw, 3371). +-define(wxStyledTextCtrl_GetLineRaw, 3372). +-define(wxStyledTextCtrl_GetSelectedTextRaw, 3373). +-define(wxStyledTextCtrl_GetTextRangeRaw, 3374). +-define(wxStyledTextCtrl_SetTextRaw, 3375). +-define(wxStyledTextCtrl_GetTextRaw, 3376). +-define(wxStyledTextCtrl_AppendTextRaw, 3377). +-define(wxArtProvider_GetBitmap, 3378). +-define(wxArtProvider_GetIcon, 3379). +-define(wxTreeEvent_GetKeyCode, 3380). +-define(wxTreeEvent_GetItem, 3381). +-define(wxTreeEvent_GetKeyEvent, 3382). +-define(wxTreeEvent_GetLabel, 3383). +-define(wxTreeEvent_GetOldItem, 3384). +-define(wxTreeEvent_GetPoint, 3385). +-define(wxTreeEvent_IsEditCancelled, 3386). +-define(wxTreeEvent_SetToolTip, 3387). +-define(wxNotebookEvent_GetOldSelection, 3388). +-define(wxNotebookEvent_GetSelection, 3389). +-define(wxNotebookEvent_SetOldSelection, 3390). +-define(wxNotebookEvent_SetSelection, 3391). +-define(wxFileDataObject_new, 3392). +-define(wxFileDataObject_AddFile, 3393). +-define(wxFileDataObject_GetFilenames, 3394). +-define(wxFileDataObject_destroy, 3395). +-define(wxTextDataObject_new, 3396). +-define(wxTextDataObject_GetTextLength, 3397). +-define(wxTextDataObject_GetText, 3398). +-define(wxTextDataObject_SetText, 3399). +-define(wxTextDataObject_destroy, 3400). +-define(wxBitmapDataObject_new_1_1, 3401). +-define(wxBitmapDataObject_new_1_0, 3402). +-define(wxBitmapDataObject_GetBitmap, 3403). +-define(wxBitmapDataObject_SetBitmap, 3404). +-define(wxBitmapDataObject_destroy, 3405). +-define(wxClipboard_new, 3407). +-define(wxClipboard_destruct, 3408). +-define(wxClipboard_AddData, 3409). +-define(wxClipboard_Clear, 3410). +-define(wxClipboard_Close, 3411). +-define(wxClipboard_Flush, 3412). +-define(wxClipboard_GetData, 3413). +-define(wxClipboard_IsOpened, 3414). +-define(wxClipboard_Open, 3415). +-define(wxClipboard_SetData, 3416). +-define(wxClipboard_UsePrimarySelection, 3418). +-define(wxClipboard_IsSupported, 3419). +-define(wxClipboard_Get, 3420). +-define(wxSpinEvent_GetPosition, 3421). +-define(wxSpinEvent_SetPosition, 3422). +-define(wxSplitterWindow_new_0, 3423). +-define(wxSplitterWindow_new_2, 3424). +-define(wxSplitterWindow_destruct, 3425). +-define(wxSplitterWindow_Create, 3426). +-define(wxSplitterWindow_GetMinimumPaneSize, 3427). +-define(wxSplitterWindow_GetSashGravity, 3428). +-define(wxSplitterWindow_GetSashPosition, 3429). +-define(wxSplitterWindow_GetSplitMode, 3430). +-define(wxSplitterWindow_GetWindow1, 3431). +-define(wxSplitterWindow_GetWindow2, 3432). +-define(wxSplitterWindow_Initialize, 3433). +-define(wxSplitterWindow_IsSplit, 3434). +-define(wxSplitterWindow_ReplaceWindow, 3435). +-define(wxSplitterWindow_SetSashGravity, 3436). +-define(wxSplitterWindow_SetSashPosition, 3437). +-define(wxSplitterWindow_SetSashSize, 3438). +-define(wxSplitterWindow_SetMinimumPaneSize, 3439). +-define(wxSplitterWindow_SetSplitMode, 3440). +-define(wxSplitterWindow_SplitHorizontally, 3441). +-define(wxSplitterWindow_SplitVertically, 3442). +-define(wxSplitterWindow_Unsplit, 3443). +-define(wxSplitterWindow_UpdateSize, 3444). +-define(wxSplitterEvent_GetSashPosition, 3445). +-define(wxSplitterEvent_GetX, 3446). +-define(wxSplitterEvent_GetY, 3447). +-define(wxSplitterEvent_GetWindowBeingRemoved, 3448). +-define(wxSplitterEvent_SetSashPosition, 3449). +-define(wxHtmlWindow_new_0, 3450). +-define(wxHtmlWindow_new_2, 3451). +-define(wxHtmlWindow_AppendToPage, 3452). +-define(wxHtmlWindow_GetOpenedAnchor, 3453). +-define(wxHtmlWindow_GetOpenedPage, 3454). +-define(wxHtmlWindow_GetOpenedPageTitle, 3455). +-define(wxHtmlWindow_GetRelatedFrame, 3456). +-define(wxHtmlWindow_HistoryBack, 3457). +-define(wxHtmlWindow_HistoryCanBack, 3458). +-define(wxHtmlWindow_HistoryCanForward, 3459). +-define(wxHtmlWindow_HistoryClear, 3460). +-define(wxHtmlWindow_HistoryForward, 3461). +-define(wxHtmlWindow_LoadFile, 3462). +-define(wxHtmlWindow_LoadPage, 3463). +-define(wxHtmlWindow_SelectAll, 3464). +-define(wxHtmlWindow_SelectionToText, 3465). +-define(wxHtmlWindow_SelectLine, 3466). +-define(wxHtmlWindow_SelectWord, 3467). +-define(wxHtmlWindow_SetBorders, 3468). +-define(wxHtmlWindow_SetFonts, 3469). +-define(wxHtmlWindow_SetPage, 3470). +-define(wxHtmlWindow_SetRelatedFrame, 3471). +-define(wxHtmlWindow_SetRelatedStatusBar, 3472). +-define(wxHtmlWindow_ToText, 3473). +-define(wxHtmlWindow_destroy, 3474). +-define(wxHtmlLinkEvent_GetLinkInfo, 3475). +-define(wxAuiNotebookEvent_SetSelection, 3476). +-define(wxAuiNotebookEvent_GetSelection, 3477). +-define(wxAuiNotebookEvent_SetOldSelection, 3478). +-define(wxAuiNotebookEvent_GetOldSelection, 3479). +-define(wxAuiNotebookEvent_SetDragSource, 3480). +-define(wxAuiNotebookEvent_GetDragSource, 3481). +-define(wxAuiManagerEvent_SetManager, 3482). +-define(wxAuiManagerEvent_GetManager, 3483). +-define(wxAuiManagerEvent_SetPane, 3484). +-define(wxAuiManagerEvent_GetPane, 3485). +-define(wxAuiManagerEvent_SetButton, 3486). +-define(wxAuiManagerEvent_GetButton, 3487). +-define(wxAuiManagerEvent_SetDC, 3488). +-define(wxAuiManagerEvent_GetDC, 3489). +-define(wxAuiManagerEvent_Veto, 3490). +-define(wxAuiManagerEvent_GetVeto, 3491). +-define(wxAuiManagerEvent_SetCanVeto, 3492). +-define(wxAuiManagerEvent_CanVeto, 3493). +-define(wxLogNull_new, 3494). +-define(wxLogNull_destroy, 3495). diff --git a/lib/wx/test/wx_xtra_SUITE.erl b/lib/wx/test/wx_xtra_SUITE.erl index 2ce1d18039..6f21c60d14 100644 --- a/lib/wx/test/wx_xtra_SUITE.erl +++ b/lib/wx/test/wx_xtra_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %%%------------------------------------------------------------------- %%% File : wx_basic_SUITE.erl @@ -51,7 +51,8 @@ all(suite) -> [ destroy_app, multiple_add_in_sizer, - app_dies + app_dies, + menu_item_debug ]. %% The test cases @@ -174,3 +175,57 @@ multiple_add_in_sizer(Config) -> wxWindow:show(Frame), wx_test_lib:wx_destroy(Frame, Config). +menu_item_debug(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo); +menu_item_debug(Config) -> + %% Debugging a menu entry problem + %% Run it with: lists:map(fun(_) -> [{0,{ok,_,_}}] = wxt:t() end, lists:seq(1,50)), ok. + Wx = wx:new(), + wx:debug(trace), + Frame = wxFrame:new(Wx, -1, "Button Fix"), + wxFrame:connect(Frame, close_window), + + FramePanel = wxPanel:new(Frame), + create_menus(Frame), + wxWindow:show(Frame), + wx_test_lib:wx_destroy(Frame,Config). + + +create_menus(Frame) -> + MenuBar = ?mt(wxMenuBar, wxMenuBar:new()), + File = ?mt(wxMenu, wxMenu:new([])), + Help = ?mt(wxMenu, wxMenu:new([])), + + ?mt(wxMenuItem, wxMenu:append(Help, ?wxID_ABOUT, "&About", [])), + ?mt(wxMenuItem, wxMenu:append(Help, ?wxID_HELP, "&Help", [])), + ?mt(wxMenuItem, wxMenu:append(File, ?wxID_EXIT, "Exit", [])), + T1 = ?mt(wxMenu, wxMenu:new([])), + [wxMenuItem:getId(wxMenu:append(T1, Id, integer_to_list(Id), [])) + || Id <- lists:seq(100, 120)], + T2 = ?mt(wxMenu, wxMenu:new([])), + [wxMenuItem:getId(wxMenu:append(T2, Id, integer_to_list(Id), [])) + || Id <- lists:seq(200, 220)], + T3 = ?mt(wxMenu, wxMenu:new([])), + [wxMenuItem:getId(wxMenu:append(T3, Id, integer_to_list(Id), [])) + || Id <- lists:seq(300, 320)], + T4 = ?mt(wxMenu, wxMenu:new([])), + [wxMenuItem:getId(wxMenu:append(T4, Id, integer_to_list(Id), [])) + || Id <- lists:seq(400, 420)], + T5 = ?mt(wxMenu, wxMenu:new([])), + [wxMenuItem:getId(wxMenu:append(T5, Id, integer_to_list(Id), [])) + || Id <- lists:seq(500, 520)], + T6 = ?mt(wxMenu, wxMenu:new([])), + [wxMenuItem:getId(wxMenu:append(T6, Id, integer_to_list(Id), [])) + || Id <- lists:seq(600, 620)], + + ?m(ok,wxFrame:connect(Frame, command_menu_selected)), + ?m(true, wxMenuBar:append(MenuBar, File, "&File")), + ?m(true, wxMenuBar:append(MenuBar, Help, "&Help")), + ?m(true, wxMenuBar:append(MenuBar, T1, "T1")), + ?m(true, wxMenuBar:append(MenuBar, T2, "T2")), + ?m(true, wxMenuBar:append(MenuBar, T3, "T3")), + ?m(true, wxMenuBar:append(MenuBar, T4, "T4")), + ?m(true, wxMenuBar:append(MenuBar, T5, "T5")), + ?m(true, wxMenuBar:append(MenuBar, T6, "T6")), + + + ?m(ok, wxFrame:setMenuBar(Frame,MenuBar)). diff --git a/make/otp.mk.in b/make/otp.mk.in index bcf9bd85a4..902def5fd8 100644 --- a/make/otp.mk.in +++ b/make/otp.mk.in @@ -3,20 +3,20 @@ # Make include file for otp # # %CopyrightBegin% -# -# Copyright Ericsson AB 1997-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1997-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # # Author: Lars Thorsen @@ -53,6 +53,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_DATA = @INSTALL_DATA@ CC = @CC@ +GCC = @GCC@ HCC = @HCC@ CC32 = @CC32@ CFLAGS32 = @CFLAGS32@ @@ -1,20 +1,20 @@ #! /bin/sh # # %CopyrightBegin% -# -# Copyright Ericsson AB 2002-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2002-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # @@ -26,7 +26,7 @@ clearmake=false # Global configuration variables # -# NOTE: lazy_configure depends on '.' allways being last directory +# NOTE: lazy_configure depends on '.' always being last directory if [ -z "$ONLY_ERTS" ]; then AUTOCONF_SUBDIRS="lib lib/*" fi @@ -42,7 +42,6 @@ usage () echo " configure [<configure parameters>] - does the actual configuration" echo " smp [-a] - build a small Erlang system, smp flavor" echo " hybrid [-a] - build a small Erlang system, hybrid flavor" - echo " nofrag [-a] - build a small Erlang system, nofrag flavor" echo " boot [-a] - bootstraps and build system (after configure)" echo " release <target_dir> - creates a small release to <target_dir>" echo " release [-a] <target_dir> - creates full release to <target_dir>" @@ -68,23 +67,39 @@ usage () echo "Before trying to cross compile, set environment via the following option" echo "Please note that the path to the configuration file should be absolute." echo " env_cross <absolute path to cross conf file> - echo environment settings for cross compilation, use with eval" - echo "" - echo "The following options concern the primary bootstrap." - echo "{prepare,update,commit,cancel}_primary is for actually updating" - echo "the checked in derivates of the main code base, they are not for" - echo "managing a downloaded spource-tree." - echo " prepare_primary - prepares for building primary bootstrap (only in Clearcase)" - echo " update_primary - creates the primary bootstrap, the one shipped" - echo " commit_primary - commits a primary bootstrap (only in Clearcase)" - echo " cancel_primary - uncheckout a primary bootstrap (only in Clearcase)" - echo "" - echo "The following options concern preloaded code." - echo "They are, like the primary bootstrap, mainly the concern of the" - echo "main developers." - echo " prepare_preloaded - prepares for building preloaded code (only in Clearcase)" - echo " update_preloaded - creates the preloaded beam code, the one shipped" - echo " commit_preloaded - commits the preloaded code (only in Clearcase)" - echo " cancel_preloaded - uncheckout preloaded code (only in Clearcase)" + case $version_controller in + none) + ;; + clearcase) + echo "" + echo "Handle the primary bootstrap in Clearcase:" + echo " prepare_primary - prepare for building a primary bootstrap" + echo " update_primary - create the primary bootstrap" + echo " commit_primary - commit a primary bootstrap" + echo " cancel_primary - uncheckout a primary bootstrap" + ;; + git) + echo "" + echo "update_primary - build and commit a new primary bootstrap" + ;; + esac + + case $version_controller in + none) + ;; + clearcase) + echo "" + echo "Handle the preloaded modules in Clearcase:" + echo " prepare_preloaded - prepares for building preloaded code" + echo " update_preloaded - creates the preloaded code" + echo " commit_preloaded - commits the preloaded code" + echo " cancel_preloaded - uncheckout preloaded code" + ;; + git) + echo "" + echo "update_preloaded - build and commit the preloaded modules" + ;; + esac } export_cross_env () @@ -189,7 +204,23 @@ target_contains () return $? } +determine_version_controller () +{ + version_controller=none + + # The current directory is now $ERL_TOP. Check for + # either this directory being controlled by git or + # for the "otp_build" file being a Clearcase controlled + # object. + if git rev-parse --git-dir 2>/dev/null >/dev/null; then + version_controller=git + else + if test -d "otp_build@@/"; then + version_controller=clearcase + fi + fi +} # Execution of the different options @@ -813,6 +844,23 @@ do_primary () fi } +do_primary_git () +{ + setup_make + if [ "x$OVERRIDE_TARGET" != "x" -a "x$OVERRIDE_TARGET" != "xwin32" ]; then + do_primary_cross + else + $MAKE MAKE="$MAKE" BOOTSTRAP_ROOT=$BOOTSTRAP_ROOT TARGET=$TARGET primary_bootstrap || exit 1; + fi + git add -A bootstrap/lib/kernel \ + bootstrap/lib/stdlib \ + bootstrap/lib/compiler \ + bootstrap/lib/orber/include \ + bootstrap/bin + git commit -m 'Update primary bootstrap' +} + + do_prepare () { CT=`lookup_prog_in_path cleartool` @@ -915,10 +963,6 @@ do_prepare_prel () do_update_prel () { CT=`lookup_prog_in_path cleartool` - if [ X"$CLEARCASE_ROOT" = X"" -o X"$CT" = X"" ]; then - echo "To prepare for update of preloaded code, you have to run in a Clearcase view" >&2 - return - fi if [ X"$ERL_TOP" = X"" ]; then echo "ERL_TOP is not set." >&2 @@ -934,6 +978,16 @@ do_update_prel () echo '*****************************************************' } +do_update_prel_git () +{ + setup_make + (cd $ERL_TOP/erts/preloaded/src && $MAKE MAKE="$MAKE" BOOTSTRAP_ROOT=$BOOTSTRAP_ROOT TARGET=$TARGET clean) + $MAKE MAKE="$MAKE" BOOTSTRAP_ROOT=$BOOTSTRAP_ROOT TARGET=$TARGET preloaded || exit 1 + (cd $ERL_TOP/erts/preloaded/src && $MAKE MAKE="$MAKE" BOOTSTRAP_ROOT=$BOOTSTRAP_ROOT TARGET=$TARGET copy) + git add -A $ERL_TOP/erts/preloaded/ebin/*.beam + git commit -m 'Update preloaded modules' +} + do_commit_prel () { CT=`lookup_prog_in_path cleartool` @@ -1144,6 +1198,8 @@ check_erltop cd $ERL_TOP +determine_version_controller + # Unset ERL_FLAGS and ERL_<Release>_FLAGS to prevent, for instance, # a value of "-hybrid" to run the hybrid emulator during bootstrap. sys_vsn=`awk '/SYSTEM_VSN = / {print $3}' < erts/vsn.mk` @@ -1252,7 +1308,7 @@ case "$1" in do_lazy_configure_target_clean;; opt) do_boot;; - plain|smp|hybrid|nofrag) + plain|smp|hybrid) if [ $minus_a_flag = false ]; then TYPE=opt fi; @@ -1264,7 +1320,11 @@ case "$1" in prepare_primary) do_prepare;; update_primary) - do_primary;; + case $version_controller in + git) do_primary_git ;; + clearcase) do_primary ;; + none) do_primary ;; + esac ;; commit_primary) do_commit;; cancel_primary) @@ -1272,7 +1332,11 @@ case "$1" in prepare_preloaded) do_prepare_prel;; update_preloaded) - do_update_prel;; + case $version_controller in + git) do_update_prel_git ;; + clearcase) do_update_prel ;; + none) do_update_prel ;; + esac ;; commit_preloaded) do_commit_prel;; cancel_preloaded) diff --git a/system/doc/reference_manual/modules.xml b/system/doc/reference_manual/modules.xml index f4885be480..0dbc0ab56b 100644 --- a/system/doc/reference_manual/modules.xml +++ b/system/doc/reference_manual/modules.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Modules</title> @@ -170,17 +170,21 @@ fact(0) -> % | <section> <title>Types and function specifications</title> - <p>The current release implements types and function specifications - as described in + <p>A similar syntax as for module attributes is used for + specifying types and function specifications. + </p> + <pre> +-type my_type() :: atom() | integer(). +-spec my_function(integer()) -> integer(). + </pre> + <p>Read more in <seealso marker="typespec">Types and Function specifications</seealso>. + </p> + <p> + The desciption is based on <url href="http://www.erlang.org/eeps/eep-0008.html">EEP8 - -Types and function specifications</url>. - - <note> - <p>The implementation and EEP8 may not exactly correspond to - each other. In a future release, type and function specifications - will be described in this reference manual.</p> - </note> - </p> + Types and function specifications</url> + which will not be further updated. + </p> </section> </section> diff --git a/system/doc/reference_manual/part.xml b/system/doc/reference_manual/part.xml index aebeaf335a..8151f4c4e1 100644 --- a/system/doc/reference_manual/part.xml +++ b/system/doc/reference_manual/part.xml @@ -4,7 +4,7 @@ <part xmlns:xi="http://www.w3.org/2001/XInclude"> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Erlang Reference Manual</title> @@ -32,6 +32,7 @@ <xi:include href="patterns.xml"/> <xi:include href="modules.xml"/> <xi:include href="functions.xml"/> + <xi:include href="typespec.xml"/> <xi:include href="expressions.xml"/> <xi:include href="macros.xml"/> <xi:include href="records.xml"/> diff --git a/system/doc/reference_manual/typespec.xml b/system/doc/reference_manual/typespec.xml new file mode 100755 index 0000000000..a3660713e4 --- /dev/null +++ b/system/doc/reference_manual/typespec.xml @@ -0,0 +1,464 @@ +<?xml version="1.0" encoding="latin1" ?> +<!DOCTYPE chapter SYSTEM "chapter.dtd"> + +<chapter> + <header> + <copyright> + <year>2003</year><year>2009</year> + <holder>Ericsson AB. All Rights Reserved.</holder> + </copyright> + <legalnotice> + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved online at http://www.erlang.org/. + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. + + </legalnotice> + + <title>Types and Function Specifications</title> + <prepared>Kostis Sagonas, Tobias Lindahl, Kenneth Lundin</prepared> + <docno></docno> + <date></date> + <rev></rev> + <file>typespec.xml</file> + </header> + + <section> + <title>Introduction of Types</title> + <p> + Although Erlang is a dynamically typed language this section describes + an extension to the Erlang language for declaring sets of Erlang terms + to form a particular type, effectively forming a specific sub-type of the + set of all Erlang terms. + </p> + <p> + Subsequently, these types can be used to specify types of record fields + and the argument and return types of functions. + </p> + <p> + Type information can be used to document function interfaces, + provide more information for bug detection tools such as <c>Dialyzer</c>, + and can be exploited by documentation tools such as <c>Edoc</c> for + generating program documentation of various forms. + It is expected that the type language described in this document will + supersede and replace the purely comment-based <c>@type</c> and + <c>@spec</c> declarations used by <c>Edoc</c>. + </p> + <warning> + The syntax and semantics described here is still preliminary and might be + slightly changed and extended before it becomes officially supported. + The plan is that this will happen in R14B. + </warning> + </section> + <section> + <marker id="syntax"></marker> + <title>Types and their Syntax</title> + <p> + Types describe sets of Erlang terms. + Types consist and are built from a set of predefined types (e.g. <c>integer()</c>, + <c>atom()</c>, <c>pid()</c>, ...) described below. + Predefined types represent a typically infinite set of Erlang terms which + belong to this type. + For example, the type <c>atom()</c> stands for the set of all Erlang atoms. + </p> + <p> + For integers and atoms, we allow for singleton types (e.g. the integers <c>-1</c> + and <c>42</c> or the atoms <c>'foo'</c> and <c>'bar'</c>). + + All other types are built using unions of either predefined types or singleton + types. In a type union between a type and one of its sub-types the sub-type is + absorbed by the super-type and the union is subsequently treated as if the + sub-type was not a constituent of the union. For example, the type union: + </p> + <pre> + atom() | 'bar' | integer() | 42</pre> + <p> + describes the same set of terms as the type union: + </p> + <pre> +atom() | integer()</pre> + <p> + Because of sub-type relations that exist between types, types form a lattice + where the topmost element, any(), denotes the set of all Erlang terms and + the bottom-most element, none(), denotes the empty set of terms. + </p> + <p> + The set of predefined types and the syntax for types is given below: + </p> + <pre><![CDATA[ +Type :: any() %% The top type, the set of all Erlang terms. + | none() %% The bottom type, contains no terms. + | pid() + | port() + | ref() + | [] %% nil + | Atom + | Binary + | float() + | Fun + | Integer + | List + | Tuple + | Union + | UserDefined %% described in Section 2 + +Union :: Type1 | Type2 + +Atom :: atom() + | Erlang_Atom %% 'foo', 'bar', ... + +Binary :: binary() %% <<_:_ * 8>> + | <<>> + | <<_:Erlang_Integer>> %% Base size + | <<_:_*Erlang_Integer>> %% Unit size + | <<_:Erlang_Integer, _:_*Erlang_Integer>> + +Fun :: fun() %% any function + | fun((...) -> Type) %% any arity, returning Type + | fun(() -> Type) + | fun((TList) -> Type) + +Integer :: integer() + | Erlang_Integer %% ..., -1, 0, 1, ... 42 ... + | Erlang_Integer..Erlang_Integer %% specifies an integer range + +List :: list(Type) %% Proper list ([]-terminated) + | improper_list(Type1, Type2) %% Type1=contents, Type2=termination + | maybe_improper_list(Type1, Type2) %% Type1 and Type2 as above + +Tuple :: tuple() %% stands for a tuple of any size + | {} + | {TList} + +TList :: Type + | Type, TList +]]></pre> + <p> + Because lists are commonly used, they have shorthand type notations. + The type <c>list(T)</c> has the shorthand <c>[T]</c>. The shorthand <c>[T,...]</c> stands for + the set of non-empty proper lists whose elements are of type <c>T</c>. + The only difference between the two shorthands is that <c>[T]</c> may be an + empty list but <c>[T,...]</c> may not. + </p> + <p> + Notice that the shorthand for <c>list()</c>, i.e. the list of elements of unknown type, + is <c>[_]</c> (or <c>[any()]</c>), not <c>[]</c>. + The notation <c>[]</c> specifies the singleton type for the empty list. + </p> + <p> + For convenience, the following types are also built-in. + They can be thought as predefined aliases for the type unions also shown in + the table. (Some type unions below slightly abuse the syntax of types.) + </p> + <table> + <row> + <cell><b>Built-in type</b></cell><cell><b>Stands for</b></cell> + </row> + <row> + <cell><c>term()</c></cell><cell><c>any()</c></cell> + </row> + <row> + <cell><c>bool()</c></cell><cell><c>'false' | 'true'</c></cell> + </row> + <row> + <cell><c>byte()</c></cell><cell><c>0..255</c></cell> + </row> + <row> + <cell><c>char()</c></cell><cell><c>0..16#10ffff</c></cell> + </row> + <row> + <cell><c>non_neg_integer()</c></cell><cell><c>0..</c></cell> + </row> + <row> + <cell><c>pos_integer()</c></cell><cell><c>1..</c></cell> + </row> + <row> + <cell><c>neg_integer()</c></cell><cell><c>..-1</c></cell> + </row> + <row> + <cell><c>number()</c></cell><cell><c>integer() | float()</c></cell> + </row> + <row> + <cell><c>list()</c></cell><cell><c>[any()]</c></cell> + </row> + <row> + <cell><c>maybe_improper_list()</c></cell><cell><c>maybe_improper_list(any(), any())</c></cell> + </row> + <row> + <cell><c>maybe_improper_list(T)</c></cell><cell><c>maybe_improper_list(T, any())</c></cell> + </row> + <row> + <cell><c>string()</c></cell><cell><c>[char()]</c></cell> + </row> + <row> + <cell><c>nonempty_string()</c></cell><cell><c>[char(),...]</c></cell> + </row> + <row> + <cell><c>iolist()</c></cell><cell><c>maybe_improper_list( +char() | binary() | iolist(), binary() | [])</c></cell> + </row> + <row> + <cell><c>module()</c></cell><cell><c>atom()</c></cell> + </row> + <row> + <cell><c>mfa()</c></cell><cell><c>{atom(),atom(),byte()}</c></cell> + </row> + <row> + <cell><c>node()</c></cell><cell><c>atom()</c></cell> + </row> + <row> + <cell><c>timeout()</c></cell><cell><c>'infinity' | non_neg_integer()</c></cell> + </row> + <row> + <cell><c>no_return()</c></cell><cell><c>none()</c></cell> + </row> + </table> + + <p> + Users are not allowed to define types with the same names as the predefined or + built-in ones. + This is checked by the compiler and its violation results in a compilation + error. + (For bootstrapping purposes, it can also result to just a warning if this + involves a built-in type which has just been introduced.) + </p> + <note> + The following built-in list types also exist, + but they are expected to be rarely used. Hence, they have long names: + </note> + <pre> +nonempty_maybe_improper_list(Type) :: nonempty_maybe_improper_list(Type, any()) +nonempty_maybe_improper_list() :: nonempty_maybe_improper_list(any()) + </pre> + <p> + where the following two types + define the set of Erlang terms one would expect: + </p> + <pre> +nonempty_improper_list(Type1, Type2) +nonempty_maybe_improper_list(Type1, Type2) + </pre> + <p> + Also for convenience, we allow for record notation to be used. + Records are just shorthands for the corresponding tuples. + </p> + <pre> +Record :: #Erlang_Atom{} + | #Erlang_Atom{Fields} + </pre> + <p> + Records have been extended to possibly contain type information. + This is described in the sub-section <seealso marker="#typeinrecords">"Type information in record declarations"</seealso> below. + </p> + </section> + + <section> + <title>Type declarations of user-defined types</title> + <p> + As seen, the basic syntax of a type is an atom followed by closed + parentheses. New types are declared using '-type' compiler attributes + as in the following: + </p> + <pre> +-type my_type() :: Type. + </pre> + <p> + where the type name is an atom (<c>'my_type'</c> in the above) followed by + parenthesis. Type is a type as defined in the previous section. + A current restriction is that Type can contain only predefined types + or user-defined types which have been previously defined. + This restriction is enforced by the compiler and results in a + compilation error. (A similar restriction currently exists for records). + </p> + <p> + This means that currently general recursive types cannot be defined. + Lifting this restriction is future work. + </p> + <p> + Type declarations can also be parameterized by including type variables + between the parentheses. The syntax of type variables is the same as + Erlang variables (starts with an upper case letter). + Naturally, these variables can - and should - appear on the RHS of the + definition. A concrete example appears below: + </p> + <pre> +-type orddict(Key, Val) :: [{Key, Val}]. + </pre> + + </section> + + <marker id="typeinrecords"/> + <section> + <title> + Type information in record declarations + </title> + <p> + The types of record fields can be specified in the declaration of the + record. The syntax for this is: + </p> + <pre> +-record(rec, {field1 :: Type1, field2, field3 :: Type3}). + </pre> + <p> + For fields without type annotations, their type defaults to any(). + I.e., the above is a shorthand for: + </p> + <pre> +-record(rec, {field1 :: Type1, field2 :: any(), field3 :: Type3}). + </pre> + <p> + In the presence of initial values for fields, + the type must be declared after the initialization as in the following: + </p> + <pre> +-record(rec, {field1 = [] :: Type1, field2, field3 = 42 :: Type3}). + </pre> + <p> + Naturally, the initial values for fields should be compatible + with (i.e. a member of) the corresponding types. + This is checked by the compiler and results in a compilation error + if a violation is detected. For fields without initial values, + the singleton type <c>'undefined'</c> is added to all declared types. + In other words, the following two record declarations have identical + effects: + </p> + <pre> +-record(rec, {f1 = 42 :: integer(), + f2 :: float(), + f3 :: 'a' | 'b'). + +-record(rec, {f1 = 42 :: integer(), + f2 :: 'undefined' | float(), + f3 :: 'undefined' | 'a' | 'b'). + </pre> + <p> + For this reason, it is recommended that records contain initializers, + whenever possible. + </p> + <p> + Any record, containing type information or not, once defined, + can be used as a type using the syntax: + </p> + <pre> +#rec{} + </pre> + <p> + In addition, the record fields can be further specified when using + a record type by adding type information about the field in the following + manner: + </p> + <pre> +#rec{some_field :: Type} + </pre> + <p> + Any unspecified fields are assumed to have the type in the original + record declaration. + </p> + </section> + + <section> + <title>Specifications (contracts) for functions</title> + <p> + A contract (or specification) for a function is given using the new + compiler attribute <c>'-spec'</c>. The basic format is as follows: + </p> + <pre> +-spec Module:Function(ArgType1, ..., ArgTypeN) -> ReturnType. + </pre> + <p> + The arity of the function has to match the number of arguments, + or else a compilation error occurs. + </p> + <p> + This form can also be used in header files (.hrl) to declare type + information for exported functions. + Then these header files can be included in files that (implicitly or + explicitly) import these functions. + </p> + <p> + For most uses within a given module, the following shorthand is allowed: + </p> + <pre> +-spec Function(ArgType1, ..., ArgTypeN) -> ReturnType. + </pre> + <p> + Also, for documentation purposes, argument names can be given: + </p> + <pre> +-spec Function(ArgName1 :: Type1, ..., ArgNameN :: TypeN) -> RT. + </pre> + <p> + A function specification can be overloaded. + That is, it can have several types, separated by a semicolon (<c>;</c>): + </p> + <pre> +-spec foo(T1, T2) -> T3 + ; (T4, T5) -> T6. + </pre> + <p> + A current restriction, which currently results in a warning + (OBS: not an error) by the compiler, is that the domains of the argument + types cannot be overlapping. + For example, the following specification results in a warning: + </p> + <pre> +-spec foo(pos_integer()) -> pos_integer() + ; (integer()) -> integer(). + </pre> + <p> + Type variables can be used in specifications to specify relations for + the input and output arguments of a function. + For example, the following specification defines the type of a + polymorphic identity function: + </p> + <pre> +-spec id(X) -> X. + </pre> + <p> + However, note that the above specification does not restrict the input + and output type in any way. + We can constrain these types by guard-like subtype constraints: + </p> + <pre> +-spec id(X) -> X when is_subtype(X, tuple()). + </pre> + <p> + and provide bounded quantification. Currently, + the <c>is_subtype/2</c> guard is the only guard which can + be used in a <c>'-spec'</c> attribute. + </p> + <p> + The scope of an <c>is_subtype/2</c> constraint is the + <c>(...) -> RetType</c> + specification after which it appears. To avoid confusion, + we suggest that different variables are used in different constituents of + an overloaded contract as in the example below: + </p> + <pre> +-spec foo({X, integer()}) -> X when is_subtype(X, atom()) + ; ([Y]) -> Y when is_subtype(Y, number()). + </pre> + <p> + Some functions in Erlang are not meant to return; + either because they define servers or because they are used to + throw exceptions as the function below: + </p> + <pre> +my_error(Err) -> erlang:throw({error, Err}). + </pre> + <p> + For such functions we recommend the use of the special no_return() + type for their "return", via a contract of the form: + </p> + <pre> +-spec my_error(term()) -> no_return(). + </pre> + </section> +</chapter> + |