Exemplo n.º 1
0
END_NCBI_SCOPE


int main(int argc, char* argv[])
{
    USING_NCBI_SCOPE;

    // Setup error posting
    SetDiagTrace(eDT_Enable);
    SetDiagPostLevel(eDiag_Trace);
    SetDiagPostAllFlags(SetDiagPostAllFlags(eDPF_Default)
                        | eDPF_All | eDPF_OmitInfoSev);
    UnsetDiagPostFlag(eDPF_Line);
    UnsetDiagPostFlag(eDPF_File);
    UnsetDiagPostFlag(eDPF_Location);
    UnsetDiagPostFlag(eDPF_LongFilename);
    SetDiagTraceAllFlags(SetDiagPostAllFlags(eDPF_Default));

    // Init the library explicitly (this sets up the log)
    CONNECT_Init(0);

    STimeout tmo = { 5, 0 };
    EIO_Status status = Soaker(argv[1], "Hello", &tmo, &tmo);
    cout << "Status = " << IO_StatusStr(status) << endl;

    return !(status == eIO_Success);
}
void CTestNetScheduleClient::Init(void)
{
    InitOutputBuffer();

    CONNECT_Init();
    SetDiagPostFlag(eDPF_Trace);
    SetDiagPostLevel(eDiag_Info);

    // Setup command line arguments and parameters

    // Create command-line argument descriptions class
    auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);

    // Specify USAGE context
    arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
                              "NetSchedule client");

    arg_desc->AddKey("service", "ServiceName",
        "NetSchedule service name (format: host:port or servcie_name)",
        CArgDescriptions::eString);

    arg_desc->AddKey("queue", "QueueName",
        "NetSchedule queue name",
        CArgDescriptions::eString);

    arg_desc->AddOptionalKey("ilen", "InputLength", "Average input length",
                             CArgDescriptions::eInteger);

    arg_desc->AddOptionalKey("maxruntime", "MaxRunTime",
            "Maximum run time of this test", CArgDescriptions::eInteger);

    arg_desc->AddOptionalKey("input", "InputString", "Input string",
                             CArgDescriptions::eString);

    arg_desc->AddOptionalKey("jobs", "jobs", "Number of jobs to submit",
                             CArgDescriptions::eInteger);

    arg_desc->AddOptionalKey("naff", "AffinityTokens",
        "Number of different affinities", CArgDescriptions::eInteger);


    // Setup arg.descriptions for this application
    SetupArgDescriptions(arg_desc.release());
}
    int Run(void)
    {
        CONNECT_Init(&CNcbiApplication::Instance()->GetConfig());
        
        const CNcbiArguments& app_args = GetArguments();
        m_Seed = app_args.Size() > 1 ?
                (unsigned int)atoi(app_args[1].c_str()) : (unsigned int)time(0);
        // Set error posting and tracing on maximum
        SetDiagTrace(eDT_Enable);
        SetDiagPostLevel(eDiag_Info);
        SetDiagPostAllFlags(SetDiagPostAllFlags(eDPF_Default)
            | eDPF_All | eDPF_OmitInfoSev);
        UnsetDiagPostFlag(eDPF_Line);
        UnsetDiagPostFlag(eDPF_File);
        UnsetDiagPostFlag(eDPF_Location);
        UnsetDiagPostFlag(eDPF_LongFilename);
        SetDiagTraceAllFlags(SetDiagPostAllFlags(eDPF_Default));

        string host = "www.ncbi.nlm.nih.gov";
        string path = "/Service/bounce.cgi";
        string args = kEmptyStr;
        string uhdr = kEmptyStr;

        ERR_POST(Info << "Seed = " << m_Seed);
        srand(m_Seed);

        ERR_POST(Info << "Creating HTTP connection to "
            "http://" + host + path + &"?"[args.empty() ? 1 : 0] + args);
        CConn_HttpStream ios(host, path, args, uhdr);

        int n = TEST_StreamPushback(ios, false/*no rewind*/);

        // Manual CONNECT_UnInit (for implicit CONNECT_Init() by HTTP stream ctor)
        CORE_SetREG(0);
        CORE_SetLOG(0);
        CORE_SetLOCK(0);

        return n;
    }
Exemplo n.º 4
0
int
#endif
main(int argc, char *argv[])
{
  Nlm_Int2 retval;

  Nlm_SetupArguments(argc, argv);

#ifdef MSC_VIRT
  if ( !_vheapinit(0, 1250, _VM_ALLSWAP) )
    {
      ErrPost(CTX_NCBIOBJ, 1, "Can't open virtual memory");
      return 1;
    }
#endif

  /* Initialize connection library's logger, registry and lock */
  CONNECT_Init(0);

  retval = Nlm_Main();

  NlmThreadJoinAll();

  Nlm_FreeConfigStruct();
  ErrSetLogfile(NULL, 0);
  Nlm_ReleaseAppContext();

#ifdef MSC_VIRT
  _vheapterm();
#endif

  NlmThreadDestroyAll();

#if   defined(OS_MSWIN)
  return retval;
#elif defined(OS_UNIX) || defined(OS_VMS)
  exit( retval );
#endif
}
Exemplo n.º 5
0
void CTestApplication::Init(void)
{
    CONNECT_Init(&GetConfig());

    auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
    arg_desc->AddDefaultKey("gi_from", "GiFrom",
                            "first GI to fetch",
                            CArgDescriptions::eInt8, "100");
    arg_desc->AddDefaultKey("gi_to", "GiTo",
                            "last GI to fetch",
                            CArgDescriptions::eInt8, "200");
    arg_desc->AddDefaultKey("count", "Count",
                            "number of passes",
                            CArgDescriptions::eInteger, "1");

    // Program description
    string prog_description = "Test id1 reader\n";
    arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
                              prog_description, false);

    // Pass argument descriptions to the application
    //
    SetupArgDescriptions(arg_desc.release());
}
Exemplo n.º 6
0
NCBITEST_AUTO_INIT()
{
    CONNECT_Init();
    SeqLocAsnLoad();
    s_SeqIdATP = AsnFind(const_cast<char*>("Seq-id")); // avoid warnings
}
Exemplo n.º 7
0
int CAgpValidateApplication::Run(void)
{
  //// Setup registry, error log, MT-lock for CONNECT library
  CONNECT_Init(&GetConfig());

 //// Process command line arguments
  const CArgs& args = GetArgs();

  if( args["list"].HasValue() ) {
    CAgpErrEx::PrintAllMessages(cout);
    exit(0);
  }

  if( args["xml"].HasValue() ) {
    m_use_xml=true;
    pAgpErr->m_use_xml=true;
    pAgpErr->m_out = &cout; // not the default &cerr
  }

  CNcbiOstrstream* error_details_out=NULL; // using cerr or cout directly
  if( args["sub"].HasValue() ) {
    pAgpErr->m_strict=true;
    if(!m_use_xml) {
      error_details_out = new CNcbiOstrstream();
      pAgpErr->m_out = error_details_out;
    }
  }

  m_reader.m_CheckObjLen=args["obj"].HasValue();
  m_reader.m_unplaced   =args["un" ].HasValue();
  if(args["chr" ].HasValue() || args["scaf" ].HasValue()) {
    if( m_reader.m_unplaced  ) {
      cerr << "Error -- cannot specify -un with -chr/-scaf.\n";
      exit(1);
    }
    if( args["alt"].HasValue() || args["species"].HasValue() ) {
      cerr << "Error -- cannot specify -chr/-scaf with -alt/-species.\n";
      exit(1);
    }
  }
  if( args["chr"].HasValue() ) {
    if( args["scaf"].HasValue() ) {
      cerr << "Error -- -scaf and -chr must precede different files.\n";
      exit(1);
    }
    m_reader.m_is_chr=true;
    m_reader.m_explicit_scaf=true;
  }
  else if( args["scaf"].HasValue() ) {
    m_reader.m_explicit_scaf=true;
  }

  if( args["alt"].HasValue() || args["species"].HasValue() ) {
    if(m_reader.m_CheckObjLen) {
      cerr << "Error -- cannot specify -obj with -alt/-species.\n";
      exit(1);
    }
    m_ValidationType = VT_AccLenTaxid;
  }
  else {
    m_ValidationType = VT_Context;
    bool checkCompNames=args["g"].HasValue();
    // m_ContextValidator = new CAgpContextValidator(checkCompNames);
    if(checkCompNames) {
      // also print WGS component_id/component_type mismatches.
      pAgpErr->SkipMsg(CAgpErr::W_CompIsWgsTypeIsNot, true);
      pAgpErr->SkipMsg(CAgpErr::W_CompIsNotWgsTypeIs, true);
      m_reader.m_CheckCompNames=true;
    }

  }
  if(m_ValidationType & VT_Acc) {
    CONNECT_Init(&GetConfig()); // Setup registry, error log, MT-lock for CONNECT library

    m_AltValidator= new CAltValidator(m_ValidationType==VT_AccLenTaxid);
    m_AltValidator->Init();
    if( args["species"].HasValue() ) {
      m_AltValidator->m_SpeciesLevelTaxonCheck = true;
    }
    if( args["out"].HasValue() ) {
      m_AltValidator->m_out = &(args["out"].AsOutputFile());
    }
  }

  const CArgValue::TStringArray* err_warn=NULL;
  bool onlyNotSkip = args["only"].HasValue();
  string action;
  if( args["skip"].HasValue() ) {
     if( onlyNotSkip ) {
       cerr << "Error -- cannot specify both -only and -skip.\n";
       exit(1);
     }
     err_warn = &( args["skip"].GetStringList() );
     action="Skipping messages:\n";
  }
  else if(onlyNotSkip) {
    if( args["show"].HasValue() ) {
      cerr << "Error -- cannot specify both -only and -show; please use multiple -only instead.\n";
      exit(1);
    }

    err_warn = &( args["only"].GetStringList() );
    pAgpErr->SkipMsg("all");
    action="Allowed messages:\n";
  }
  if(err_warn) {
    // Inform pAgpErr what to skip; show messages that we skip.
    bool needHeading=true; // avoid printing >action when not needed
    for( CArgValue::TStringArray::const_iterator it =
      err_warn->begin();  it != err_warn->end(); ++it
    ) {
      string res  = pAgpErr->SkipMsg(*it, onlyNotSkip);
      if(res=="") {
        cerr << "WARNING: no matches for " << *it << "\n";
        needHeading=true;
      }
      else {
        if ( res[0] == ' ' && needHeading) {
          if(needHeading) cerr << action;
          cerr << res;
          needHeading=false;
        }
        else {
          cerr << res << "\n";
          needHeading=true;
        }
      }
    }
  }

  if( args["show"].HasValue() ) {
    err_warn = &( args["show"].GetStringList() );
    for( CArgValue::TStringArray::const_iterator it =
      err_warn->begin();  it != err_warn->end(); ++it
    ) {
      pAgpErr->SkipMsg(*it, true);
    }
  }

  pAgpErr->m_MaxRepeat =
    args["limit"].HasValue() ? args["limit"].AsInteger() : 100;

  if(args["v"].HasValue() ) {
    if( args["v"].AsString()[0]=='1' ) {
      m_agp_version=eAgpVersion_1_1;
    }
    else if( args["v"].AsString()[0]=='2' ) {
      m_agp_version=eAgpVersion_2_0;
    }
    else {
      cerr << "Error -- invalid AGP version after -v. Use 1.1 or 2.0.\n";
      exit(1);
    }
  }
  else {
    m_agp_version=eAgpVersion_auto; // save for CAgpRow; it is default for CAgpValidateReader
  }

  if( ! args["comp"] ) {
      // if "-comp" not specified, neither should the other
      // comp-related args
      if( args["loadlog"] || args["ignoreagponly"] ||
          args["ignoreobjfileonly"] ||
          args["diffstofind"].AsInteger() > 0 )
      {
          cerr << "Error -- -comp mode options without -comp" << endl;
          exit(1);
      }

      //// Process files, print results
      bool taxid_check_failed=false;
      if(m_use_xml) {
        cout << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<page>\n";
      }
      x_ValidateUsingFiles(args, error_details_out);
      if(m_ValidationType == VT_Context) {
        m_reader.PrintTotals(cout, m_use_xml);
      }
      else if(m_ValidationType & VT_Acc) {
        if(!m_use_xml) cout << "\n";
        if(m_ValidationType & VT_Taxid) taxid_check_failed = !m_AltValidator->CheckTaxids(cout, m_use_xml);
        m_AltValidator->PrintTotals(cout, m_use_xml);
      }
      if(m_use_xml) {
        cout << "</page>\n";
        // return 0;
      }
      else if(error_details_out) {
        cout << "\n\n===== Details =====" << endl;
        cout << (string)CNcbiOstrstreamToString(*error_details_out);
        delete error_details_out;
      }
      return (pAgpErr->CountTotals(CAgpErrEx::E_Last)>0 || taxid_check_failed) ? 2 : 0;
  }
  else {
      // Note: traditional validation (now in the "if" clause above) used to be done regardless of args["comp"].
      // Doing it separately now since it does not yet work properly when both object and component FASTA files are given at the same time.

      list<string> filenames;
      for (unsigned int i = 1; i <= args.GetNExtra(); i++) {
          const string filename = args['#' + NStr::IntToString(i)].AsString();
          if( ! filename.empty() && filename[0] != '-' ) {
              filenames.push_back(filename);
          }
      }

      string comploadlog;
      if( args["loadlog"] ) {
          comploadlog = args["loadlog"].AsString();
      }

      string agp_as_fasta_file;
      if( args["out"] ) {
          agp_as_fasta_file = args["out"].AsString();
      }

      CAgpFastaComparator::TDiffsToHide diffsToHide = 0;
      if( args["ignoreagponly"] ) {
          diffsToHide |= CAgpFastaComparator::fDiffsToHide_AGPOnly;
      }
      if( args["ignoreobjfileonly"] ) {
          diffsToHide |= CAgpFastaComparator::fDiffsToHide_ObjfileOnly;
      }

      int diffsToFind = args["diffstofind"].AsInteger();

      CAgpFastaComparator agpFastaComparator;
      if( CAgpFastaComparator::eResult_Success !=
          agpFastaComparator.Run( filenames, comploadlog,
                                  agp_as_fasta_file, diffsToHide,
                                  diffsToFind) )
      {
          cerr << "AGP/FASTA comparison failed." << endl;
      }
  }

  return 0;
}
Exemplo n.º 8
0
//  --------------------------------------------------------------------------
int CAsn2FastaApp::Run(void)
//  --------------------------------------------------------------------------
{
	// initialize conn library
	CONNECT_Init(&GetConfig());

    const CArgs&   args = GetArgs();

    // create object manager
    m_Objmgr = CObjectManager::GetInstance();
    if ( !m_Objmgr ) {
        NCBI_THROW(CException, eUnknown,
                   "Could not create object manager");
    }
    CGBDataLoader::RegisterInObjectManager(*m_Objmgr);
    m_Scope.Reset(new CScope(*m_Objmgr));
    m_Scope->AddDefaults();

    // open the output stream
    m_Os = args["o"] ? &(args["o"].AsOutputFile()) : &cout;
    if ( m_Os == 0 ) {
        NCBI_THROW(CException, eUnknown, "Could not open output stream");
    }

    auto_ptr<CObjectIStream> is;
    is.reset( x_OpenIStream( args ) );
    if (is.get() == NULL) {
        string msg = args["i"]? "Unable to open input file" + args["i"].AsString() :
                        "Unable to read data from stdin";
        NCBI_THROW(CException, eUnknown, msg);
    }

    m_DeflineOnly = args["defline-only"];

    if ( args["batch"] ) {
        CGBReleaseFile in(*is.release());
        in.RegisterHandler(this);
        in.Read();  // HandleSeqEntry will be called from this function
    }
    else {

        if ( args["id"] ) {

            //
            //  Implies gbload; otherwise this feature would be pretty
            //  useless...
            //
            m_Scope->AddDefaults();
            string seqID = args["id"].AsString();
            HandleSeqID( seqID );

        } else {
            string asn_type = args["type"].AsString();
            CSeq_entry_Handle seh;

            if ( asn_type == "seq-entry" ) {
                //
                //  Straight through processing: Read a seq_entry, then process
                //  a seq_entry:
                //
                seh = ObtainSeqEntryFromSeqEntry(*is);
                while (seh) {
                    try {
                        HandleSeqEntry(seh);
                    }
                    catch (...) {
                        cerr << "Resolution error: Sequence dropped." << endl;
                    }
                    m_Scope->RemoveTopLevelSeqEntry(seh);
                    seh = ObtainSeqEntryFromSeqEntry(*is);
                }
                return 0;
			}
			else if ( asn_type == "bioseq" ) {				
				//
                //  Read object as a bioseq, wrap it into a seq_entry, then
                //  process the wrapped bioseq as a seq_entry:
				//
                seh = ObtainSeqEntryFromBioseq(*is);
                if ( !seh ) {
                    NCBI_THROW(CException, eUnknown,
                               "Unable to construct Seq-entry object" );
                }
                HandleSeqEntry(seh);
			}
			else if ( asn_type == "bioseq-set" ) {
				//
				//  Read object as a bioseq_set, wrap it into a seq_entry, then
				//  process the wrapped bioseq_set as a seq_entry:
				//
                seh = ObtainSeqEntryFromBioseqSet(*is);
                if ( !seh ) {
                    NCBI_THROW(CException, eUnknown,
                               "Unable to construct Seq-entry object" );
                }
                HandleSeqEntry(seh);
			}
            else if ( asn_type == "any" ) {
                //
                //  Try the first three in turn:
                //
                size_t streampos = is->GetStreamPos();
                while (!is->EndOfData()) {
                    seh = ObtainSeqEntryFromSeqEntry(*is);
                    if (!seh) {
                        if (is->EndOfData()) {
                            break;
                        }
                        is->ClearFailFlags(-1);
                        is->SetStreamPos(streampos);
                        seh = ObtainSeqEntryFromBioseqSet(*is);
                    }
                    if (!seh) {
                        if (is->EndOfData()) {
                            break;
                        }
                        is->ClearFailFlags(-1);
                        is->SetStreamPos(streampos);
                        seh = ObtainSeqEntryFromBioseq(*is);
                    }
                    if (!seh) {
                        NCBI_THROW(CException, eUnknown,
                            "Unable to construct Seq-entry object" );
                    }
                    HandleSeqEntry(seh);
                    m_Scope->RemoveTopLevelSeqEntry(seh);
                    streampos = is->GetStreamPos();
                }
            }
        }
    }

    m_Os->flush();

    is.reset();
    return 0;
}
Exemplo n.º 9
0
END_NCBI_SCOPE


int main(int argc, const char* argv[])
{
    USING_NCBI_SCOPE;
    TFTP_Flags flag = 0;
    SConnNetInfo* net_info;
    auto_ptr<CNcbiRegistry> reg;
    size_t i, j, k, l, m, n, size;

    reg.reset(s_CreateRegistry());
    CONNECT_Init(reg.get());

    // Set error posting and tracing on maximum
    SetDiagTrace(eDT_Enable);
    SetDiagPostLevel(eDiag_Info);
    SetDiagPostAllFlags(SetDiagPostAllFlags(eDPF_Default)
                        | eDPF_All | eDPF_OmitInfoSev);
    UnsetDiagPostFlag(eDPF_Line);
    UnsetDiagPostFlag(eDPF_File);
    UnsetDiagPostFlag(eDPF_Location);
    UnsetDiagPostFlag(eDPF_LongFilename);
    SetDiagTraceAllFlags(SetDiagPostAllFlags(eDPF_Default));

    if (argc <= 1)
        g_NCBI_ConnectRandomSeed = (int) time(0) ^ NCBI_CONNECT_SRAND_ADDEND;
    else
        g_NCBI_ConnectRandomSeed = atoi(argv[1]);
    CORE_LOGF(eLOG_Note, ("Random SEED = %u", g_NCBI_ConnectRandomSeed));
    srand(g_NCBI_ConnectRandomSeed);


    LOG_POST(Info << "Test 0 of 9: Checking error log setup");
    ERR_POST(Info << "Test log message using C++ Toolkit posting");
    CORE_LOG(eLOG_Note, "Another test message using C Toolkit posting");
    LOG_POST(Info << "Test 0 passed\n");


    LOG_POST(Info << "Test 1 of 9: Memory stream");
    // Testing memory stream out-of-sequence interleaving operations
    m = (rand() & 0x00FF) + 1;
    size = 0;
    const IOS_BASE::iostate ex = IOS_BASE::badbit;
    for (n = 0;  n < m;  n++) {
        CConn_MemoryStream* ms = 0;
        string data, back;
        size_t sz = 0;
#if 0
        LOG_POST(Info << "  Micro-test " << (int) n << " of "
                 << (int) m << " start");
#endif
        k = (rand() & 0x00FF) + 1;
        for (i = 0;  i < k;  i++) {
            l = (rand() & 0x00FF) + 1;
            string bit;
            bit.resize(l);
            for (j = 0;  j < l;  j++) {
                bit[j] = "0123456789"[rand() % 10];
            }
#if 0
            LOG_POST(Info << "    Data bit at " << (unsigned long) sz << ", "
                     << (unsigned long) l << " byte(s) long: " << bit);
#endif
            sz += l;
            data += bit;
            if (ms)
                assert(*ms << bit);
            else if (i == 0) {
                switch (n % 4) {
                case 0:
#if 0
                    LOG_POST(Info << "  CConn_MemoryStream()");
#endif
                    ms = new CConn_MemoryStream;
                    ms->exceptions(ex);
                    assert(*ms << bit);
                    break;
                case 1:
                {{
                    BUF buf = 0;
                    assert(BUF_Write(&buf, bit.data(), l));
#if 0
                    LOG_POST(Info << "  CConn_MemoryStream(BUF)");
#endif
                    ms = new CConn_MemoryStream(buf, eTakeOwnership);
                    ms->exceptions(ex);
                    break;
                }}
                default:
                    break;
                }
            }
        }
        switch (n % 4) {
        case 2:
#if 0
            LOG_POST(Info << "  CConn_MemoryStream("
                     << (unsigned long) data.size() << ')');
#endif
            ms = new CConn_MemoryStream(data.data(),data.size(), eNoOwnership);
            break;
        case 3:
        {{
            BUF buf = 0;
            assert(BUF_Append(&buf, data.data(), data.size()));
#if 0
            LOG_POST(Info << "  CConn_MemoryStream(BUF, "
                     << (unsigned long) data.size() << ')');
#endif
            ms = new CConn_MemoryStream(buf, eTakeOwnership);
            break;
        }}
        default:
            break;
        }
        assert(ms);
        if (!(rand() & 1)) {
            assert(*ms << endl);
            *ms >> back;
            IOS_BASE::iostate state = ms->rdstate();
            assert(state == IOS_BASE::goodbit);
            SetDiagTrace(eDT_Disable);
            ms->exceptions(ex | IOS_BASE::eofbit);
            try {
                *ms >> ws;
            } catch (IOS_BASE::failure& ) {
                state = ms->rdstate();
            }
#if defined(NCBI_COMPILER_GCC)
#  if NCBI_COMPILER_VERSION == 510 && (!defined(_GLIBCXX_USE_CXX11_ABI)  ||  _GLIBCXX_USE_CXX11_ABI != 0)
            catch (...) {
                // WORKAROUND:
                //   At least GCC 5.1.0 in optimized mode and using new ABI:
                //   fails to catch "IOS_BASE::failure" above.
                state = ms->rdstate();
            }
#  endif
#endif
            _ASSERT(state & IOS_BASE::eofbit);
            SetDiagTrace(eDT_Enable);
            ms->clear();
        } else
Exemplo n.º 10
0
END_NCBI_SCOPE


int main(int argc, const char* argv[])
{
    USING_NCBI_SCOPE;
    CNcbiRegistry* reg;
    TFTP_Flags flag = 0;
    SConnNetInfo* net_info;
    size_t i, j, k, l, m, n, size;

    reg = s_CreateRegistry();
    CONNECT_Init(reg);

    // Set error posting and tracing on maximum
    SetDiagTrace(eDT_Enable);
    SetDiagPostLevel(eDiag_Info);
    SetDiagPostAllFlags(eDPF_All | eDPF_OmitInfoSev);
    UnsetDiagPostFlag(eDPF_Line);
    UnsetDiagPostFlag(eDPF_File);
    UnsetDiagPostFlag(eDPF_Location);
    UnsetDiagPostFlag(eDPF_LongFilename);
    SetDiagTraceAllFlags(SetDiagPostAllFlags(eDPF_Default));

    if (argc <= 1)
        g_NCBI_ConnectRandomSeed = (int) time(0) ^ NCBI_CONNECT_SRAND_ADDEND;
    else
        g_NCBI_ConnectRandomSeed = atoi(argv[1]);
    CORE_LOGF(eLOG_Note, ("Random SEED = %u", g_NCBI_ConnectRandomSeed));
    srand(g_NCBI_ConnectRandomSeed);


    LOG_POST(Info << "Test 0 of 9: Checking error log setup");
    ERR_POST(Info << "Test log message using C++ Toolkit posting");
    CORE_LOG(eLOG_Note, "Another test message using C Toolkit posting");
    LOG_POST(Info << "Test 0 passed\n");


    LOG_POST("Test 1 of 9: Memory stream");
    // Testing memory stream out-of-sequence interleaving operations
    m = (rand() & 0x00FF) + 1;
    size = 0;
    for (n = 0;  n < m;  n++) {
        CConn_MemoryStream* ms = 0;
        string data, back;
        size_t sz = 0;
#if 0
        LOG_POST("  Micro-test " << (int) n << " of " << (int) m << " start");
#endif
        k = (rand() & 0x00FF) + 1;
        for (i = 0;  i < k;  i++) {
            l = (rand() & 0x00FF) + 1;
            string bit;
            bit.resize(l);
            for (j = 0;  j < l;  j++) {
                bit[j] = "0123456789"[rand() % 10];
            }
#if 0
            LOG_POST("    Data bit at " << (unsigned long) sz <<
                     ", " << (unsigned long) l << " byte(s) long: " << bit);
#endif
            sz += l;
            data += bit;
            if (ms)
                assert(*ms << bit);
            else if (i == 0) {
                switch (n % 4) {
                case 0:
#if 0
                    LOG_POST("  CConn_MemoryStream()");
#endif
                    ms = new CConn_MemoryStream;
                    assert(*ms << bit);
                    break;
                case 1:
                {{
                    BUF buf = 0;
                    assert(BUF_Write(&buf, bit.data(), l));
#if 0
                    LOG_POST("  CConn_MemoryStream(BUF)");
#endif
                    ms = new CConn_MemoryStream(buf, eTakeOwnership);
                    break;
                }}
                default:
                    break;
                }
            }
        }
        switch (n % 4) {
        case 2:
#if 0
            LOG_POST("  CConn_MemoryStream(" <<
                     (unsigned long) data.size() << ')');
#endif
            ms = new CConn_MemoryStream(data.data(),data.size(), eNoOwnership);
            break;
        case 3:
        {{
            BUF buf = 0;
            assert(BUF_Append(&buf, data.data(), data.size()));
#if 0
            LOG_POST("  CConn_MemoryStream(BUF, " <<
                     (unsigned long) data.size() << ')');
#endif
            ms = new CConn_MemoryStream(buf, eTakeOwnership);
            break;
        }}
        default:
            break;
        }
        assert(ms);
        if (!(rand() & 1)) {
            assert(*ms << endl);
            *ms >> back;
            assert(ms->good());
            SetDiagTrace(eDT_Disable);
            *ms >> ws;
            SetDiagTrace(eDT_Enable);
            ms->clear();
        } else