diff options
26 files changed, 1260 insertions, 278 deletions
diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c index df4d1a5715..ef471a473a 100644 --- a/erts/epmd/src/epmd_srv.c +++ b/erts/epmd/src/epmd_srv.c @@ -39,8 +39,10 @@ * server keeps the socket open where the request for registration was * made. * - * The protocol is briefly documented in "erl_ext_dist.txt". All requests - * to this server are done with a packet + * The protocol is briefly documented in the ERTS User's Guide, see + * http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html + * + * All requests to this server are done with a packet * * 2 n * +--------+---------+ diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in index 96655662b8..e866511153 100644 --- a/erts/etc/common/Makefile.in +++ b/erts/etc/common/Makefile.in @@ -327,31 +327,31 @@ $(OBJDIR)/$(ERLEXEC).o: $(ERLEXECDIR)/$(ERLEXEC).c $(CC) -I$(EMUDIR) $(CFLAGS) -o $@ -c $(ERLEXECDIR)/$(ERLEXEC).c endif $(BINDIR)/erlc@EXEEXT@: $(OBJDIR)/erlc.o - $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/erlc.o -L$(OBJDIR) $(LIBS) + $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/erlc.o -L$(OBJDIR) $(LIBS) $(ERTS_INTERNAL_LIBS) $(OBJDIR)/erlc.o: erlc.c $(CC) $(CFLAGS) -o $@ -c erlc.c $(BINDIR)/dialyzer@EXEEXT@: $(OBJDIR)/dialyzer.o - $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/dialyzer.o -L$(OBJDIR) $(LIBS) + $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/dialyzer.o -L$(OBJDIR) $(LIBS) $(ERTS_INTERNAL_LIBS) $(OBJDIR)/dialyzer.o: dialyzer.c $(CC) $(CFLAGS) -o $@ -c dialyzer.c $(BINDIR)/typer@EXEEXT@: $(OBJDIR)/typer.o - $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/typer.o -L$(OBJDIR) $(LIBS) + $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/typer.o -L$(OBJDIR) $(LIBS) $(ERTS_INTERNAL_LIBS) $(OBJDIR)/typer.o: typer.c $(CC) $(CFLAGS) -o $@ -c typer.c $(BINDIR)/escript@EXEEXT@: $(OBJDIR)/escript.o - $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/escript.o -L$(OBJDIR) $(LIBS) + $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/escript.o -L$(OBJDIR) $(LIBS) $(ERTS_INTERNAL_LIBS) $(OBJDIR)/escript.o: escript.c $(CC) $(CFLAGS) -o $@ -c escript.c $(BINDIR)/run_test@EXEEXT@: $(OBJDIR)/run_test.o - $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/run_test.o -L$(OBJDIR) $(LIBS) + $(PURIFY) $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/run_test.o -L$(OBJDIR) $(LIBS) $(ERTS_INTERNAL_LIBS) $(OBJDIR)/run_test.o: run_test.c $(CC) $(CFLAGS) -o $@ -c run_test.c diff --git a/erts/etc/common/dialyzer.c b/erts/etc/common/dialyzer.c index 4b4c1124f1..4453e63f1c 100644 --- a/erts/etc/common/dialyzer.c +++ b/erts/etc/common/dialyzer.c @@ -147,6 +147,9 @@ main(int argc, char** argv) env = get_env("DIALYZER_EMULATOR"); emulator = env ? env : get_default_emulator(argv[0]); + if (strlen(emulator) >= MAXPATHLEN) + error("Value of environment variable DIALYZER_EMULATOR is too large"); + /* * Allocate the argv vector to be used for arguments to Erlang. * Arrange for starting to pushing information in the middle of @@ -228,7 +231,7 @@ main(int argc, char** argv) static void push_words(char* src) { - char sbuf[1024]; + char sbuf[MAXPATHLEN]; char* dst; dst = sbuf; @@ -360,7 +363,7 @@ error(char* format, ...) va_list ap; va_start(ap, format); - vsprintf(sbuf, format, ap); + erts_vsnprintf(sbuf, sizeof(sbuf), format, ap); va_end(ap); fprintf(stderr, "dialyzer: %s\n", sbuf); exit(1); @@ -389,6 +392,9 @@ get_default_emulator(char* progname) char sbuf[MAXPATHLEN]; char* s; + if (strlen(progname) >= sizeof(sbuf)) + return ERL_NAME; + strcpy(sbuf, progname); for (s = sbuf+strlen(sbuf); s >= sbuf; s--) { if (IS_DIRSEP(*s)) { diff --git a/erts/etc/common/erlc.c b/erts/etc/common/erlc.c index 09aca19e6c..cd137435d1 100644 --- a/erts/etc/common/erlc.c +++ b/erts/etc/common/erlc.c @@ -148,10 +148,6 @@ int main(int argc, char** argv) { char cwd[MAXPATHLEN]; /* Current working directory. */ - char** rpc_eargv; /* Pointer to the beginning of arguments - * if calling a running Erlang system - * via erl_rpc(). - */ int eargv_size; int eargc_base; /* How many arguments in the base of eargv. */ char* emulator; @@ -160,6 +156,9 @@ main(int argc, char** argv) env = get_env("ERLC_EMULATOR"); emulator = env ? env : get_default_emulator(argv[0]); + if (strlen(emulator) >= MAXPATHLEN) + error("Value of environment variable ERLC_EMULATOR is too large"); + /* * Allocate the argv vector to be used for arguments to Erlang. * Arrange for starting to pushing information in the middle of @@ -170,7 +169,7 @@ main(int argc, char** argv) * base of the eargv vector, and move it up later. */ - eargv_size = argc*4+100; + eargv_size = argc*6+100; eargv_base = (char **) emalloc(eargv_size*sizeof(char*)); eargv = eargv_base; eargc = 0; @@ -189,7 +188,6 @@ main(int argc, char** argv) PUSH2("-mode", "minimal"); PUSH2("-boot", "start_clean"); PUSH3("-s", "erl_compile", "compile_cmdline"); - rpc_eargv = eargv+eargc; /* * Push standard arguments to Erlang. @@ -419,7 +417,7 @@ process_opt(int* pArgc, char*** pArgv, int offset) static void push_words(char* src) { - char sbuf[1024]; + char sbuf[MAXPATHLEN]; char* dst; dst = sbuf; @@ -595,7 +593,7 @@ error(char* format, ...) va_list ap; va_start(ap, format); - vsprintf(sbuf, format, ap); + erts_vsnprintf(sbuf, sizeof(sbuf), format, ap); va_end(ap); fprintf(stderr, "erlc: %s\n", sbuf); exit(1); @@ -624,6 +622,9 @@ get_default_emulator(char* progname) char sbuf[MAXPATHLEN]; char* s; + if (strlen(progname) >= sizeof(sbuf)) + return ERL_NAME; + strcpy(sbuf, progname); for (s = sbuf+strlen(sbuf); s >= sbuf; s--) { if (IS_DIRSEP(*s)) { diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index c1fc2aebee..6ec2c8b52c 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -309,7 +309,7 @@ free_env_val(char *value) } /* - * Add the arcitecture suffix to the program name if needed, + * Add the architecture suffix to the program name if needed, * except on Windows, where we insert it just before ".DLL". */ static char* @@ -560,7 +560,7 @@ int main(int argc, char **argv) usage("+MYm"); } emu = add_extra_suffixes(emu, emu_type); - sprintf(tmpStr, "%s" DIRSEP "%s" BINARY_EXT, bindir, emu); + erts_snprintf(tmpStr, sizeof(tmpStr), "%s" DIRSEP "%s" BINARY_EXT, bindir, emu); emu = strsave(tmpStr); add_Eargs(emu); /* Will be argv[0] -- necessary! */ @@ -571,12 +571,12 @@ int main(int argc, char **argv) s = get_env("PATH"); if (!s) { - sprintf(tmpStr, "%s" PATHSEP "%s" DIRSEP "bin", bindir, rootdir); + erts_snprintf(tmpStr, sizeof(tmpStr), "%s" PATHSEP "%s" DIRSEP "bin", bindir, rootdir); } else if (strstr(s, bindir) == NULL) { - sprintf(tmpStr, "%s" PATHSEP "%s" DIRSEP "bin" PATHSEP "%s", bindir, + erts_snprintf(tmpStr, sizeof(tmpStr), "%s" PATHSEP "%s" DIRSEP "bin" PATHSEP "%s", bindir, rootdir, s); } else { - sprintf(tmpStr, "%s", s); + erts_snprintf(tmpStr, sizeof(tmpStr), "%s", s); } free_env_val(s); set_env("PATH", tmpStr); @@ -714,7 +714,7 @@ int main(int argc, char **argv) error("-man not supported on Windows"); #else argv[i] = "man"; - sprintf(tmpStr, "%s/man", rootdir); + erts_snprintf(tmpStr, sizeof(tmpStr), "%s/man", rootdir); set_env("MANPATH", tmpStr); execvp("man", argv+i); error("Could not execute the 'man' command."); @@ -1145,10 +1145,10 @@ start_epmd(char *epmd) if (!epmd) { epmd = epmd_cmd; #ifdef __WIN32__ - sprintf(epmd_cmd, "%s" DIRSEP "epmd", bindir); + erts_snprintf(epmd_cmd, sizeof(epmd_cmd), "%s" DIRSEP "epmd", bindir); arg1 = "-daemon"; #else - sprintf(epmd_cmd, "%s" DIRSEP "epmd -daemon", bindir); + erts_snprintf(epmd_cmd, sizeof(epmd_cmd), "%s" DIRSEP "epmd -daemon", bindir); #endif } #ifdef __WIN32__ @@ -1224,7 +1224,7 @@ void error(char* format, ...) va_list ap; va_start(ap, format); - vsprintf(sbuf, format, ap); + erts_vsnprintf(sbuf, sizeof(sbuf), format, ap); va_end(ap); fprintf(stderr, "erlexec: %s\n", sbuf); exit(1); @@ -1304,14 +1304,14 @@ static void get_start_erl_data(char *file) if (env) reldir = strsave(env); else { - sprintf(tmpbuffer, "%s/releases", rootdir); + erts_snprintf(tmpbuffer, sizeof(tmpbuffer), "%s/releases", rootdir); reldir = strsave(tmpbuffer); } free_env_val(env); if (file == NULL) - sprintf(start_erl_data, "%s/start_erl.data", reldir); + erts_snprintf(start_erl_data, sizeof(start_erl_data), "%s/start_erl.data", reldir); else - sprintf(start_erl_data, "%s", file); + erts_snprintf(start_erl_data, sizeof(start_erl_data), "%s", file); fp = _open(start_erl_data, _O_RDONLY ); if( fp == -1 ) error( "open failed on %s",start_erl_data ); @@ -1341,16 +1341,16 @@ static void get_start_erl_data(char *file) } bindir = emalloc(512); - sprintf(bindir,"%s/erts-%s/bin",rootdir,tmpbuffer); + erts_snprintf(bindir,512,"%s/erts-%s/bin",rootdir,tmpbuffer); /* BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin */ tprogname = progname; progname = emalloc(strlen(tprogname) + 20); - sprintf(progname,"%s -start_erl",tprogname); + erts_snprintf(progname,strlen(tprogname) + 20,"%s -start_erl",tprogname); boot_script = emalloc(512); config_script = emalloc(512); - sprintf(boot_script, "%s/%s/start", reldir, otpstring); - sprintf(config_script, "%s/%s/sys", reldir, otpstring); + erts_snprintf(boot_script, 512, "%s/%s/start", reldir, otpstring); + erts_snprintf(config_script, 512, "%s/%s/sys", reldir, otpstring); } @@ -1358,7 +1358,7 @@ static void get_start_erl_data(char *file) static char *replace_filename(char *path, char *new_base) { int plen = strlen(path); - char *res = malloc((plen+strlen(new_base)+1)*sizeof(char)); + char *res = emalloc((plen+strlen(new_base)+1)*sizeof(char)); char *p; strcpy(res,path); @@ -1373,7 +1373,7 @@ static char *path_massage(char *long_path) { char *p; - p = malloc(MAX_PATH+1); + p = emalloc(MAX_PATH+1); strcpy(p, long_path); GetShortPathName(p, p, MAX_PATH); return p; @@ -1509,7 +1509,8 @@ get_parameters(int argc, char** argv) /* Determine bindir from absolute path to executable */ char *p; char buffer[PATH_MAX]; - strcpy(buffer, argv[0]); + strncpy(buffer, argv[0], sizeof(buffer)); + buffer[sizeof(buffer)-1] = '\0'; for (p = buffer+strlen(buffer)-1 ; p >= buffer && *p != '/'; --p) ; @@ -1522,7 +1523,8 @@ get_parameters(int argc, char** argv) /* Determine rootdir from absolute path to bindir */ char *p; char buffer[PATH_MAX]; - strcpy(buffer, bindir); + strncpy(buffer, bindir, sizeof(buffer)); + buffer[sizeof(buffer)-1] = '\0'; for (p = buffer+strlen(buffer)-1; p >= buffer && *p != '/'; --p) ; diff --git a/erts/etc/common/escript.c b/erts/etc/common/escript.c index 1bc5eb7651..6ed79c91e3 100644 --- a/erts/etc/common/escript.c +++ b/erts/etc/common/escript.c @@ -151,6 +151,9 @@ find_prog(char *origpath) char relpath[PMAX]; char abspath[PMAX]; + if (strlen(origpath) >= sizeof(relpath)) + error("Path too long"); + strcpy(relpath, origpath); if (strstr(relpath, DIRSEPSTR) == NULL) { @@ -180,19 +183,21 @@ find_prog(char *origpath) end = strstr(beg, PATHSEPSTR); if (end != NULL) { sz = end - beg; - strncpy(dir, beg, sz); - dir[sz] = '\0'; } else { sz = strlen(beg); - strcpy(dir, beg); look_for_sep = FALSE; } + if (sz >= sizeof(dir)) { + beg = end + 1; + continue; + } + strncpy(dir, beg, sz); + dir[sz] = '\0'; beg = end + 1; #ifdef __WIN32__ - strcpy(wildcard, dir); - strcat(wildcard, DIRSEPSTR); - strcat(wildcard, relpath); /* basename */ + erts_snprintf(wildcard, sizeof(wildcard), "%s" DIRSEPSTR "%s", + dir, relpath /* basename */); dir_handle = FindFirstFile(wildcard, &find_data); if (dir_handle == INVALID_HANDLE_VALUE) { /* Try next directory in path */ @@ -217,9 +222,8 @@ find_prog(char *origpath) if (strcmp(origpath, dirp->d_name) == 0) { /* Wow we found the executable. */ - strcpy(relpath, dir); - strcat(relpath, DIRSEPSTR); - strcat(relpath, dirp->d_name); + erts_snprintf(relpath, sizeof(relpath), "%s" DIRSEPSTR "%s", + dir, dirp->d_name); closedir(dp); look_for_sep = FALSE; break; @@ -291,7 +295,7 @@ append_shebang_args(char* scriptname) /* Find end of arg */ end = beg; - while (end && end[0] != ' ') { + while (end && end < (linebuf+LINEBUFSZ-1) && end[0] != ' ') { if (end[0] == '\n') { newline = TRUE; end[0]= '\0'; @@ -335,13 +339,16 @@ main(int argc, char** argv) emulator = get_default_emulator(argv[0]); } + if (strlen(emulator) >= PMAX) + error("Value of environment variable ESCRIPT_EMULATOR is too large"); + /* * Allocate the argv vector to be used for arguments to Erlang. * Arrange for starting to pushing information in the middle of * the array, to allow easy addition of commands in the beginning. */ - eargv_size = argc*4+1000; + eargv_size = argc*4+1000+LINEBUFSZ/2; eargv_base = (char **) emalloc(eargv_size*sizeof(char*)); eargv = eargv_base; eargc = 0; @@ -387,7 +394,8 @@ main(int argc, char** argv) if (argc <= 1) { error("Missing filename\n"); } - strcpy(scriptname, argv[1]); + strncpy(scriptname, argv[1], sizeof(scriptname)); + scriptname[sizeof(scriptname)-1] = '\0'; argc--; argv++; } else { @@ -395,16 +403,17 @@ main(int argc, char** argv) int len; #endif absname = find_prog(argv[0]); - strcpy(scriptname, absname); - efree(absname); #ifdef __WIN32__ - len = strlen(scriptname); - if (len >= 4 && _stricmp(scriptname+len-4, ".exe") == 0) { - scriptname[len-4] = '\0'; + len = strlen(absname); + if (len >= 4 && _stricmp(absname+len-4, ".exe") == 0) { + absname[len-4] = '\0'; } #endif - strcat(scriptname, ".escript"); + erts_snprintf(scriptname, sizeof(scriptname), "%s.escript", + absname); + efree(absname); + } /* @@ -455,7 +464,7 @@ main(int argc, char** argv) static void push_words(char* src) { - char sbuf[1024]; + char sbuf[PMAX]; char* dst; dst = sbuf; @@ -584,7 +593,7 @@ error(char* format, ...) va_list ap; va_start(ap, format); - vsprintf(sbuf, format, ap); + erts_vsnprintf(sbuf, sizeof(sbuf), format, ap); va_end(ap); fprintf(stderr, "escript: %s\n", sbuf); exit(1); @@ -619,6 +628,9 @@ get_default_emulator(char* progname) char sbuf[MAXPATHLEN]; char* s; + if (strlen(progname) >= sizeof(sbuf)) + return ERL_NAME; + strcpy(sbuf, progname); for (s = sbuf+strlen(sbuf); s >= sbuf; s--) { if (IS_DIRSEP(*s)) { diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c index 4f738947b7..3e19e5f386 100644 --- a/erts/etc/common/heart.c +++ b/erts/etc/common/heart.c @@ -375,7 +375,8 @@ main(int argc, char **argv) _setmode(erlin_fd,_O_BINARY); _setmode(erlout_fd,_O_BINARY); #endif - strcpy(program_name, argv[0]); + strncpy(program_name, argv[0], sizeof(program_name)); + program_name[sizeof(program_name)-1] = '\0'; notify_ack(erlout_fd); cmd[0] = '\0'; do_terminate(message_loop(erlin_fd,erlout_fd)); @@ -728,7 +729,11 @@ heart_cmd_reply(int fd, char *s) struct msg m; int len = strlen(s) + 1; /* Include \0 */ - /* FIXME if s >= MSG_BODY_SIZE error */ + /* if s >= MSG_BODY_SIZE, return a write + * failure immediately. + */ + if (len > sizeof(m.fill)) + return -1; m.op = HEART_CMD; m.len = htons(len + 2); /* Include Op */ diff --git a/erts/etc/common/run_test.c b/erts/etc/common/run_test.c index 016d9c6afd..042b8571ca 100644 --- a/erts/etc/common/run_test.c +++ b/erts/etc/common/run_test.c @@ -164,11 +164,13 @@ main(int argc, char** argv) erl_args = cnt; } else if (strcmp(argv[1], "-sname") == 0) { - strcpy(nodename, argv[2]); + strncpy(nodename, argv[2], sizeof(nodename)); + nodename[sizeof(nodename)-1] = '\0'; cnt++, argv++; } else if (strcmp(argv[1], "-name") == 0) { - strcpy(nodename, argv[2]); + strncpy(nodename, argv[2], sizeof(nodename)); + nodename[sizeof(nodename)-1] = '\0'; dist_mode = FULL_NAME; cnt++, argv++; } @@ -178,7 +180,8 @@ main(int argc, char** argv) ct_mode = VTS_MODE; } else if (strcmp(argv[1], "-browser") == 0) { - strcpy(browser, argv[2]); + strncpy(browser, argv[2], sizeof(browser)); + browser[sizeof(browser)-1] = '\0'; cnt++, argv++; } else if (strcmp(argv[1], "-shell") == 0) { @@ -189,7 +192,8 @@ main(int argc, char** argv) ct_mode = MASTER_MODE; } else if (strcmp(argv[1], "-ctname") == 0) { - strcpy(nodename, argv[2]); + strncpy(nodename, argv[2], sizeof(nodename)); + nodename[sizeof(nodename)-1] = '\0'; ct_mode = ERL_SHELL_MODE; cnt++, argv++; } @@ -273,7 +277,7 @@ main(int argc, char** argv) static void push_words(char* src) { - char sbuf[1024]; + char sbuf[MAXPATHLEN]; char* dst; dst = sbuf; @@ -405,7 +409,7 @@ error(char* format, ...) va_list ap; va_start(ap, format); - vsprintf(sbuf, format, ap); + erts_vsnprintf(sbuf, sizeof(sbuf), format, ap); va_end(ap); fprintf(stderr, "run_test: %s\n", sbuf); exit(1); @@ -434,6 +438,9 @@ get_default_emulator(char* progname) char sbuf[MAXPATHLEN]; char* s; + if (strlen(progname) >= sizeof(sbuf)) + return ERL_NAME; + strcpy(sbuf, progname); for (s = sbuf+strlen(sbuf); s >= sbuf; s--) { if (IS_DIRSEP(*s)) { diff --git a/erts/etc/common/typer.c b/erts/etc/common/typer.c index c2567cb8b4..de48daf002 100644 --- a/erts/etc/common/typer.c +++ b/erts/etc/common/typer.c @@ -175,7 +175,7 @@ main(int argc, char** argv) static void push_words(char* src) { - char sbuf[1024]; + char sbuf[MAXPATHLEN]; char* dst; dst = sbuf; @@ -307,7 +307,7 @@ error(char* format, ...) va_list ap; va_start(ap, format); - vsprintf(sbuf, format, ap); + erts_vsnprintf(sbuf, sizeof(sbuf), format, ap); va_end(ap); fprintf(stderr, "typer: %s\n", sbuf); exit(1); @@ -336,6 +336,9 @@ get_default_emulator(char* progname) char sbuf[MAXPATHLEN]; char* s; + if (strlen(progname) >= sizeof(sbuf)) + return ERL_NAME; + strcpy(sbuf, progname); for (s = sbuf+strlen(sbuf); s >= sbuf; s--) { if (IS_DIRSEP(*s)) { diff --git a/erts/test/erlc_SUITE.erl b/erts/test/erlc_SUITE.erl index 437f020f99..4797f78be2 100644 --- a/erts/test/erlc_SUITE.erl +++ b/erts/test/erlc_SUITE.erl @@ -21,13 +21,13 @@ %% Tests the erlc command by compiling various types of files. -export([all/1, compile_erl/1, compile_yecc/1, compile_script/1, - compile_mib/1, good_citizen/1, deep_cwd/1]). + compile_mib/1, good_citizen/1, deep_cwd/1, arg_overflow/1]). -include_lib("test_server/include/test_server.hrl"). all(suite) -> [compile_erl, compile_yecc, compile_script, compile_mib, - good_citizen, deep_cwd]. + good_citizen, deep_cwd, arg_overflow]. %% Copy from erlc_SUITE_data/include/erl_test.hrl. @@ -189,6 +189,18 @@ deep_cwd_1(PrivDir) -> ?line true = filelib:is_file("test.beam"), ok. +%% Test that a large number of command line switches does not +%% overflow the argument buffer +arg_overflow(Config) when is_list(Config) -> + ?line {SrcDir, _OutDir, Cmd} = get_cmd(Config), + ?line FileName = filename:join(SrcDir, "erl_test_ok.erl"), + ?line Args = lists:flatten([ ["-D", integer_to_list(N), "=1 "] || + N <- lists:seq(1,10000) ]), + ?line run(Config, Cmd, FileName, Args, + ["Warning: function foo/0 is unused\$", + "_OK_"]), + ok. + erlc() -> case os:find_executable("erlc") of false -> diff --git a/lib/common_test/doc/src/ct_slave.xml b/lib/common_test/doc/src/ct_slave.xml deleted file mode 100644 index ceebf51f1a..0000000000 --- a/lib/common_test/doc/src/ct_slave.xml +++ /dev/null @@ -1,139 +0,0 @@ -<?xml version="1.0" encoding="latin1" ?> -<!DOCTYPE erlref SYSTEM "erlref.dtd"> -<erlref> -<header> -<title>ct_slave</title> -<prepared></prepared> -<responsible></responsible> -<docno>1</docno> -<approved></approved> -<checked></checked> -<date></date> -<rev>A</rev> -<file>ct_slave.xml</file></header> -<module>ct_slave</module> -<modulesummary>Common Test Framework functions for starting and stopping nodes for -Large Scale Testing.</modulesummary> -<description> -<p>Common Test Framework functions for starting and stopping nodes for -Large Scale Testing.</p> - - <p>This module exports functions which are used by the Common Test Master - to start and stop "slave" nodes. It is the default callback module for the - <c>{init, node_start}</c> term of the Test Specification.</p></description> -<funcs> -<func> -<name>start(Node) -> Result</name> -<fsummary>Starts an Erlang node with name Node on the local host.</fsummary> -<type> -<v>Node = atom()</v><v>Result = {ok, NodeName} | {error, already_started, NodeName} | {error, started_not_connected, NodeName} | {error, boot_timeout, NodeName} | {error, init_timeout, NodeName} | {error, startup_timeout, NodeName} | {error, not_alive, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="start-1"/> - -<p>Starts an Erlang node with name <c>Node</c> on the local host.</p> -<p><em>See also:</em> <seealso marker="#start-3">start/3</seealso>.</p> -</desc></func> -<func> -<name>start(Host, Node) -> Result</name> -<fsummary>Starts an Erlang node with name Node on host - Host with the default options.</fsummary> -<type> -<v>Node = atom()</v><v>Host = atom()</v><v>Result = {ok, NodeName} | {error, already_started, NodeName} | {error, started_not_connected, NodeName} | {error, boot_timeout, NodeName} | {error, init_timeout, NodeName} | {error, startup_timeout, NodeName} | {error, not_alive, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="start-2"/> - -<p>Starts an Erlang node with name <c>Node</c> on host - <c>Host</c> with the default options.</p> -<p><em>See also:</em> <seealso marker="#start-3">start/3</seealso>.</p> -</desc></func> -<func> -<name>start(Host, Node, Options::Opts) -> Result</name> -<fsummary>Starts an Erlang node with name Node on host - Host as specified by the combination of options in - Opts.</fsummary> -<type> -<v>Node = atom()</v><v>Host = atom()</v><v>Opts = [OptTuples]</v><v>OptTuples = {username, Username} | {password, Password} | {boot_timeout, BootTimeout} | {init_timeout, InitTimeout} | {startup_timeout, StartupTimeout} | {startup_functions, StartupFunctions} | {monitor_master, Monitor} | {kill_if_fail, KillIfFail} | {erl_flags, ErlangFlags}</v><v>Username = string()</v><v>Password = string()</v><v>BootTimeout = integer()</v><v>InitTimeout = integer()</v><v>StartupTimeout = integer()</v><v>StartupFunctions = [StartupFunctionSpec]</v><v>StartupFunctionSpec = {Module, Function, Arguments}</v><v>Module = atom()</v><v>Function = atom()</v><v>Arguments = [term]</v><v>Monitor = bool()</v><v>KillIfFail = bool()</v><v>ErlangFlags = string()</v><v>Result = {ok, NodeName} | {error, already_started, NodeName} | {error, started_not_connected, NodeName} | {error, boot_timeout, NodeName} | {error, init_timeout, NodeName} | {error, startup_timeout, NodeName} | {error, not_alive, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="start-3"/> - -<p>Starts an Erlang node with name <c>Node</c> on host - <c>Host</c> as specified by the combination of options in - <c>Opts</c>.</p> - - <p>Options <c>Username</c> and <c>Password</c> will be used - to log in onto the remote host <c>Host</c>. - Username, if omitted, defaults to the current user name, - and password is empty by default.</p> - - <p>A list of functions specified in the <c>Startup</c> option will be - executed after startup of the node. Note that all used modules should be - present in the code path on the <c>Host</c>.</p> - - <p>The timeouts are applied as follows: - <list> - <item> - <c>BootTimeout</c> - time to start the Erlang node, in seconds. - Defaults to 3 seconds. If node does not become pingable within this time, - the result <c>{error, boot_timeout, NodeName}</c> is returned; - </item> - <item> - <c>InitTimeout</c> - time to wait for the node until it calls the - internal callback function informing master about successfull startup. - Defaults to one second. - In case of timed out message the result - <c>{error, init_timeout, NodeName}</c> is returned; - </item> - <item> - <c>StartupTimeout</c> - time to wait intil the node finishes to run - the <c>StartupFunctions</c>. Defaults to one second. - If this timeout occurs, the result - <c>{error, startup_timeout, NodeName}</c> is returned. - </item> - </list></p> - - <p>Option <c>monitor_master</c> specifies, if the slave node should be - stopped in case of master node stop. Defaults to false.</p> - - <p>Option <c>kill_if_fail</c> specifies, if the slave node should be - killed in case of a timeout during initialization or startup. - Defaults to true. Note that node also may be still alive it the boot - timeout occurred, but it will not be killed in this case.</p> - - <p>Option <c>erlang_flags</c> specifies, which flags will be added - to the parameters of the <c>erl</c> executable.</p> - - <p>Special return values are: - <list> - <item><c>{error, already_started, NodeName}</c> - if the node with - the given name is already started on a given host;</item> - <item><c>{error, started_not_connected, NodeName}</c> - if node is - started, but not connected to the master node.</item> - <item><c>{error, not_alive, NodeName}</c> - if node on which the - <c>ct_slave:start/3</c> is called, is not alive. Note that - <c>NodeName</c> is the name of current node in this case.</item> - </list></p> - -</desc></func> -<func> -<name>stop(Node) -> Result</name> -<fsummary>Stops the running Erlang node with name Node on - the localhost.</fsummary> -<type> -<v>Node = atom()</v><v>Result = {ok, NodeName} | {error, not_started, NodeName} | {error, not_connected, NodeName} | {error, stop_timeout, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="stop-1"/> - -<p>Stops the running Erlang node with name <c>Node</c> on - the localhost.</p> -</desc></func> -<func> -<name>stop(Host, Node) -> Result</name> -<fsummary>Stops the running Erlang node with name Node on - host Host.</fsummary> -<type> -<v>Host = atom()</v><v>Node = atom()</v><v>Result = {ok, NodeName} | {error, not_started, NodeName} | {error, not_connected, NodeName} | {error, stop_timeout, NodeName}</v><v>NodeName = atom()</v></type> -<desc><marker id="stop-2"/> - -<p>Stops the running Erlang node with name <c>Node</c> on - host <c>Host</c>.</p> -</desc></func></funcs> - -<authors> -<aname> </aname> -<email> </email></authors></erlref>
\ No newline at end of file diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index 8ae175f10d..1dbf83ee10 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -694,7 +694,7 @@ userdata(TestDir, Suite, Case) -> %%%----------------------------------------------------------------- -%%% @spec get_status() -> TestStatus | {error,Reason} +%%% @spec get_status() -> TestStatus | {error,Reason} | no_tests_running %%% TestStatus = [StatusElem] %%% StatusElem = {current,{Suite,TestCase}} | {successful,Successful} | %%% {failed,Failed} | {skipped,Skipped} | {total,Total} diff --git a/lib/cosFileTransfer/test/Makefile b/lib/cosFileTransfer/test/Makefile new file mode 100644 index 0000000000..60f72644bd --- /dev/null +++ b/lib/cosFileTransfer/test/Makefile @@ -0,0 +1,132 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2000-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 + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(COSFILETRANSFER_VSN) +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/cosFileTransfer_test + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +TEST_SPEC_FILE = cosFileTransfer.spec + + +IDL_FILES = + +IDLOUTDIR = idl_output + +MODULES = \ + fileTransfer_SUITE \ + +GEN_MODULES = \ + +GEN_HRL_FILES = \ + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = + +GEN_FILES = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +GEN_TARGET_FILES = $(GEN_MODULES:%=$(IDLOUTDIR)/%.$(EMULATOR)) + +SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) + +TARGET_FILES = \ + $(GEN_TARGET_FILES) \ + $(SUITE_TARGET_FILES) + + +# ---------------------------------------------------- +# PROGRAMS +# ---------------------------------------------------- +LOCAL_CLASSPATH = $(ERL_TOP)lib/cosFileTransfer/priv:$(ERL_TOP)lib/cosFileTransfer/test +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/cosFileTransfer/ebin \ + -pa $(ERL_TOP)/lib/cosFileTransfer/src \ + -pa $(ERL_TOP)/lib/cosFileTransfer/include \ + -pa $(ERL_TOP)/lib/cosProperty/ebin \ + -pa $(ERL_TOP)/lib/cosProperty/include \ + -pa $(ERL_TOP)/lib/orber/ebin \ + -pa $(ERL_TOP)/lib/ic/ebin + +ERL_COMPILE_FLAGS += \ + $(ERL_IDL_FLAGS) \ + -pa $(ERL_TOP)/lib/orber/include \ + -pa $(ERL_TOP)/lib/cosProperty/include \ + -pa $(ERL_TOP)/internal_tools/test_server/ebin \ + -pa $(ERL_TOP)/lib/cosFileTransfer/ebin \ + -pa $(ERL_TOP)/lib/cosFileTransfer/include \ + -pa $(ERL_TOP)/lib/cosFileTransfer/test/idl_output \ + -I$(ERL_TOP)/lib/orber/include \ + -I$(ERL_TOP)/lib/cosProperty/include \ + -I$(ERL_TOP)/lib/cosFileTransfer/src \ + -I$(ERL_TOP)/lib/cosFileTransfer/include \ + -I$(ERL_TOP)/lib/cosFileTransfer \ + -I$(ERL_TOP)/lib/cosFileTransfer/test/$(IDLOUTDIR) \ + -I$(ERL_TOP)/lib/test_server/include + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- + + +tests debug opt: $(TARGET_FILES) + +clean: + rm -f idl_output/* + rm -f $(TARGET_FILES) + rm -f errs core *~ + +docs: + +# ---------------------------------------------------- +# Special Targets +# ---------------------------------------------------- + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +# We don't copy generated intermediate erlang and hrl files + +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: + +release_docs_spec: + +release_tests_spec: tests + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(IDL_FILES) $(TEST_SPEC_FILE) \ + $(ERL_FILES) $(RELSYSDIR) + $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR) + chmod -f -R u+w $(RELSYSDIR) diff --git a/lib/cosFileTransfer/test/cosFileTransfer.spec b/lib/cosFileTransfer/test/cosFileTransfer.spec new file mode 100644 index 0000000000..80fe919f2a --- /dev/null +++ b/lib/cosFileTransfer/test/cosFileTransfer.spec @@ -0,0 +1 @@ +{topcase, {dir, "../cosFileTransfer_test"}}. diff --git a/lib/cosFileTransfer/test/fileTransfer_SUITE.erl b/lib/cosFileTransfer/test/fileTransfer_SUITE.erl new file mode 100644 index 0000000000..f877e3ceda --- /dev/null +++ b/lib/cosFileTransfer/test/fileTransfer_SUITE.erl @@ -0,0 +1,954 @@ +%%----------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-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 : fileTransfer_SUITE.erl +%% Purpose : +%%---------------------------------------------------------------------- + +-module(fileTransfer_SUITE). + + + +%%--------------- INCLUDES ----------------------------------- +-include_lib("cosFileTransfer/src/cosFileTransferApp.hrl"). + +-include("test_server.hrl"). + +%%--------------- DEFINES ------------------------------------ +-define(default_timeout, ?t:minutes(20)). +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + exit(AcTuAlReS) + end + end()). + +-define(matchnopr(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT (~p) ------~n", [?LINE]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + exit(AcTuAlReS) + end + end()). + + + + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, + cases/0, + init_all/1, + finish_all/1, + fileIterator_api/1, + fts_ftp_file_api/1, + fts_ftp_file_ssl_api/1, + fts_ftp_dir_api/1, + fts_native_file_api/1, + fts_native_file_ssl_api/1, + fts_native_dir_api/1, + init_per_testcase/2, + fin_per_testcase/2, + install_data/2, + uninstall_data/1, + slave_sup/0, + app_test/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for the cosFileTransfer interfaces", ""]; +all(suite) -> {req, + [mnesia, orber], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [fts_ftp_dir_api, fts_ftp_file_api, fts_ftp_file_ssl_api, + fts_native_dir_api, fts_native_file_api, fts_native_file_ssl_api, + fileIterator_api, app_test]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +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. + +init_all(Config) -> + orber:jump_start(), + cosProperty:install(), + cosProperty:start(), + Dir = filename:join([code:lib_dir(ssl), "examples", "certs", "etc"]), + %% Client + cosFileTransferApp:configure(ssl_client_certfile, + filename:join([Dir, "client", "cert.pem"])), + cosFileTransferApp:configure(ssl_client_cacertfile, + filename:join([Dir, "client", "cacerts.pem"])), + cosFileTransferApp:configure(ssl_client_verify, 1), + cosFileTransferApp:configure(ssl_client_depth, 0), + %% Server + cosFileTransferApp:configure(ssl_server_certfile, + filename:join([Dir, "server", "cert.pem"])), + cosFileTransferApp:configure(ssl_server_cacertfile, + filename:join([Dir, "server", "cacerts.pem"])), + cosFileTransferApp:configure(ssl_server_verify, 1), + cosFileTransferApp:configure(ssl_server_depth, 0), + crypto:start(), + ssl:start(), + cosFileTransferApp:install(), + cosFileTransferApp:start(), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + ssl:stop(), + crypto:stop(), + cosFileTransferApp:stop(), + cosProperty:stop(), + cosProperty:uninstall(), + cosFileTransferApp:uninstall(), + orber:jump_stop(), + Config. + +%%----------------------------------------------------------------- +%% Local definitions +%%----------------------------------------------------------------- +-define(FTP_USER, "anonymous"). +-define(FTP_PASS, "fileTransfer_SUITE@localhost"). +-define(TEST_DIR,["/", "incoming"]). + + +-define(FTP_PORT, 21). +-define(FTP_ACC, "anonymous"). + +-define(BAD_HOST, "badhostname"). +-define(BAD_USER, "baduser"). +-define(BAD_DIR, "baddirectory"). + +-define(TEST_FILE_DATA, "If this file exists after a completed test an error occurred."). +-define(TEST_FILE_DATA2, "1234567890123"). + + +%%----------------------------------------------------------------- +%% aoo-file test +%%----------------------------------------------------------------- +app_test(doc) -> []; +app_test(suite) -> []; +app_test(_Config) -> + ?line ok=?t:app_test(cosFileTransfer), + ok. + +%%----------------------------------------------------------------- +%% FileIterator API tests +%%----------------------------------------------------------------- +fileIterator_api(doc) -> ["CosFileTransfer FileIterator API tests.", ""]; +fileIterator_api(suite) -> []; +fileIterator_api(Config) -> + case ftp_host(Config) of + {skipped, SkippedReason} -> + {skipped, SkippedReason}; + Host -> + + ?line {ok, Node} = create_node("fileIterator_api", 4008, normal), + ?line ?match(ok, remote_apply(Node, ?MODULE, install_data, + [tcp, {{'NATIVE', + 'cosFileTransferNATIVE_file'}, Host, + "fileIterator_api"}])), + + %% Create a Virtual File System. +%% ?line VFS = ?match({_,_,_,_,_,_}, +%% cosFileTransferApp:create_VFS({'NATIVE', +%% 'cosFileTransferNATIVE_file'}, +%% [], Host, ?FTP_PORT)), + ?line VFS = ?matchnopr({'IOP_IOR',"IDL:omg.org/CosFileTransfer/VirtualFileSystem:1.0",_}, + corba:string_to_object("corbaname::1.2@localhost:4008/NameService#fileIterator_api")), + + %% Start two File Transfer Sessions (Source and Target). + ?line {FS, Dir} = ?matchnopr({{_,_,_},{_,_,_}}, + 'CosFileTransfer_VirtualFileSystem':login(VFS, + ?FTP_USER, + ?FTP_PASS, + ?FTP_ACC)), + + %% Do some basic test on one of the Directories attributes. + ?line ?match([_H|_], 'CosFileTransfer_Directory':'_get_name'(Dir)), + ?line ?match([_H|_], 'CosFileTransfer_Directory':'_get_complete_file_name'(Dir)), + ?line ?match({'IOP_IOR',[],[]}, 'CosFileTransfer_Directory':'_get_parent'(Dir)), + ?line ?matchnopr(FS, 'CosFileTransfer_Directory':'_get_associated_session'(Dir)), + {ok,[],FileIter} = ?match({ok,[],_}, 'CosFileTransfer_Directory':list(Dir, 0)), + %% Usually the working directory for the test is not empty so no need for + %% creating files of our own?! + #any{value=Children} = ?match({any, _, _}, + 'CosPropertyService_PropertySet': + get_property_value(Dir, "num_children")), + + if + Children > 5 -> + ?line ?matchnopr({true, _}, 'CosFileTransfer_FileIterator':next_one(FileIter)), + ?line ?matchnopr({true, _}, 'CosFileTransfer_FileIterator':next_n(FileIter, 3)), + ?line ?matchnopr({true, _}, 'CosFileTransfer_FileIterator':next_n(FileIter, + Children)), + ?line ?matchnopr({false, _}, 'CosFileTransfer_FileIterator':next_one(FileIter)), + ?line ?match({false, []}, 'CosFileTransfer_FileIterator':next_n(FileIter, 1)), + ok; + true -> + ok + end, + ?line ?match(ok, 'CosFileTransfer_FileIterator':destroy(FileIter)), + ?line ?match(false, corba_object:non_existent(FS)), + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':logout(FS)), + %% To make sure Orber can remove it from mnesia. + timer:sleep(1000), + ?line ?match(true, corba_object:non_existent(FS)), + ?line ?match(ok, remote_apply(Node, ?MODULE, uninstall_data, ["fileIterator_api"])), + stop_orber_remote(Node, normal), + ok + end. + + +%%----------------------------------------------------------------- +%% FileTransferSession API tests +%%----------------------------------------------------------------- +fts_ftp_file_api(doc) -> ["CosFileTransfer FTP FileTransferSession API tests.", ""]; +fts_ftp_file_api(suite) -> []; +fts_ftp_file_api(Config) -> + ?line {ok, Node} = create_node("ftp_file_api", 4004, normal), + file_helper(Config, 'FTP', ?TEST_DIR, Node, 4004, "ftp_file_api", tcp). + +fts_ftp_file_ssl_api(doc) -> ["CosFileTransfer FTP FileTransferSession API tests.", ""]; +fts_ftp_file_ssl_api(suite) -> []; +fts_ftp_file_ssl_api(Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + ?line {ok, Node} = create_node("ftp_file_api_ssl", {4005, 1}, ssl), + file_helper(Config, 'FTP', ?TEST_DIR, Node, 4005, "ftp_file_api_ssl", ssl) + end. + +fts_native_file_api(doc) -> ["CosFileTransfer NATIVE FileTransferSession API tests.", ""]; +fts_native_file_api(suite) -> []; +fts_native_file_api(Config) -> + ?line {ok, Node} = create_node("native_file_api", 4006, normal), + {ok, Pwd} = file:get_cwd(), + file_helper(Config,{'NATIVE', 'cosFileTransferNATIVE_file'},filename:split(Pwd), + Node, 4006, "native_file_api", tcp). + +fts_native_file_ssl_api(doc) -> ["CosFileTransfer NATIVE FileTransferSession API tests.", ""]; +fts_native_file_ssl_api(suite) -> []; +fts_native_file_ssl_api(Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + ?line {ok, Node} = create_node("native_file_ssl_api", {4007, 1}, ssl), + {ok, Pwd} = file:get_cwd(), + file_helper(Config,{'NATIVE', 'cosFileTransferNATIVE_file'},filename:split(Pwd), + Node, 4007, "native_file_ssl_api", ssl) + end. + + + +file_helper(Config, WhichType, TEST_DIR, Node, Port, Name, Type) -> + case ftp_host(Config) of + {skipped, SkippedReason} -> + {skipped, SkippedReason}; + Host -> + TEST_SOURCE = TEST_DIR ++ [create_name(remove_me_source)], + TEST_SOURCE2 = TEST_DIR ++ [create_name(remove_me_source)], + TEST_TARGET = TEST_DIR ++ [create_name(remove_me_target)], + + io:format("<<<<<< CosFileTransfer Testing Configuration >>>>>>~n",[]), + io:format("Source: ~p~nTarget: ~p~n", [TEST_SOURCE, TEST_TARGET]), + + ?line ?match(ok, remote_apply(Node, ?MODULE, install_data, + [Type, {WhichType, Host, Name}])), + + ?line VFST = ?match({'IOP_IOR',"IDL:omg.org/CosFileTransfer/VirtualFileSystem:1.0",_}, + corba:string_to_object("corbaname::1.2@localhost:"++integer_to_list(Port)++"/NameService#"++Name)), + + + %% Create a Virtual File System. + ?line VFS = ?match({_,_,_,_,_,_}, + cosFileTransferApp:create_VFS(WhichType, [], Host, ?FTP_PORT, + [{protocol, Type}])), + %% Start two File Transfer Sessions (Source and Target). + ?line {FST, _DirT} = ?match({{_,_,_},{_,_,_}}, + 'CosFileTransfer_VirtualFileSystem':login(VFST, + ?FTP_USER, + ?FTP_PASS, + ?FTP_ACC)), + ?line {FSS, DirS} = ?match({{_,_,_,_,_,_},{_,_,_,_,_,_}}, + 'CosFileTransfer_VirtualFileSystem':login(VFS, + ?FTP_USER, + ?FTP_PASS, + ?FTP_ACC)), + + %% Do some basic test on one of the Directories attributes. + ?line ?match([_H|_], 'CosFileTransfer_Directory':'_get_name'(DirS)), + ?line ?match([_H|_], 'CosFileTransfer_Directory':'_get_complete_file_name'(DirS)), + ?line ?match({'IOP_IOR',[],[]}, 'CosFileTransfer_Directory':'_get_parent'(DirS)), + ?line ?match(FSS, 'CosFileTransfer_Directory':'_get_associated_session'(DirS)), + + %% Get a FileList before we create any new Files + ?line #'CosFileTransfer_FileWrapper'{the_file = Dir} = + ?match({'CosFileTransfer_FileWrapper', _, ndirectory}, + 'CosFileTransfer_FileTransferSession':get_file(FSS, TEST_DIR)), + ?line {ok,FileList, Iter1} = ?match({ok,_,_}, 'CosFileTransfer_Directory':list(Dir, 10)), + ?line loop_files(FileList), + + case Iter1 of + {'IOP_IOR',[],[]} -> + ok; + _-> + ?line ?match(ok, 'CosFileTransfer_FileIterator':destroy(Iter1)) + end, + + #any{value=Count1} = ?match({any, _, _}, 'CosPropertyService_PropertySet': + get_property_value(Dir, "num_children")), + + %% Now we want to transfer a file from source to target. First, we'll create + %% a a file to work with. + ?line create_file_on_source_node(WhichType, Config, Host, + filename:join(TEST_SOURCE), TEST_DIR, + ?TEST_FILE_DATA), + ?line create_file_on_source_node(WhichType, Config, Host, + filename:join(TEST_SOURCE2), TEST_DIR, + ?TEST_FILE_DATA2), + + ?line #'CosFileTransfer_FileWrapper'{the_file = FileS} = + ?matchnopr({'CosFileTransfer_FileWrapper', _, nfile}, + 'CosFileTransfer_FileTransferSession':get_file(FSS, TEST_SOURCE)), + ?line #'CosFileTransfer_FileWrapper'{the_file = FileS2} = + ?matchnopr({'CosFileTransfer_FileWrapper', _, nfile}, + 'CosFileTransfer_FileTransferSession':get_file(FSS, TEST_SOURCE2)), + + #any{value=Count2} = ?match({any, _, _}, 'CosPropertyService_PropertySet': + get_property_value(Dir, "num_children")), + timer:sleep(2000), + ?match(true, (Count1+2 == Count2)), + + %% Create a target File + ?line FileT = ?matchnopr({_,_,_}, + 'CosFileTransfer_FileTransferSession':create_file(FST, TEST_TARGET)), + %% Try to delete the non-existing file. + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_FileTransferSession':delete(FST, FileT)), + + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':transfer(FSS, FileS, FileT)), + + %% Remove this test when ftp supports append. + case WhichType of + {'NATIVE', 'cosFileTransferNATIVE_file'} -> + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':append(FSS, FileS, FileT)), + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':insert(FSS, FileS2, FileT, 7)); + _-> + ok + end, + + %% Delete source and target files + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':delete(FSS, FileS)), + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':delete(FSS, FileS2)), + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':delete(FST, FileT)), + + %% Should be back where we started. + timer:sleep(2000), + #any{value=Count3} = ?match({any, _, _}, 'CosPropertyService_PropertySet': + get_property_value(Dir, "num_children")), + ?match(true, (Count1 == Count3)), + + + ?line ?match(false, corba_object:non_existent(FSS)), + ?line ?match(false, corba_object:non_existent(FST)), + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':logout(FSS)), + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':logout(FST)), + %% To make sure Orber can remove it from mnesia. + timer:sleep(2000), + ?line ?match(true, corba_object:non_existent(FSS)), + ?line ?match(true, corba_object:non_existent(FST)), + ?line ?match(ok, remote_apply(Node, ?MODULE, uninstall_data, [Name])), + stop_orber_remote(Node, normal), + ok + end. + +%%----------------------------------------------------------------- +%% FileTransferSession API tests +%%----------------------------------------------------------------- +fts_ftp_dir_api(doc) -> ["CosFileTransfer FTP FileTransferSession API tests.", ""]; +fts_ftp_dir_api(suite) -> []; +fts_ftp_dir_api(Config) -> + ?line {ok, Node} = create_node("ftp_dir_api", 4009, normal), + dir_helper(Config, 'FTP', ?TEST_DIR, Node, 4009, "ftp_dir_api"). + + +fts_native_dir_api(doc) -> ["CosFileTransfer NATIVE FileTransferSession API tests.", ""]; +fts_native_dir_api(suite) -> []; +fts_native_dir_api(Config) -> + ?line {ok, Node} = create_node("native_dir_api", 4010, normal), + {ok, Pwd} = file:get_cwd(), + dir_helper(Config, {'NATIVE', 'cosFileTransferNATIVE_file'}, + filename:split(Pwd), Node, 4010, "native_dir_api"). + +dir_helper(Config, WhichType, TEST_DIR, Node, Port, Name) -> + case ftp_host(Config) of + {skipped, SkippedReason} -> + {skipped, SkippedReason}; + Host -> + TEST_DIR_LEVEL1 = TEST_DIR ++ [create_name(remove_me_dir1)], + TEST_DIR_LEVEL2 = TEST_DIR_LEVEL1 ++ [create_name(remove_me_dir2)], + + io:format("<<<<<< CosFileTransfer Testing Configuration >>>>>>~n",[]), + io:format("Top Dir: ~p~nLevel2 Dir: ~p~n", [TEST_DIR_LEVEL1, TEST_DIR_LEVEL2]), + + ?line ?match(ok, remote_apply(Node, ?MODULE, install_data, + [tcp, {WhichType, Host, Name}])), + + ?line VFS = ?matchnopr({'IOP_IOR',"IDL:omg.org/CosFileTransfer/VirtualFileSystem:1.0",_}, + corba:string_to_object("corbaname::1.2@localhost:"++integer_to_list(Port)++"/NameService#"++Name)), + + %% Start two File Transfer Sessions (Source and Target). + ?line {FS, DirS} = ?matchnopr({{'IOP_IOR',_,_}, _}, + 'CosFileTransfer_VirtualFileSystem':login(VFS, + ?FTP_USER, + ?FTP_PASS, + ?FTP_ACC)), + + %% Do some basic test on one of the Directories attributes. + ?line ?match([_H|_], 'CosFileTransfer_Directory':'_get_name'(DirS)), + ?line ?match([_H|_], 'CosFileTransfer_Directory':'_get_complete_file_name'(DirS)), + ?line ?match({'IOP_IOR',[],[]}, 'CosFileTransfer_Directory':'_get_parent'(DirS)), + ?line ?matchnopr(FS, 'CosFileTransfer_Directory':'_get_associated_session'(DirS)), + + %% Create a Root Directory. Currently we only need to create one but + %% later on, when supporting other protocols than FTP it's not enough. + ?line Dir1 = 'CosFileTransfer_FileTransferSession':create_directory(FS, + TEST_DIR_LEVEL1), + io:format("<<<<<< CosFileTransfer Testing Properties >>>>>>~n",[]), + ?line ?match({ok, [tk_long, tk_boolean]}, + 'CosFileTransfer_Directory':get_allowed_property_types(Dir1)), + ?line ?match({ok, [_,_]}, + 'CosFileTransfer_Directory':get_allowed_properties(Dir1)), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_property_with_mode(Dir1, + "num_children", + #any{typecode=tk_long, value=0}, + fixed_readonly)), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_property_with_mode(Dir1, + "wrong", + #any{typecode=tk_long, value=0}, + fixed_readonly)), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_property_with_mode(Dir1, + "num_children", + #any{typecode=tk_short, value=0}, + fixed_readonly)), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_property_with_mode(Dir1, + "num_children", + #any{typecode=tk_long, value=0}, + fixed_normal)), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_properties_with_modes(Dir1, + [#'CosPropertyService_PropertyDef' + {property_name = "num_children", + property_value = #any{typecode=tk_long, value=0}, + property_mode = fixed_readonly}])), + ?line ?match(fixed_readonly, + 'CosFileTransfer_Directory':get_property_mode(Dir1, "num_children")), + ?line ?match({true, + [#'CosPropertyService_PropertyMode'{property_name = "num_children", + property_mode = fixed_readonly}]}, + 'CosFileTransfer_Directory':get_property_modes(Dir1, ["num_children"])), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':set_property_mode(Dir1, "num_children", fixed_readonly)), + + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory': + set_property_modes(Dir1, + [#'CosPropertyService_PropertyMode' + {property_name = "num_children", + property_mode = fixed_readonly}])), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory': + set_property_modes(Dir1, + [#'CosPropertyService_PropertyMode' + {property_name = "wrong", + property_mode = fixed_readonly}])), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory': + set_property_modes(Dir1, + [#'CosPropertyService_PropertyMode' + {property_name = "num_children", + property_mode = fixed_normal}])), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_property(Dir1, + "num_children", + #any{typecode=tk_long, value=0})), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_property(Dir1, + "wrong", + #any{typecode=tk_long, value=0})), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_property(Dir1, + "num_children", + #any{typecode=tk_short, value=0})), + + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':define_property(Dir1, + "num_children", + #any{typecode=tk_long, value=0})), + + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory': + define_properties(Dir1, + [#'CosPropertyService_Property' + {property_name = "num_children", + property_value = #any{typecode=tk_long, + value=0}}])), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory': + define_properties(Dir1, + [#'CosPropertyService_Property' + {property_name = "wrong", + property_value = #any{typecode=tk_long, + value=0}}])), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory': + define_properties(Dir1, + [#'CosPropertyService_Property' + {property_name = "num_children", + property_value = #any{typecode=tk_short, + value=0}}])), + ?line ?match(2, 'CosFileTransfer_Directory':get_number_of_properties(Dir1)), + + ?line ?match({ok, ["num_children", "is_directory"], {'IOP_IOR',[],[]}}, + 'CosFileTransfer_Directory':get_all_property_names(Dir1, 2)), + ?line ?match({ok, ["is_directory"], _}, + 'CosFileTransfer_Directory':get_all_property_names(Dir1, 1)), + + ?line ?match(#any{}, + 'CosFileTransfer_Directory':get_property_value(Dir1, "num_children")), + ?line ?match(#any{}, + 'CosFileTransfer_Directory':get_property_value(Dir1, "is_directory")), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':get_property_value(Dir1, "wrong")), + + ?line ?match({true, + [#'CosPropertyService_Property'{property_name = "num_children"}]}, + 'CosFileTransfer_Directory':get_properties(Dir1, ["num_children"])), + ?line ?match({false, + [#'CosPropertyService_Property'{property_name = "wrong"}]}, + 'CosFileTransfer_Directory':get_properties(Dir1, ["wrong"])), + + ?line ?match({ok, [_],_}, + 'CosFileTransfer_Directory':get_all_properties(Dir1, 1)), + ?line ?match({ok, [_,_], {'IOP_IOR',[],[]}}, + 'CosFileTransfer_Directory':get_all_properties(Dir1, 2)), + + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':delete_property(Dir1, "num_children")), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':delete_property(Dir1, "wrong")), + + + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':delete_properties(Dir1, ["num_children"])), + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_Directory':delete_properties(Dir1, ["wrong"])), + ?line ?match(false, 'CosFileTransfer_Directory':delete_all_properties(Dir1)), + ?line ?match(true, + 'CosFileTransfer_Directory':is_property_defined(Dir1, "num_children")), + ?line ?match(false, + 'CosFileTransfer_Directory':is_property_defined(Dir1, "wrong")), + + %% The Top Dir should be empty and ... + ?line ?match({ok,[],_}, 'CosFileTransfer_Directory':list(Dir1, 1000)), + ?line ?match( #any{value=0}, + 'CosPropertyService_PropertySet':get_property_value(Dir1, "num_children")), + %% Create a sub-directory. + ?line Dir2 = 'CosFileTransfer_FileTransferSession':create_directory(FS, + TEST_DIR_LEVEL2), + ?line ?match( #any{value=1}, + 'CosPropertyService_PropertySet':get_property_value(Dir1, "num_children")), + + ?line ?match({ok, [_,_], {'IOP_IOR',[],[]}}, + 'CosFileTransfer_Directory':get_all_properties(Dir1, 2)), + ?line {_,_,Iterator1} = ?match({ok, [_], _}, + 'CosFileTransfer_Directory':get_all_properties(Dir1, 1)), + ?line ?match({false, [_]}, + 'CosPropertyService_PropertiesIterator':next_n(Iterator1,4)), + + ?line {_,_,Iterator0} = ?match({ok, [], _}, + 'CosFileTransfer_Directory':get_all_properties(Dir1, 0)), + + ?line ?match({false, [_, {'CosPropertyService_Property', + "num_children",{any,tk_long,1}}]}, + 'CosPropertyService_PropertiesIterator':next_n(Iterator0,4)), + + ?line ?match({true, + [#'CosPropertyService_Property'{property_name = "num_children"}]}, + 'CosFileTransfer_Directory':get_properties(Dir1, ["num_children"])), + + %% The Top Directory is not emtpy any more and ... + ?line {ok,[#'CosFileTransfer_FileWrapper'{the_file = DirRef}],_} = + ?matchnopr({ok,[{'CosFileTransfer_FileWrapper', _, ndirectory}],_}, + 'CosFileTransfer_Directory':list(Dir1, 1000)), + %% ... its name eq. to 'TEST_DIR_LEVEL2' + ?line ?match(TEST_DIR_LEVEL2, + 'CosFileTransfer_Directory':'_get_complete_file_name'(DirRef)), + + ?line #'CosFileTransfer_FileWrapper'{the_file = Dir3} = + ?matchnopr({'CosFileTransfer_FileWrapper', _, ndirectory}, + 'CosFileTransfer_FileTransferSession':get_file(FS, TEST_DIR_LEVEL1)), + + %% Must get the same result for the 'get_file' operation. + ?line {ok,[#'CosFileTransfer_FileWrapper'{the_file = DirRef2}],_} = + ?matchnopr({ok,[{'CosFileTransfer_FileWrapper', _, ndirectory}],_}, + 'CosFileTransfer_Directory':list(Dir3,1000)), + ?line ?match(TEST_DIR_LEVEL2, + 'CosFileTransfer_Directory':'_get_complete_file_name'(DirRef2)), + + %% Since the top directory isn't empty deleting it must fail. + ?line ?match({'EXCEPTION', _}, + 'CosFileTransfer_FileTransferSession':delete(FS, Dir1)), + + %% Delete the sub-directory and ... + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':delete(FS, Dir2)), + %% ... see if the top directory realyy is empty. + ?line ?match({ok,[],_}, 'CosFileTransfer_Directory':list(Dir1, 1000)), + + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':delete(FS, Dir1)), + %% Test if the top directory been removed as intended. + ?line ?match({'EXCEPTION', {'CosFileTransfer_FileNotFoundException', _, _}}, + 'CosFileTransfer_FileTransferSession':get_file(FS, TEST_DIR_LEVEL1)), + + ?line ?match(false, corba_object:non_existent(FS)), + ?line ?match(ok, 'CosFileTransfer_FileTransferSession':logout(FS)), + %% To make sure Orber can remove it from mnesia. + timer:sleep(1000), + ?line ?match(true, corba_object:non_existent(FS)), + ?line ?match(ok, remote_apply(Node, ?MODULE, uninstall_data, [Name])), + stop_orber_remote(Node, normal), + ok + end. + + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- +ftp_host(Config) -> + case ?config(ftp_remote_host, Config) of + undefined -> + {skipped, "The configuration parameter 'ftp_remote_host' not defined."}; + Host -> + Host + end. + +loop_files([]) -> + io:format("@@@ DONE @@@~n", []); +loop_files([#'CosFileTransfer_FileWrapper'{the_file = H}|T]) -> + FullName = 'CosFileTransfer_File':'_get_complete_file_name'(H), + Name = 'CosFileTransfer_File':'_get_name'(H), + io:format("FULL NAME: ~p SHORT NAME: ~p~n", [FullName, Name]), + loop_files(T). + + +create_file_on_source_node('FTP', _Config, Host, FileName, Path, Data) -> + io:format("<<<<<< CosFileTransfer Testing File >>>>>>~n",[]), + io:format("Host: ~p~nPath: ~p~nFile: ~p~n", [Host, Path, FileName]), + {ok, Pid} = ?match({ok, _}, inets:start(ftpc, [{host, Host}], stand_alone)), + ?match(ok, ftp:user(Pid, ?FTP_USER, ?FTP_PASS)), + ?match(ok, ftp:cd(Pid, Path)), + ?match(ok, ftp:send_bin(Pid, list_to_binary(Data), FileName)), + ?match(ok, inets:stop(ftpc, Pid)); +create_file_on_source_node({'NATIVE', _}, _Config, Host, FileName, Path, Data) -> + io:format("<<<<<< CosFileTransfer Testing File >>>>>>~n",[]), + io:format("Host: ~p~nPath: ~p~nFile: ~p~n", [Host, Path, FileName]), + ?match(ok, file:write_file(FileName, list_to_binary(Data))). + +create_name(Type) -> + {MSec, Sec, USec} = erlang:now(), + lists:concat([Type,'_',MSec, '_', Sec, '_', USec]). + + + + +%%------------------------------------------------------------ +%% function : create_node/4 +%% Arguments: Name - the name of the new node (atom()) +%% Port - which iiop_port (integer()) +%% Domain - which domain. +%% Type - if /4 used the types defines the extra arguments +%% to be used. +%% Returns : {ok, Node} | {error, _} +%% Effect : Starts a new slave-node with given (optinally) +%% extra arguments. If fails it retries 'Retries' times. +%%------------------------------------------------------------ +create_node(Name, Port, normal) -> + Args = basic_args(Name), + create_node(Name, Port, 10, normal, Args, []); +create_node(Name, {Port, _Depth}, ssl) -> + Dir = filename:join([code:lib_dir(ssl), "examples", "certs", "etc"]), + Args = basic_args(Name), + {ok, Node} = create_node(list_to_atom(Name), Port, 10, ssl, Args, []), + %% Client + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_client_certfile, + filename:join([Dir, "client", "cert.pem"])]), + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_client_cacertfile, + filename:join([Dir, "client", "cacerts.pem"])]), + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_client_keyfile, + filename:join([Dir, "client", "key.pem"])]), + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_client_verify, 1]), + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_client_depth, 0]), + + %% Server + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_server_certfile, + filename:join([Dir, "server", "cert.pem"])]), + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_server_cacertfile, + filename:join([Dir, "server", "cacerts.pem"])]), + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_server_keyfile, + filename:join([Dir, "server", "key.pem"])]), + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_server_verify, 1]), + rpc:call(Node, application, set_env, [cosFileTransfer, ssl_server_depth, 0]), + {ok, Node}. + +%create_node(Name, {Port, Depth}, ssl) -> +% TestLibs = filename:join(filename:dirname(code:which(?MODULE)), "ssl_data"), +% Args = basic_args(Name), +% SArgs = basic_ssl_args(TestLibs, Args), +% LArgs = level_based_ssl(Depth, TestLibs, SArgs), +% create_node(list_to_atom(Name), Port, 10, ssl, LArgs, [{sslpath, TestLibs}]). + +create_node(Name, Port, Retries, Type, Args, Options) -> + [_, Host] = ?match([_,_],string:tokens(atom_to_list(node()), [$@])), + case starter(Host, Name, Args) of + {ok, NewNode} -> + ?line ?match(pong, net_adm:ping(NewNode)), + {ok, Cwd} = file:get_cwd(), + Path = code:get_path(), + ?line ?match(ok, rpc:call(NewNode, file, set_cwd, [Cwd])), + true = rpc:call(NewNode, code, set_path, [Path]), + ?match(ok, start_orber_remote(NewNode, Type, Options, Port)), + spawn_link(NewNode, ?MODULE, slave_sup, []), + rpc:multicall([node() | nodes()], global, sync, []), + {ok, NewNode}; + {error, Reason} when Retries == 0-> + {error, Reason}; + {error, Reason} -> + io:format("Could not start slavenode ~p ~p retrying~n", + [{Host, Name, Args}, Reason]), + timer:sleep(500), + create_node(Name, Port, Retries - 1, Type, Args, Options) + end. + +starter(Host, Name, Args) -> + case os:type() of + vxworks -> + test_server:start_node(Name, slave, [{args,Args}]); + _ -> + slave:start(Host, Name, Args) + end. + +slave_sup() -> + process_flag(trap_exit, true), + receive + {'EXIT', _, _} -> + case os:type() of + vxworks -> + erlang:halt(); + _ -> + ignore + end + end. + + +%%------------------------------------------------------------ +%% function : destroy_node +%% Arguments: Node - which node to destroy. +%% Type - normal | ssl +%% Returns : +%% Effect : +%%------------------------------------------------------------ +-ifdef(false). +destroy_node(Node, Type) -> + stopper(Node, Type). + +stopper(Node, Type) -> + catch stop_orber_remote(Node, Type), + case os:type() of + vxworks -> + test_server:stop_node(Node); + _ -> + slave:stop(Node) + end. +-endif. + +%%------------------------------------------------------------ +%% function : remote_apply +%% Arguments: N - Node, M - Module, +%% F - Function, A - Arguments (list) +%% Returns : +%% Effect : +%%------------------------------------------------------------ +remote_apply(N, M,F,A) -> + case rpc:call(N, M, F, A) of + {badrpc, Reason} -> + exit(Reason); + Other -> + Other + end. + +%%------------------------------------------------------------ +%% function : stop_orber_remote +%% Arguments: Node - which node to stop orber on. +%% Type - normal | ssl | light | ....... +%% Returns : ok +%% Effect : Stops orber on given node and, if specified, +%% other applications or programs. +%%------------------------------------------------------------ +stop_orber_remote(Node, ssl) -> + rpc:call(Node, ssl, stop, []), + rpc:call(Node, crypto, stop, []), + orb_rpc_blast(Node, ssl); +stop_orber_remote(Node, Type) -> + orb_rpc_blast(Node, Type). + +orb_rpc_blast(Node, _) -> + rpc:call(Node, cosFileTransferApp, stop, []), + rpc:call(Node, cosProperty, stop, []), + rpc:call(Node, cosFileTransferApp, uninstall, []), + rpc:call(Node, cosProperty, uninstall, []), + rpc:call(Node, orber, jump_stop, []). + +%%------------------------------------------------------------ +%% function : start_orber_remote +%% Arguments: Node - which node to start orber on. +%% Type - normal | ssl | light | ....... +%% Returns : ok +%% Effect : Starts orber on given node and, if specified, +%% other applications or programs. +%%------------------------------------------------------------ +start_orber_remote(Node, ssl, _Options, Port) -> + rpc:call(Node, ssl, start, []), + rpc:call(Node, crypto, start, []), + rpc:call(Node, ssl, seed, ["testing"]), + orb_rpc_setup(Node, ssl, Port); +start_orber_remote(Node, Type, _, Port) -> + orb_rpc_setup(Node, Type, Port). + +orb_rpc_setup(Node, _, Port) -> + rpc:call(Node, orber, jump_start, [Port]), + rpc:call(Node, cosProperty, install, []), + rpc:call(Node, cosProperty, start, []), + rpc:call(Node, cosFileTransferApp, install, []). + +%%--------------- MISC FUNCTIONS ----------------------------- +basic_args(_Name) -> + TestLibs = filename:dirname(code:which(?MODULE)), + " -orber orber_debug_level 10" ++ + " -pa " ++ + TestLibs ++ + " -pa " ++ + filename:join(TestLibs, "all_SUITE_data") ++ + " -pa " ++ + filename:dirname(code:which(cosFileTransferApp)). + +-ifdef(false). +basic_ssl_args(TestLibs, Args) -> +% Args ++ +% " -cosFileTransfer ssl_client_certfile \\\"" ++ +% filename:join(TestLibs, "ssl_client_cert.pem") ++ +% "\\\" -cosFileTransfer ssl_server_certfile \\\""++ +% filename:join(TestLibs, "ssl_server_cert.pem")++"\\\"". + + io:format("<<<<<< SSL LIBS ~p >>>>>>~n",[TestLibs]), + NewArgs = Args ++ + " -cosFileTransfer ssl_client_certfile \\\"" ++ + filename:join(TestLibs, "ssl_client_cert.pem") ++ + "\\\" -cosFileTransfer ssl_server_certfile \\\""++ + filename:join(TestLibs, "ssl_server_cert.pem")++"\\\"", + io:format("<<<<<< SSL LIBS ARGS ~p >>>>>>~n",[NewArgs]), + NewArgs. + +level_based_ssl(1, _TestLibs, Args) -> + Args; +level_based_ssl(2, _TestLibs, Args) -> + Args.% ++ +% " -cosFileTransfer ssl_server_depth 2 " ++ +% " -cosFileTransfer ssl_client_depth 2 " ++ +% " -cosFileTransfer ssl_server_verify " ++ +% " -cosFileTransfer ssl_client_verify " ++ +% " -cosFileTransfer ssl_server_cacertfile " ++ +% " -cosFileTransfer ssl_client_cacertfile " ++ + +-endif. + +install_data(Protocol, {WhichType, Host, Name}) -> + io:format("<<<<<< Starting ~p/~p VFS at ~p/~p>>>>>>~n", + [Protocol, WhichType, Host, Name]), + %% Create a Virtual File System. + ?line VFS = ?match({_,_,_,_,_,_}, + cosFileTransferApp:create_VFS(WhichType, [], Host, ?FTP_PORT, + [{protocol, Protocol}])), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), Name), + N = lname:insert_component(lname:create(), 1, NC1), + 'CosNaming_NamingContext':rebind(NS, N, VFS). + +uninstall_data(Name) -> + ?line VFS = ?match({_,_,_,_,_,_}, + corba:string_to_object("corbaname:rir:/NameService#"++Name)), + ?line ?match(ok, corba:dispose(VFS)), + ok. + + + +%%------------------- EOF MODULE----------------------------------- diff --git a/lib/dialyzer/src/dialyzer_races.erl b/lib/dialyzer/src/dialyzer_races.erl index ec8d613b96..ee9d5e88a3 100644 --- a/lib/dialyzer/src/dialyzer_races.erl +++ b/lib/dialyzer/src/dialyzer_races.erl @@ -118,7 +118,7 @@ var_map :: dict()}). -type case_tags() :: 'beg_case' | #beg_clause{} | #end_clause{} | #end_case{}. --type code() :: [#dep_call{} | #warn_call{} | #fun_call{} | +-type code() :: [#dep_call{} | #fun_call{} | #warn_call{} | #curr_fun{} | #let_tag{} | case_tags() | race_tag()]. -type table_var() :: label() | ?no_label. @@ -479,23 +479,11 @@ fixup_race_forward(CurrFun, CurrFunLabel, Calls, Code, RaceList, _Other -> {RaceList, [], NestingLevel, false} end; - #dep_call{call_name = ets_lookup, args = DepCallArgs} -> + #dep_call{call_name = ets_lookup} -> case RaceWarnTag of ?WARN_ETS_LOOKUP_INSERT -> - [Tab, Names, _, _] = DepCallArgs, - case compare_var_list(Tab, - dialyzer_callgraph:get_public_tables(Callgraph), - RaceVarMap) - orelse - length(Names -- - dialyzer_callgraph:get_named_tables(Callgraph)) < - length(Names) of - true -> - {[Head#dep_call{var_map = RaceVarMap}|RaceList], - [], NestingLevel, false}; - false -> - {RaceList, [], NestingLevel, false} - end; + {[Head#dep_call{var_map = RaceVarMap}|RaceList], + [], NestingLevel, false}; _Other -> {RaceList, [], NestingLevel, false} end; @@ -517,23 +505,11 @@ fixup_race_forward(CurrFun, CurrFunLabel, Calls, Code, RaceList, _Other -> {RaceList, [], NestingLevel, false} end; - #warn_call{call_name = ets_insert, args = WarnCallArgs} -> + #warn_call{call_name = ets_insert} -> case RaceWarnTag of ?WARN_ETS_LOOKUP_INSERT -> - [Tab, Names, _, _] = WarnCallArgs, - case compare_var_list(Tab, - dialyzer_callgraph:get_public_tables(Callgraph), - RaceVarMap) - orelse - length(Names -- - dialyzer_callgraph:get_named_tables(Callgraph)) < - length(Names) of - true -> - {[Head#warn_call{var_map = RaceVarMap}|RaceList], - [], NestingLevel, false}; - false -> - {RaceList, [], NestingLevel, false} - end; + {[Head#warn_call{var_map = RaceVarMap}|RaceList], + [], NestingLevel, false}; _Other -> {RaceList, [], NestingLevel, false} end; diff --git a/lib/erl_interface/src/misc/ei_format.c b/lib/erl_interface/src/misc/ei_format.c index 08235d0ebe..b35421d4b2 100644 --- a/lib/erl_interface/src/misc/ei_format.c +++ b/lib/erl_interface/src/misc/ei_format.c @@ -106,6 +106,8 @@ static int eiformat(const char** fmt, union arg** args, ei_x_buff* x) default: if (isdigit((int)*p)) res = pdigit(&p, x); + else if ((*p == '-' || *p == '+') && isdigit((int)*(p+1))) + res = pdigit(&p, x); else if (islower((int)*p)) res = patom(&p, x); else @@ -149,6 +151,8 @@ static int pdigit(const char** fmt, ei_x_buff* x) double d; long l; + if (**fmt == '-' || **fmt == '+') + (*fmt)++; for (;;) { c = *(*fmt)++; if (isdigit((int)c)) diff --git a/lib/erl_interface/src/prog/erl_call.c b/lib/erl_interface/src/prog/erl_call.c index 448de9aa23..33ff6da7c9 100644 --- a/lib/erl_interface/src/prog/erl_call.c +++ b/lib/erl_interface/src/prog/erl_call.c @@ -118,7 +118,6 @@ static void usage_arg(const char *progname, const char *switchname); static void usage_error(const char *progname, const char *switchname); static void usage(const char *progname); static int get_module(char **mbuf, char **mname); -static struct hostent* get_hostent(char *host); static int do_connect(ei_cnode *ec, char *nodename, struct call_flags *flags); static int read_stdin(char **buf); static void split_apply_string(char *str, char **mod, @@ -367,8 +366,8 @@ int erl_call(int argc, char **argv) * Expand name to a real name (may be ip-address) */ /* FIXME better error string */ - if ((hp = get_hostent(host)) == 0) { - fprintf(stderr,"erl_call: can't get_hostent(%s)\n", host); + if ((hp = ei_gethostbyname(host)) == 0) { + fprintf(stderr,"erl_call: can't ei_gethostbyname(%s)\n", host); exit(1); } /* If shortnames, cut off the name at first '.' */ @@ -604,32 +603,6 @@ int erl_call(int argc, char **argv) * ***************************************************************************/ -/* - * Get host entry (by address or name) - */ -/* FIXME: will fail on names like '2fun4you'. */ -static struct hostent* get_hostent(char *host) -{ - if (isdigit((int)*host)) { - struct in_addr ip_addr; - int b1, b2, b3, b4; - long addr; - - /* FIXME: Use inet_aton() (or inet_pton() and get v6 for free). */ - if (sscanf(host, "%d.%d.%d.%d", &b1, &b2, &b3, &b4) != 4) { - return NULL; - } - addr = inet_addr(host); - ip_addr.s_addr = htonl(addr); - - return ei_gethostbyaddr((char *)&ip_addr,sizeof(struct in_addr), AF_INET); - } - - return ei_gethostbyname(host); -} /* get_hostent */ - - - /* * This function does only return on success. diff --git a/lib/erl_interface/src/registry/reg_dump.c b/lib/erl_interface/src/registry/reg_dump.c index 50a6949177..dfec96b43c 100644 --- a/lib/erl_interface/src/registry/reg_dump.c +++ b/lib/erl_interface/src/registry/reg_dump.c @@ -157,7 +157,7 @@ static int mn_send_delete(int fd, erlang_pid *mnesia, const char *key) int len = strlen(key) + 32; /* 32 is a slight overestimate */ if (len > EISMALLBUF) - if (!(dbuf = malloc(index))) + if (!(dbuf = malloc(len))) return -1; msgbuf = (dbuf ? dbuf : sbuf); @@ -187,7 +187,7 @@ static int mn_send_write(int fd, erlang_pid *mnesia, const char *key, ei_reg_obj int len = 32 + keylen + obj->size; if (len > EISMALLBUF) - if (!(dbuf = malloc(index))) + if (!(dbuf = malloc(len))) return -1; msgbuf = (dbuf ? dbuf : sbuf); diff --git a/lib/erl_interface/src/registry/reg_restore.c b/lib/erl_interface/src/registry/reg_restore.c index 27918d2364..aeb33c784a 100644 --- a/lib/erl_interface/src/registry/reg_restore.c +++ b/lib/erl_interface/src/registry/reg_restore.c @@ -266,7 +266,7 @@ int ei_reg_restore(int fd, ei_reg *reg, const char *mntab) /* make sure receive buffer can handle largest expected message */ len = maxkey + maxobj + 512; if (len > EISMALLBUF) - if (!(dbuf = malloc(index))) { + if (!(dbuf = malloc(len))) { ei_send_exit(fd,&self,&mnesia,"cannot allocate space for incoming data"); return -1; } diff --git a/lib/erl_interface/test/ei_format_SUITE.erl b/lib/erl_interface/test/ei_format_SUITE.erl index 7871f07ae9..cbe9fa52d7 100644 --- a/lib/erl_interface/test/ei_format_SUITE.erl +++ b/lib/erl_interface/test/ei_format_SUITE.erl @@ -155,7 +155,7 @@ format_wo_ver(suite) -> []; format_wo_ver(Config) when is_list(Config) -> ?line P = runner:start(?format_wo_ver), - ?line {term, [{a, "b"}, {c, 10}]} = get_term(P), + ?line {term, [-1, 2, {a, "b"}, {c, 10}]} = get_term(P), ?line runner:recv_eot(P), ok. diff --git a/lib/erl_interface/test/ei_format_SUITE_data/ei_format_test.c b/lib/erl_interface/test/ei_format_SUITE_data/ei_format_test.c index a969ded3dc..ecdce402f5 100644 --- a/lib/erl_interface/test/ei_format_SUITE_data/ei_format_test.c +++ b/lib/erl_interface/test/ei_format_SUITE_data/ei_format_test.c @@ -176,7 +176,7 @@ TESTCASE(format_wo_ver) { ei_x_buff x; ei_x_new (&x); - ei_x_format(&x, "[{~a,~s},{~a,~i}]", "a", "b", "c", 10); + ei_x_format(&x, "[-1, +2, {~a,~s},{~a,~i}]", "a", "b", "c", 10); send_bin_term(&x); free(x.buff); diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl index f5d5441184..5bdd1a8672 100644 --- a/lib/stdlib/src/supervisor.erl +++ b/lib/stdlib/src/supervisor.erl @@ -33,7 +33,9 @@ -export([init/1, handle_call/3, handle_info/2, terminate/2, code_change/3]). -export([handle_cast/2]). --export_type([child_spec/0, strategy/0]). +%%-------------------------------------------------------------------------- + +-export_type([child_spec/0, del_err/0, startchild_ret/0, strategy/0]). %%-------------------------------------------------------------------------- @@ -77,6 +79,10 @@ -define(is_simple(State), State#state.strategy =:= simple_one_for_one). +%%-------------------------------------------------------------------------- + +-spec behaviour_info(atom()) -> 'undefined' | [{atom(), arity()}]. + behaviour_info(callbacks) -> [{init,1}]; behaviour_info(_Other) -> @@ -160,11 +166,13 @@ check_childspecs(X) -> {error, {badarg, X}}. %%% %%% --------------------------------------------------- +-type init_sup_name() :: sup_name() | 'self'. + -type stop_rsn() :: 'shutdown' | {'bad_return', {module(),'init', term()}} | {'bad_start_spec', term()} | {'start_spec', term()} | {'supervisor_data', term()}. --spec init({sup_name(), module(), [term()]}) -> +-spec init({init_sup_name(), module(), [term()]}) -> {'ok', state()} | 'ignore' | {'stop', stop_rsn()}. init({SupName, Mod, Args}) -> @@ -184,7 +192,7 @@ init({SupName, Mod, Args}) -> Error -> {stop, {bad_return, {Mod, init, Error}}} end. - + init_children(State, StartSpec) -> SupName = State#state.name, case check_startspec(StartSpec) of diff --git a/lib/stdlib/test/escript_SUITE.erl b/lib/stdlib/test/escript_SUITE.erl index 77fd190e45..162ca6006f 100644 --- a/lib/stdlib/test/escript_SUITE.erl +++ b/lib/stdlib/test/escript_SUITE.erl @@ -31,6 +31,7 @@ epp/1, create_and_extract/1, foldl/1, + overflow/1, verify_sections/3 ]). @@ -48,7 +49,8 @@ all(suite) -> archive_script, epp, create_and_extract, - foldl + foldl, + overflow ]. init_per_testcase(_Case, Config) -> @@ -736,6 +738,17 @@ emulate_escript_foldl(Fun, Acc, File) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +overflow(Config) when is_list(Config) -> + Data = ?config(data_dir, Config), + Dir = filename:absname(Data), %Get rid of trailing slash. + ?line run(Dir, "arg_overflow", + [<<"ExitCode:0">>]), + ?line run(Dir, "linebuf_overflow", + [<<"ExitCode:0">>]), + ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + run(Dir, Cmd0, Expected0) -> Expected = iolist_to_binary(expected_output(Expected0, Dir)), Cmd = case os:type() of diff --git a/lib/stdlib/test/escript_SUITE_data/arg_overflow b/lib/stdlib/test/escript_SUITE_data/arg_overflow new file mode 100755 index 0000000000..dd5accc051 --- /dev/null +++ b/lib/stdlib/test/escript_SUITE_data/arg_overflow @@ -0,0 +1,5 @@ +#! /usr/bin/env escript +%% -*- erlang -*- +%%!x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x +main(_) -> + halt(0). diff --git a/lib/stdlib/test/escript_SUITE_data/linebuf_overflow b/lib/stdlib/test/escript_SUITE_data/linebuf_overflow new file mode 100755 index 0000000000..33133c1ce9 --- /dev/null +++ b/lib/stdlib/test/escript_SUITE_data/linebuf_overflow @@ -0,0 +1,5 @@ +#! /usr/bin/env escript +%% -*- erlang -*- +%%!xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +main(_) -> + halt(0). |