diff options
Diffstat (limited to 'cpp')
56 files changed, 1069 insertions, 696 deletions
diff --git a/cpp/allTests.py b/cpp/allTests.py index 844bb1b9e44..c93dc9f1747 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -38,6 +38,7 @@ tests = [ ("Slice/structure", ["once"]), ("Slice/macros", ["once"]), ("Slice/headers", ["once", "nowin32"]), + ("Slice/unicodePaths", ["once"]), ("Ice/properties", ["once", "nomingw"]), ("Ice/proxy", ["core", "bt"]), ("Ice/operations", ["core", "bt"]), diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h index ca711546141..94c31eeff25 100644 --- a/cpp/include/IceUtil/Config.h +++ b/cpp/include/IceUtil/Config.h @@ -64,31 +64,37 @@ #endif +#ifdef _MSC_VER -// -// Use system headers as preferred way to detect 32 or 64 bit mode and -// fallback to architecture based checks -// -#include <stdint.h> - -#if defined(__WORDSIZE) && (__WORDSIZE == 64) -# define ICE_64 -#elif defined(__WORDSIZE) && (__WORDSIZE == 32) -# define ICE_32 -#elif defined(__sun) && (defined(__sparcv9) || defined(__x86_64)) || \ - defined(__linux) && defined(__x86_64) || \ - defined(__APPLE__) && defined(__x86_64) || \ - defined(__hppa) && defined(__LP64__) || \ - defined(_ARCH_COM) && defined(__64BIT__) || \ - defined(__alpha__) || \ - defined(_WIN64) - -# define ICE_64 +# ifdef _WIN64 +# define ICE_64 +# else +# define ICE_32 +# endif #else -# define ICE_32 - + // + // Use system headers as preferred way to detect 32 or 64 bit mode and + // fallback to architecture based checks + // +# include <stdint.h> + +# if defined(__WORDSIZE) && (__WORDSIZE == 64) +# define ICE_64 +# elif defined(__WORDSIZE) && (__WORDSIZE == 32) +# define ICE_32 +# elif defined(__sun) && (defined(__sparcv9) || defined(__x86_64)) || \ + defined(__linux) && defined(__x86_64) || \ + defined(__APPLE__) && defined(__x86_64) || \ + defined(__hppa) && defined(__LP64__) || \ + defined(_ARCH_COM) && defined(__64BIT__) || \ + defined(__alpha__) || \ + defined(_WIN64) +# define ICE_64 +# else +# define ICE_32 +# endif #endif // diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp index a63f700e342..91b5e05db6f 100644 --- a/cpp/src/Glacier2/SessionRouterI.cpp +++ b/cpp/src/Glacier2/SessionRouterI.cpp @@ -80,7 +80,7 @@ public: // Close the connection otherwise the peer has no way to know that // the session has gone. // - _connection->close(false); + _connection->close(true); _router->destroySession(_connection); } } @@ -922,7 +922,7 @@ SessionRouterI::refreshSession(const Ice::ConnectionPtr& con) // Close the connection otherwise the peer has no way to know that the // session has gone. // - con->close(false); + con->close(true); throw SessionNotExistException(); } } diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp index 8cb221fbfce..d70e14bd74a 100644 --- a/cpp/src/Ice/DynamicLibrary.cpp +++ b/cpp/src/Ice/DynamicLibrary.cpp @@ -15,6 +15,10 @@ # include <dlfcn.h> #endif +#if defined(ICE_CPP11) && defined(__GNUC__) && (__GNUC__ < 6) && defined(__GLIBCXX__) +# define ICE_LIBSUFFIX "++11" +#endif + using namespace Ice; using namespace IceInternal; using namespace std; diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index 412e8e0ca8c..c1a1cde9335 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -6,7 +6,7 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -// Generated by makeprops.py from file ./config/PropertyNames.xml, Thu Aug 18 20:28:56 2016 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Wed Oct 5 19:04:47 2016 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -1008,7 +1008,7 @@ const IceInternal::Property IceSSLPropsData[] = IceInternal::Property("IceSSL.DHParams", false, 0), IceInternal::Property("IceSSL.EntropyDaemon", false, 0), IceInternal::Property("IceSSL.FindCert", false, 0), - IceInternal::Property("IceSSL.FindCert.*", true, "IceSSL.FindCert"), + IceInternal::Property("IceSSL.FindCert.*", true, 0), IceInternal::Property("IceSSL.InitOpenSSL", false, 0), IceInternal::Property("IceSSL.KeyFile", true, 0), IceInternal::Property("IceSSL.Keychain", false, 0), diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index ee9c805955c..52e12f92225 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -6,7 +6,7 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -// Generated by makeprops.py from file ./config/PropertyNames.xml, Thu Aug 18 20:28:56 2016 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Wed Oct 5 19:04:47 2016 // IMPORTANT: Do not edit this file -- any edits made here will be lost! diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp index de544ef43b1..8c0d04cd911 100644 --- a/cpp/src/IceGrid/Util.cpp +++ b/cpp/src/IceGrid/Util.cpp @@ -16,7 +16,7 @@ using namespace std; using namespace Ice; using namespace IceGrid; -string +string IceGrid::toString(const vector<string>& v, const string& sep) { ostringstream os; @@ -61,7 +61,7 @@ IceGrid::toString(const Ice::Exception& exception) string IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name, const string& def) -{ +{ string result; for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) { @@ -79,7 +79,7 @@ IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name int IceGrid::getPropertyAsInt(const PropertyDescriptorSeq& properties, const string& name, int def) -{ +{ string strVal; for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) { @@ -88,7 +88,7 @@ IceGrid::getPropertyAsInt(const PropertyDescriptorSeq& properties, const string& strVal = q->value; } } - + int result = def; if(!strVal.empty()) @@ -104,7 +104,7 @@ IceGrid::getPropertyAsInt(const PropertyDescriptorSeq& properties, const string& bool IceGrid::hasProperty(const PropertyDescriptorSeq& properties, const string& name) -{ +{ for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) { if(q->name == name) @@ -156,7 +156,7 @@ IceGrid::escapeProperty(const string& s, bool escapeEqual) previousCharIsEscape = false; break; } - + case '\\': case '#': case '=': @@ -212,7 +212,7 @@ IceGrid::toObjectInfo(const Ice::CommunicatorPtr& communicator, const ObjectDesc { proxyStr << ' ' << obj.proxyOptions; } - proxyStr << " @ " << adapterId; + proxyStr << " @ \"" << adapterId << "\""; try { info.proxy = communicator->stringToProxy(proxyStr.str()); @@ -220,7 +220,7 @@ IceGrid::toObjectInfo(const Ice::CommunicatorPtr& communicator, const ObjectDesc catch(const Ice::ProxyParseException&) { ostringstream fallbackProxyStr; - fallbackProxyStr << "\"" << identityToString(obj.id) << "\"" << " @ " << adapterId; + fallbackProxyStr << "\"" << identityToString(obj.id) << "\"" << " @ \"" << adapterId << "\""; info.proxy = communicator->stringToProxy(fallbackProxyStr.str()); } return info; @@ -246,7 +246,7 @@ IceGrid::setupThreadPool(const PropertiesPtr& properties, const string& name, in { sizeMax = size * 10; } - + ostringstream os; os << sizeMax; properties->setProperty(name + ".SizeMax", os.str()); @@ -277,7 +277,7 @@ IceGrid::getMMVersion(const string& o) } if(patchPos != string::npos) - { + { if((minorPos == 1 && patchPos != 3 && patchPos != 4) || (minorPos == 2 && patchPos != 4 && patchPos != 5)) { return -1; @@ -326,6 +326,6 @@ IceGrid::getMMVersion(const string& o) // } // ver += v; // } - + return ver; } diff --git a/cpp/src/IcePatch2Lib/ClientUtil.cpp b/cpp/src/IcePatch2Lib/ClientUtil.cpp index 07c30450029..66d315f8a6b 100644 --- a/cpp/src/IcePatch2Lib/ClientUtil.cpp +++ b/cpp/src/IcePatch2Lib/ClientUtil.cpp @@ -863,8 +863,14 @@ PatcherI::updateFilesInternal(const LargeFileInfoSeq& files, const DecompressorP throw ": cannot write `" + pathBZ2 + "':\n" + IceUtilInternal::lastErrorToString(); } - pos += bytes.size(); - updated += bytes.size(); + // 'bytes' is always returned with size '_chunkSize'. When a file is smaller than '_chunkSize' + // or we are reading the last chunk of a file, 'bytes' will be larger than necessary. In this + // case we calculate the current position and updated size based on the known file size. + size_t size = (pos + bytes.size()) > static_cast<size_t>(p->size) ? + static_cast<size_t>(p->size - pos) : bytes.size(); + + pos += size; + updated += size; if(!_feedback->patchProgress(pos, p->size, updated, total)) { diff --git a/cpp/src/IceSSL/OpenSSLEngine.cpp b/cpp/src/IceSSL/OpenSSLEngine.cpp index 5fc4de1604b..84238614220 100644 --- a/cpp/src/IceSSL/OpenSSLEngine.cpp +++ b/cpp/src/IceSSL/OpenSSLEngine.cpp @@ -474,37 +474,6 @@ OpenSSLEngine::initialize() } } - if(!file && !dir) - { - // Deprecated properties - path = properties->getProperty(propPrefix + "CertAuthFile"); - if(!path.empty()) - { - if(!checkPath(path, defaultDir, false, resolved)) - { - throw PluginInitializationException(__FILE__, __LINE__, - "IceSSL: CA certificate file not found:\n" + path); - } - path = resolved; - file = path.c_str(); - } - else - { - path = properties->getProperty(propPrefix + "CertAuthDir"); - if(!path.empty()) - { - if(!checkPath(path, defaultDir, true, resolved)) - { - throw PluginInitializationException(__FILE__, __LINE__, - "IceSSL: CA certificate directory not found:\n" + - path); - } - path = resolved; - dir = path.c_str(); - } - } - } - if(file || dir) { // diff --git a/cpp/src/IceStorm/IceStormInternal.ice b/cpp/src/IceStorm/IceStormInternal.ice index 32b010fe87d..bafb51717fa 100644 --- a/cpp/src/IceStorm/IceStormInternal.ice +++ b/cpp/src/IceStorm/IceStormInternal.ice @@ -39,6 +39,10 @@ module IceStorm Ice::Context context; }; +local exception SendQueueSizeMaxReached +{ +}; + /** A sequence of EventData. */ ["cpp:type:std::deque< ::IceStorm::EventDataPtr>"] sequence<EventData> EventDataSeq; diff --git a/cpp/src/IceStorm/Instance.cpp b/cpp/src/IceStorm/Instance.cpp index 5dd876da63e..6d8334cab4d 100644 --- a/cpp/src/IceStorm/Instance.cpp +++ b/cpp/src/IceStorm/Instance.cpp @@ -17,6 +17,7 @@ #include <Ice/InstrumentationI.h> #include <Ice/Communicator.h> #include <Ice/Properties.h> +#include <Ice/TraceUtil.h> using namespace std; using namespace IceStorm; @@ -110,6 +111,8 @@ Instance::Instance( name + ".Flush.Timeout", 1000))), // default one second. // default one minute. _sendTimeout(communicator->getProperties()->getPropertyAsIntWithDefault(name + ".Send.Timeout", 60 * 1000)), + _sendQueueSizeMax(communicator->getProperties()->getPropertyAsIntWithDefault(name + ".Send.QueueSizeMax", -1)), + _sendQueueSizeMaxPolicy(RemoveSubscriber), _topicReaper(new TopicReaper()) { try @@ -134,6 +137,21 @@ Instance::Instance( _batchFlusher = new IceUtil::Timer(); _timer = new IceUtil::Timer(); + string policy = properties->getProperty(name + ".Send.QueueSizeMaxPolicy"); + if(policy == "RemoveSubscriber") + { + const_cast<SendQueueSizeMaxPolicy&>(_sendQueueSizeMaxPolicy) = RemoveSubscriber; + } + else if(policy == "DropEvents") + { + const_cast<SendQueueSizeMaxPolicy&>(_sendQueueSizeMaxPolicy) = DropEvents; + } + else if(!policy.empty()) + { + Ice::Warning warn(_traceLevels->logger); + warn << "invalid value `" << policy << "' for `" << name << ".Send.QueueSizeMaxPolicy'"; + } + // // If an Ice metrics observer is setup on the communicator, also // enable metrics for IceStorm. @@ -287,6 +305,18 @@ Instance::sendTimeout() const return _sendTimeout; } +int +Instance::sendQueueSizeMax() const +{ + return _sendQueueSizeMax; +} + +Instance::SendQueueSizeMaxPolicy +Instance::sendQueueSizeMaxPolicy() const +{ + return _sendQueueSizeMaxPolicy; +} + void Instance::shutdown() { @@ -320,7 +350,7 @@ Instance::destroy() _node = 0; // // The observer instance must be cleared as it holds the - // TopicManagerImpl which hodlds the instance causing a + // TopicManagerImpl which hodlds the instance causing a // cyclic reference. // _observer = 0; diff --git a/cpp/src/IceStorm/Instance.h b/cpp/src/IceStorm/Instance.h index e7e5814a598..11d1372e1b8 100644 --- a/cpp/src/IceStorm/Instance.h +++ b/cpp/src/IceStorm/Instance.h @@ -61,6 +61,12 @@ class Instance : public IceUtil::Shared { public: + enum SendQueueSizeMaxPolicy + { + RemoveSubscriber, + DropEvents + }; + Instance(const std::string&, const std::string&, const Ice::CommunicatorPtr&, const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr& = 0, const IceStormElection::NodePrx& = 0); ~Instance(); @@ -88,6 +94,8 @@ public: IceUtil::Time discardInterval() const; IceUtil::Time flushInterval() const; int sendTimeout() const; + int sendQueueSizeMax() const; + SendQueueSizeMaxPolicy sendQueueSizeMaxPolicy() const; void shutdown(); virtual void destroy(); @@ -105,6 +113,8 @@ private: const IceUtil::Time _discardInterval; const IceUtil::Time _flushInterval; const int _sendTimeout; + const int _sendQueueSizeMax; + const SendQueueSizeMaxPolicy _sendQueueSizeMaxPolicy; const Ice::ObjectPrx _topicReplicaProxy; const Ice::ObjectPrx _publisherReplicaProxy; const TopicReaperPtr _topicReaper; diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp index 9d925c9bff1..3f78ad37a25 100644 --- a/cpp/src/IceStorm/Service.cpp +++ b/cpp/src/IceStorm/Service.cpp @@ -535,6 +535,8 @@ ServiceI::validateProperties(const string& name, const PropertiesPtr& properties "Trace.Topic", "Trace.TopicManager", "Send.Timeout", + "Send.QueueSizeMax", + "Send.QueueSizeMaxPolicy", "Discard.Interval", "LMDB.Path", "LMDB.MapSize" diff --git a/cpp/src/IceStorm/Subscriber.cpp b/cpp/src/IceStorm/Subscriber.cpp index a4b89d09e1b..529461f0f03 100644 --- a/cpp/src/IceStorm/Subscriber.cpp +++ b/cpp/src/IceStorm/Subscriber.cpp @@ -227,7 +227,7 @@ void SubscriberBatch::doFlush() { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock); - + // // If the subscriber isn't online we're done. // @@ -239,7 +239,7 @@ SubscriberBatch::doFlush() EventDataSeq v; v.swap(_events); assert(!v.empty()); - + if(_observer) { _outstandingCount = static_cast<Ice::Int>(v.size()); @@ -255,7 +255,7 @@ SubscriberBatch::doFlush() } Ice::AsyncResultPtr result = _obj->begin_ice_flushBatchRequests( - Ice::newCallback_Object_ice_flushBatchRequests(this, + Ice::newCallback_Object_ice_flushBatchRequests(this, &SubscriberBatch::exception, &SubscriberBatch::sent)); if(result->sentSynchronously()) @@ -278,7 +278,7 @@ SubscriberBatch::doFlush() { _lock.notify(); } - + // This is significantly faster than the async version, but it can // block the calling thread. Bad news! @@ -294,7 +294,7 @@ SubscriberBatch::sent(bool sentSynchronously) } IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock); - + // Decrement the _outstanding count. --_outstanding; assert(_outstanding == 0); @@ -334,7 +334,7 @@ void SubscriberOneway::flush() { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock); - + // // If the subscriber isn't online we're done. // @@ -360,7 +360,7 @@ SubscriberOneway::flush() try { Ice::AsyncResultPtr result = _obj->begin_ice_invoke( - e->op, e->mode, e->data, e->context, Ice::newCallback_Object_ice_invoke(this, + e->op, e->mode, e->data, e->context, Ice::newCallback_Object_ice_invoke(this, &SubscriberOneway::exception, &SubscriberOneway::sent)); if(!result->sentSynchronously()) @@ -394,7 +394,7 @@ SubscriberOneway::sent(bool sentSynchronously) } IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock); - + // Decrement the _outstanding count. --_outstanding; assert(_outstanding >= 0 && _outstanding < _maxOutstanding); @@ -481,7 +481,7 @@ void SubscriberLink::flush() { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock); - + if(_state != SubscriberStateOnline || _outstanding > 0) { return; @@ -673,23 +673,40 @@ Subscriber::queue(bool forwarded, const EventDataSeq& events) { break; } - + // // State transition to online. // setState(SubscriberStateOnline); // fall through } - + case SubscriberStateOnline: - copy(events.begin(), events.end(), back_inserter(_events)); + { + for(EventDataSeq::const_iterator p = events.begin(); p != events.end(); ++p) + { + if(static_cast<int>(_events.size()) == _instance->sendQueueSizeMax()) + { + if(_instance->sendQueueSizeMaxPolicy() == Instance::RemoveSubscriber) + { + error(false, IceStorm::SendQueueSizeMaxReached(__FILE__, __LINE__)); + return false; + } + else // DropEvents + { + _events.pop_front(); + } + } + _events.push_back(*p); + } + if(_observer) { _observer->queued(static_cast<Ice::Int>(events.size())); } flush(); break; - + } case SubscriberStateError: return false; @@ -768,10 +785,24 @@ Subscriber::error(bool dec, const Ice::Exception& e) assert(_outstanding >= 0 && _outstanding < _maxOutstanding); } + // + // It's possible to be already in the error state if the queue maximum size + // has been reached or if an ObjectNotExistException occured before. + // + if(_state >= SubscriberStateError) + { + if(_shutdown) + { + _lock.notify(); + } + return; + } + // A hard error is an ObjectNotExistException or // NotRegisteredException. bool hardError = dynamic_cast<const Ice::ObjectNotExistException*>(&e) || - dynamic_cast<const Ice::NotRegisteredException*>(&e); + dynamic_cast<const Ice::NotRegisteredException*>(&e) || + dynamic_cast<const IceStorm::SendQueueSizeMaxReached*>(&e); // // A twoway subscriber can queue multiple send events and @@ -834,7 +865,7 @@ Subscriber::error(bool dec, const Ice::Exception& e) { _events.clear(); setState(SubscriberStateError); - + TraceLevelsPtr traceLevels = _instance->traceLevels(); if(traceLevels->subscriber > 0) { @@ -871,13 +902,13 @@ Subscriber::completed(const Ice::AsyncResultPtr& result) { _observer->delivered(_outstandingCount); } - + // // A successful response means we're no longer retrying, we're // back active. // _currentRetry = 0; - + if(_events.empty() && _outstanding == 0 && _shutdown) { _lock.notify(); @@ -893,7 +924,7 @@ Subscriber::completed(const Ice::AsyncResultPtr& result) } } - + void Subscriber::shutdown() { @@ -954,7 +985,7 @@ Subscriber::Subscriber( rec.topicName, rec.obj, rec.theQoS, - rec.theTopic, + rec.theTopic, toSubscriberState(_state), 0)); } @@ -992,7 +1023,7 @@ Subscriber::setState(Subscriber::SubscriberState state) if(traceLevels->subscriber > 1) { Ice::Trace out(traceLevels->logger, traceLevels->subscriberCat); - out << "endpoints: " << IceStormInternal::describeEndpoints(_rec.obj) + out << "endpoints: " << IceStormInternal::describeEndpoints(_rec.obj) << " transition from: " << stateToString(_state) << " to: " << stateToString(state); } _state = state; diff --git a/cpp/src/IceUtil/OutputUtil.cpp b/cpp/src/IceUtil/OutputUtil.cpp index 3e21011e511..587c720aa97 100644 --- a/cpp/src/IceUtil/OutputUtil.cpp +++ b/cpp/src/IceUtil/OutputUtil.cpp @@ -95,7 +95,7 @@ IceUtilInternal::OutputBase::open(const string& s) // mismatches on case-insensitive OSs. // IceUtilInternal::unlink(s); - _fout.open(s.c_str()); + _fout.open(IceUtilInternal::streamFilename(s).c_str()); } void @@ -172,13 +172,13 @@ IceUtilInternal::OutputBase::currIndent() return _indent; } -void +void IceUtilInternal::OutputBase::setIndent(int indentSize) { - _indentSize = indentSize; + _indentSize = indentSize; } -void +void IceUtilInternal::OutputBase::setUseTab(bool useTab) { _useTab = useTab; @@ -554,7 +554,7 @@ IceUtilInternal::StartElement::StartElement(const string& name) : _name(name) { } - + const string& IceUtilInternal::StartElement::getName() const { diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 52c72714619..ad8d3628d65 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -13,9 +13,9 @@ #include <Slice/Util.h> #include <Slice/MD5.h> #include <IceUtil/Functional.h> +#include <IceUtil/FileUtil.h> #include <sys/types.h> -#include <sys/stat.h> #include <string.h> #ifdef _WIN32 @@ -644,10 +644,8 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri path += dir.substr(start); } - struct stat st; - int result; - result = stat(path.c_str(), &st); - if(result == 0) + IceUtilInternal::structstat st; + if(!IceUtilInternal::stat(path, &st)) { if(!(st.st_mode & S_IFDIR)) { @@ -658,12 +656,8 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri } continue; } -#ifdef _WIN32 - result = _mkdir(path.c_str()); -#else - result = ::mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); -#endif - if(result != 0) + + if(IceUtilInternal::mkdir(path, 0777) != 0) { ostringstream os; os << "cannot create directory `" << path << "': " << strerror(errno); diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 6a32037af44..c8e49029f25 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -741,7 +741,7 @@ Slice::Preprocessor::checkInputFile() return false; } - ifstream test(_fileName.c_str()); + ifstream test(IceUtilInternal::streamFilename(_fileName).c_str()); if(!test) { getErrorStream() << _path << ": error: cannot open `" << _fileName << "' for reading" << endl; diff --git a/cpp/src/Slice/Python.cpp b/cpp/src/Slice/Python.cpp index 4343456efb2..73a470260c4 100644 --- a/cpp/src/Slice/Python.cpp +++ b/cpp/src/Slice/Python.cpp @@ -187,10 +187,8 @@ PackageVisitor::visitModuleEnd(const ModulePtr& p) void PackageVisitor::createDirectory(const string& dir) { - struct stat st; - int result; - result = stat(dir.c_str(), &st); - if(result == 0) + IceUtilInternal::structstat st; + if(!IceUtilInternal::stat(dir, &st)) { if(!(st.st_mode & S_IFDIR)) { @@ -201,13 +199,8 @@ PackageVisitor::createDirectory(const string& dir) } return; } -#ifdef _WIN32 - result = _mkdir(dir.c_str()); -#else - result = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); -#endif - if(result != 0) + if(IceUtilInternal::mkdir(dir, 0777) != 0) { ostringstream os; os << "cannot create directory `" << dir << "': " << strerror(errno); @@ -254,10 +247,10 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub { string initPath = dir + "/__init__.py"; - struct stat st; - if(stat(initPath.c_str(), &st) == 0) + IceUtilInternal::structstat st; + if(!IceUtilInternal::stat(initPath, &st)) { - ifstream in(initPath.c_str()); + ifstream in(IceUtilInternal::streamFilename(initPath).c_str()); if(!in) { ostringstream os; @@ -358,7 +351,7 @@ PackageVisitor::writeInit(const string& dir, const string& name, const StringLis { string initPath = dir + "/__init__.py"; - ofstream os(initPath.c_str()); + ofstream os(IceUtilInternal::streamFilename(initPath).c_str()); if(!os) { ostringstream os; @@ -388,7 +381,7 @@ PackageVisitor::writeInit(const string& dir, const string& name, const StringLis } void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; getErrorStream() << @@ -416,7 +409,7 @@ usage(const char* n) } int -Slice::Python::compile(int argc, char* argv[]) +Slice::Python::compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -441,7 +434,7 @@ Slice::Python::compile(int argc, char* argv[]) vector<string> args; try { - args = opts.parse(argc, const_cast<const char**>(argv)); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { diff --git a/cpp/src/Slice/PythonUtil.h b/cpp/src/Slice/PythonUtil.h index 807fcfa1561..9d48b3d3871 100644 --- a/cpp/src/Slice/PythonUtil.h +++ b/cpp/src/Slice/PythonUtil.h @@ -56,7 +56,7 @@ std::string getAbsolute(const Slice::ContainedPtr&, const std::string& = "", con // void printHeader(IceUtilInternal::Output&); -int compile(int, char*[]); +int compile(const std::vector<std::string>&); } } diff --git a/cpp/src/Slice/Ruby.cpp b/cpp/src/Slice/Ruby.cpp index 209711a679d..799e72c264b 100644 --- a/cpp/src/Slice/Ruby.cpp +++ b/cpp/src/Slice/Ruby.cpp @@ -56,10 +56,10 @@ interruptedCallback(int /*signal*/) } void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; - getErrorStream() << + getErrorStream() << "Options:\n" "-h, --help Show this message.\n" "-v, --version Display the Ice version.\n" @@ -83,7 +83,7 @@ usage(const char* n) } int -Slice::Ruby::compile(int argc, char* argv[]) +Slice::Ruby::compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -101,11 +101,11 @@ Slice::Ruby::compile(int argc, char* argv[]) opts.addOpt("", "underscore"); opts.addOpt("", "all"); opts.addOpt("", "checksum"); - + vector<string> args; try { - args = opts.parse(argc, const_cast<const char**>(argv)); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -222,7 +222,7 @@ Slice::Ruby::compile(int argc, char* argv[]) return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Ruby : Preprocessor::SliceXML, includePaths, + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Ruby : Preprocessor::SliceXML, includePaths, "-D__SLICE2RB__")) { out.cleanup(); diff --git a/cpp/src/Slice/RubyUtil.h b/cpp/src/Slice/RubyUtil.h index 3acae195d9c..e67ecd1b623 100644 --- a/cpp/src/Slice/RubyUtil.h +++ b/cpp/src/Slice/RubyUtil.h @@ -46,7 +46,7 @@ std::string getAbsolute(const Slice::ContainedPtr&, IdentStyle, const std::strin // void printHeader(IceUtilInternal::Output&); -int compile(int, char*[]); +int compile(const std::vector<std::string>&); } } diff --git a/cpp/src/Slice/SliceUtil.cpp b/cpp/src/Slice/SliceUtil.cpp index e0c490fa937..cdef47244c6 100644 --- a/cpp/src/Slice/SliceUtil.cpp +++ b/cpp/src/Slice/SliceUtil.cpp @@ -431,3 +431,27 @@ Slice::DependOutputUtil::os() { return _file.empty() ? cout : _os; } + +#ifdef _WIN32 +vector<string> +Slice::argvToArgs(int argc, wchar_t* argv[]) +{ + vector<string> args; + for(int i = 0; i < argc; i++) + { + args.push_back(IceUtil::wstringToString(argv[i])); + } + return args; +} +#else +vector<string> +Slice::argvToArgs(int argc, char* argv[]) +{ + vector<string> args; + for(int i = 0; i < argc; i++) + { + args.push_back(argv[i]); + } + return args; +} +#endif diff --git a/cpp/src/Slice/Util.h b/cpp/src/Slice/Util.h index a2ec69a87a2..fdf84a1290e 100644 --- a/cpp/src/Slice/Util.h +++ b/cpp/src/Slice/Util.h @@ -30,6 +30,12 @@ void emitWarning(const std::string&, const std::string&, const std::string&); void emitRaw(const char*); std::vector<std::string> filterMcppWarnings(const std::string&); void printGeneratedHeader(IceUtilInternal::Output& out, const std::string&, const std::string& commentStyle = "//"); +#ifdef _WIN32 +std::vector<std::string> argvToArgs(int argc, wchar_t* argv[]); +#else +std::vector<std::string> argvToArgs(int argc, char* argv[]); +#endif + class DependOutputUtil : IceUtil::noncopyable { diff --git a/cpp/src/slice2confluence/Gen.cpp b/cpp/src/slice2confluence/Gen.cpp index f62bd1f6fb8..dd7175133f1 100644 --- a/cpp/src/slice2confluence/Gen.cpp +++ b/cpp/src/slice2confluence/Gen.cpp @@ -9,16 +9,16 @@ #include <IceUtil/Functional.h> #include <IceUtil/StringUtil.h> +#include <IceUtil/FileUtil.h> #include <Slice/FileTracker.h> #include <Gen.h> #include <string.h> #include <sys/types.h> -#include <sys/stat.h> #ifdef _WIN32 -#include <direct.h> +# include <direct.h> #else -#include <unistd.h> +# include <unistd.h> #endif #include <iterator> @@ -1780,8 +1780,7 @@ void Slice::GeneratorBase::makeDir(const string& dir) { struct stat st; - int rc = stat(dir.c_str(), &st); - if(rc == 0) + if(!IceUtilInternal::stat(dir, &st)) { if(!(st.st_mode & S_IFDIR)) { @@ -1793,12 +1792,7 @@ Slice::GeneratorBase::makeDir(const string& dir) return; } -#ifdef _WIN32 - rc = _mkdir(dir.c_str()); -#else - rc = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); -#endif - if(rc != 0) + if(IceUtilInternal::mkdir(dir, 0777) != 0) { ostringstream os; os << "cannot create directory `" << dir << "': " << strerror(errno); diff --git a/cpp/src/slice2confluence/Main.cpp b/cpp/src/slice2confluence/Main.cpp index 885c58819ab..8bf3cd85ba5 100644 --- a/cpp/src/slice2confluence/Main.cpp +++ b/cpp/src/slice2confluence/Main.cpp @@ -78,7 +78,7 @@ interruptedCallback(int signal) } void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; getErrorStream() << @@ -109,7 +109,7 @@ usage(const char* n) } int -compile(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -134,20 +134,11 @@ compile(int argc, char* argv[]) opts.addOpt("", "ice"); opts.addOpt("", "underscore"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } - + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string> args; try { - args = opts.parse(argc, (const char**)argv); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -364,31 +355,35 @@ compile(int argc, char* argv[]) return status; } -int -main(int argc, char* argv[]) +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif { + vector<string> args = Slice::argvToArgs(argc, argv); try { - return compile(argc, argv); + return compile(args); } catch(const std::exception& ex) { - getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + getErrorStream() << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index ca06c64219c..140438eb37e 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -18,10 +18,9 @@ #include <IceUtil/StringUtil.h> #include <Slice/Checksum.h> #include <Slice/FileTracker.h> +#include <IceUtil/FileUtil.h> #include <limits> - -#include <sys/stat.h> #include <string.h> using namespace std; @@ -725,14 +724,14 @@ Slice::Gen::generate(const UnitPtr& p) fileImplC = _dir + '/' + fileImplC; } - struct stat st; - if(stat(fileImplH.c_str(), &st) == 0) + IceUtilInternal::structstat st; + if(!IceUtilInternal::stat(fileImplH, &st)) { ostringstream os; os << fileImplH << "' already exists - will not overwrite"; throw FileException(__FILE__, __LINE__, os.str()); } - if(stat(fileImplC.c_str(), &st) == 0) + if(!IceUtilInternal::stat(fileImplC, &st)) { ostringstream os; os << fileImplC << "' already exists - will not overwrite"; diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 66e9bcf2269..27376433b57 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -54,7 +54,7 @@ interruptedCallback(int /*signal*/) } void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; getErrorStream() << @@ -86,7 +86,7 @@ usage(const char* n) } int -compile(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -112,20 +112,11 @@ compile(int argc, char* argv[]) opts.addOpt("", "underscore"); opts.addOpt("", "checksum"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } - + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string> args; try { - args = opts.parse(argc, const_cast<const char**>(argv)); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -374,31 +365,35 @@ compile(int argc, char* argv[]) return status; } -int -main(int argc, char* argv[]) +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif { + vector<string> args = Slice::argvToArgs(argc, argv); try { - return compile(argc, argv); + return compile(args); } catch(const std::exception& ex) { - getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + getErrorStream() << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 5fa82827c4f..313c04ea229 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -11,15 +11,14 @@ #include <IceUtil/Functional.h> #include <IceUtil/StringUtil.h> #include <IceUtil/InputUtil.h> +#include <IceUtil/FileUtil.h> #include <Gen.h> #include <limits> -#include <sys/stat.h> - #ifndef _WIN32 -# include <unistd.h> +# include <unistd.h> #else -# include <direct.h> +# include <direct.h> #endif #include <IceUtil/Iterator.h> @@ -2165,8 +2164,8 @@ Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const st if(impl || implTie) { - struct stat st; - if(stat(fileImpl.c_str(), &st) == 0) + IceUtilInternal::structstat st; + if(!IceUtilInternal::stat(fileImpl, &st)) { ostringstream os; os << "`" << fileImpl << "' already exists - will not overwrite"; @@ -5684,7 +5683,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string name = p->name(); - _out << sp << nl << "public sealed class " << name << 'I'; + _out << sp << nl << "public class " << name << 'I'; if(p->isInterface()) { if(p->isLocal()) diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index 73a9027689b..2268eb1fa0a 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -54,7 +54,7 @@ interruptedCallback(int /*signal*/) } void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; getErrorStream() << @@ -82,7 +82,7 @@ usage(const char* n) } int -compile(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -104,20 +104,11 @@ compile(int argc, char* argv[]) opts.addOpt("", "underscore"); opts.addOpt("", "checksum"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } - + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string> args; try { - args = opts.parse(argc, const_cast<const char**>(argv)); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -372,31 +363,35 @@ compile(int argc, char* argv[]) return status; } -int -main(int argc, char* argv[]) +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif { + vector<string> args = Slice::argvToArgs(argc, argv); try { - return compile(argc, argv); + return compile(args); } catch(const std::exception& ex) { - getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + getErrorStream() << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp index 03e87cefec9..a5e03d6015f 100644 --- a/cpp/src/slice2html/Gen.cpp +++ b/cpp/src/slice2html/Gen.cpp @@ -10,20 +10,19 @@ #include <IceUtil/DisableWarnings.h> #include <IceUtil/Functional.h> #include <IceUtil/StringUtil.h> +#include <IceUtil/FileUtil.h> #include <Slice/FileTracker.h> #include <Gen.h> #include <sys/types.h> -#include <sys/stat.h> #ifdef _WIN32 -#include <direct.h> +# include <direct.h> #else -#include <unistd.h> +# include <unistd.h> #endif #include <iterator> - #include <string.h> using namespace std; @@ -352,7 +351,7 @@ Slice::GeneratorBase::printComment(const ContainedPtr& p, const SyntaxTreeBasePt { item = q->substr(pos); } - + start("dt", "Symbol"); _out << term; end(); @@ -393,7 +392,7 @@ Slice::GeneratorBase::printComment(const ContainedPtr& p, const SyntaxTreeBasePt { item = q->substr(pos); } - + start("dt", "Symbol"); _out << getURL(toSliceID(term, source->definitionContext()->filename()), source, false); end(); @@ -1316,14 +1315,14 @@ Slice::GeneratorBase::getTagged(const string& tag, string& comment) { return result; } - + string::size_type pos1 = comment.find_first_not_of(" \t\r\n", begin + tag.size() + 1); if(pos1 == string::npos) { comment.erase(begin); return result; } - + string::size_type pos2 = comment.find('@', pos1); string line = comment.substr(pos1, pos2 - pos1); comment.erase(begin, pos2 - 1 - begin); @@ -1357,7 +1356,7 @@ Slice::GeneratorBase::getScopedMinimized(const SyntaxTreeBasePtr& target, const { return scoped.substr(2); } - + do { string scoped2 = s->scoped(); @@ -1559,9 +1558,8 @@ Slice::GeneratorBase::toStringList(const string& scoped) void Slice::GeneratorBase::makeDir(const string& dir) { - struct stat st; - int rc = stat(dir.c_str(), &st); - if(rc == 0) + IceUtilInternal::structstat st; + if(!IceUtilInternal::stat(dir, &st)) { if(!(st.st_mode & S_IFDIR)) { @@ -1573,12 +1571,7 @@ Slice::GeneratorBase::makeDir(const string& dir) return; } -#ifdef _WIN32 - rc = _mkdir(dir.c_str()); -#else - rc = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); -#endif - if(rc != 0) + if(IceUtilInternal::mkdir(dir, 0777) != 0) { ostringstream os; os << "cannot create directory `" << dir << "': " << strerror(errno); @@ -1590,7 +1583,7 @@ Slice::GeneratorBase::makeDir(const string& dir) string Slice::GeneratorBase::readFile(const string& file) { - ifstream in(file.c_str()); + ifstream in(streamFilename(file).c_str()); if(!in) { ostringstream os; @@ -1606,7 +1599,7 @@ Slice::GeneratorBase::readFile(const string& file) result << line << '\n'; getline(in, line); } - + return result.str(); } @@ -1664,7 +1657,7 @@ Slice::GeneratorBase::getFooter(const string& footer) void Slice::GeneratorBase::readFile(const string& file, string& part1, string& part2) { - ifstream in(file.c_str()); + ifstream in(streamFilename(file).c_str()); if(!in) { ostringstream os; @@ -2568,7 +2561,7 @@ Slice::ExceptionGenerator::generate(const ExceptionPtr& e) } end(); } - + _out << nl << "<hr>"; printHeaderFooter(e); @@ -2894,7 +2887,7 @@ Slice::StructGenerator::generate(const StructPtr& s) } end(); } - + _out << nl << "<hr>"; printHeaderFooter(s); @@ -2973,7 +2966,7 @@ Slice::EnumGenerator::generate(const EnumPtr& e) } end(); } - + closeDoc(); _out << nl << "<hr>"; diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp index 0b9a0b24590..818882ceb61 100644 --- a/cpp/src/slice2html/Main.cpp +++ b/cpp/src/slice2html/Main.cpp @@ -56,7 +56,7 @@ interruptedCallback(int /*signal*/) } void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; getErrorStream() << @@ -86,7 +86,7 @@ usage(const char* n) } int -compile(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -110,20 +110,11 @@ compile(int argc, char* argv[]) opts.addOpt("", "ice"); opts.addOpt("", "underscore"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } - + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string> args; try { - args = opts.parse(argc, const_cast<const char**>(argv)); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -336,31 +327,35 @@ compile(int argc, char* argv[]) return status; } -int -main(int argc, char* argv[]) +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif { + vector<string> args = argvToArgs(argc, argv); try { - return compile(argc, argv); + return compile(args); } catch(const std::exception& ex) { - getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + getErrorStream() << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index c92a4264d71..d864279a544 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -56,7 +56,7 @@ interruptedCallback(int /*signal*/) } void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; getErrorStream() << @@ -87,7 +87,7 @@ usage(const char* n) } int -compile(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -112,19 +112,11 @@ compile(int argc, char* argv[]) opts.addOpt("", "meta", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); opts.addOpt("", "compat"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string>args; try { - args = opts.parse(argc, const_cast<const char**>(argv)); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -485,31 +477,35 @@ compile(int argc, char* argv[]) return status; } -int -main(int argc, char* argv[]) +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif { + vector<string> args = argvToArgs(argc, argv); try { - return compile(argc, argv); + return compile(args); } catch(const std::exception& ex) { - getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + getErrorStream() << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } diff --git a/cpp/src/slice2js/Main.cpp b/cpp/src/slice2js/Main.cpp index da15f8b1064..862e1343e02 100644 --- a/cpp/src/slice2js/Main.cpp +++ b/cpp/src/slice2js/Main.cpp @@ -54,7 +54,7 @@ interruptedCallback(int /*signal*/) } void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; getErrorStream() << @@ -80,7 +80,7 @@ usage(const char* n) } int -compile(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -100,20 +100,12 @@ compile(int argc, char* argv[]) opts.addOpt("", "ice"); opts.addOpt("", "underscore"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string> args; try { - args = opts.parse(argc, const_cast<const char**>(argv)); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -393,31 +385,35 @@ compile(int argc, char* argv[]) return status; } -int -main(int argc, char* argv[]) +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif { + vector<string> args = Slice::argvToArgs(argc, argv); try { - return compile(argc, argv); + return compile(args); } catch(const std::exception& ex) { - getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + getErrorStream() << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } diff --git a/cpp/src/slice2objc/Main.cpp b/cpp/src/slice2objc/Main.cpp index 1a766772ef0..c8d68d39bf1 100644 --- a/cpp/src/slice2objc/Main.cpp +++ b/cpp/src/slice2objc/Main.cpp @@ -53,7 +53,7 @@ interruptedCallback(int signal) } void -usage(const char* n) +usage(const string& n) { cerr << "Usage: " << n << " [options] slice-files...\n"; cerr << @@ -80,7 +80,7 @@ usage(const char* n) } int -main(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -101,20 +101,12 @@ main(int argc, char* argv[]) opts.addOpt("", "underscore"); opts.addOpt("", "case-sensitive"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string> args; try { - args = opts.parse(argc, (const char**)argv); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -334,3 +326,36 @@ main(int argc, char* argv[]) return status; } + +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif +{ + vector<string> args = Slice::argvToArgs(argc, argv); + try + { + return compile(args); + } + catch(const std::exception& ex) + { + getErrorStream() << args[0] << ": error:" << ex.what() << endl; + return EXIT_FAILURE; + } + catch(const std::string& msg) + { + getErrorStream() << args[0] << ": error:" << msg << endl; + return EXIT_FAILURE; + } + catch(const char* msg) + { + getErrorStream() << args[0] << ": error:" << msg << endl; + return EXIT_FAILURE; + } + catch(...) + { + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; + return EXIT_FAILURE; + } +} diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index e6676731cdc..b0f4b4ec7cb 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -1627,7 +1627,7 @@ interruptedCallback(int /*signal*/) } static void -usage(const char* n) +usage(const string& n) { getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; getErrorStream() << @@ -1654,7 +1654,7 @@ usage(const char* n) } int -compile(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -1675,20 +1675,12 @@ compile(int argc, char* argv[]) opts.addOpt("", "checksum"); opts.addOpt("n", "namespace"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string> args; try { - args = opts.parse(argc, const_cast<const char**>(argv)); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -1954,31 +1946,35 @@ compile(int argc, char* argv[]) return status; } -int -main(int argc, char* argv[]) +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif { + vector<string> args = Slice::argvToArgs(argc, argv); try { - return compile(argc, argv); + return compile(args); } catch(const std::exception& ex) { - getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + getErrorStream() << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index ab22e73a5b0..39e103cfb4e 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -14,31 +14,35 @@ using namespace std; using namespace Slice; using namespace Slice::Python; -int -main(int argc, char* argv[]) +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif { + vector<string> args = Slice::argvToArgs(argc, argv); try { - return Slice::Python::compile(argc, argv); + return Slice::Python::compile(args); } catch(const std::exception& ex) { - getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + getErrorStream() << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << argv[0] << ": error:" << msg << endl; + getErrorStream() << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index 8c38a8bd60b..7b489503f71 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -17,9 +17,10 @@ using namespace Slice::Ruby; int main(int argc, char* argv[]) { + vector<string> args = Slice::argvToArgs(argc, argv); try { - return Slice::Ruby::compile(argc, argv); + return Slice::Ruby::compile(args); } catch(const std::exception& ex) { diff --git a/cpp/test/Glacier2/hashpassword/run.py b/cpp/test/Glacier2/hashpassword/run.py index db973eb0d0f..7abe7831eec 100755 --- a/cpp/test/Glacier2/hashpassword/run.py +++ b/cpp/test/Glacier2/hashpassword/run.py @@ -27,8 +27,8 @@ def test(b): raise RuntimeError('test assertion failed') def hashPasswords(password, args = ""): - p = subprocess.Popen("%s %s %s" % (sys.executable, hashpassword, args), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - stdin=subprocess.PIPE) + p = subprocess.Popen('%s "%s" %s' % (sys.executable, hashpassword, args), shell=True, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, stdin=subprocess.PIPE) p.stdin.write(password.encode('UTF-8')) p.stdin.write('\r\n'.encode('UTF-8')) p.stdin.flush() diff --git a/cpp/test/Ice/adapterDeactivation/AllTests.cpp b/cpp/test/Ice/adapterDeactivation/AllTests.cpp index 3f2f0462247..c1aa649be20 100644 --- a/cpp/test/Ice/adapterDeactivation/AllTests.cpp +++ b/cpp/test/Ice/adapterDeactivation/AllTests.cpp @@ -32,29 +32,38 @@ allTests(const CommunicatorPtr& communicator) test(obj == base); #endif cout << "ok" << endl; +#ifdef ICE_OS_WINRT + bool winrt = true; +#else + bool winrt = false; +#endif { - string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ? - "127.0.0.1" : "\"0:0:0:0:0:0:0:1\""; - cout << "creating/destroying/recreating object adapter... " << flush; - ObjectAdapterPtr adapter = - communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -h " + host); - try - { - communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -h " + host); - test(false); - } - catch(const AlreadyRegisteredException&) + if(!winrt || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" && + communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss")) { - } - adapter->destroy(); + string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ? + "127.0.0.1" : "\"0:0:0:0:0:0:0:1\""; + cout << "creating/destroying/recreating object adapter... " << flush; + ObjectAdapterPtr adapter = + communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -h " + host); + try + { + communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -h " + host); + test(false); + } + catch(const AlreadyRegisteredException&) + { + } + adapter->destroy(); - // - // Use a different port than the first adapter to avoid an "address already in use" error. - // - adapter = communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -h " + host); - adapter->destroy(); - cout << "ok" << endl; + // + // Use a different port than the first adapter to avoid an "address already in use" error. + // + adapter = communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -h " + host); + adapter->destroy(); + cout << "ok" << endl; + } } cout << "creating/activating/deactivating object adapter in one operation... " << flush; diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp index 46c3ce7ae9a..caa960b8938 100644 --- a/cpp/test/Ice/exceptions/AllTests.cpp +++ b/cpp/test/Ice/exceptions/AllTests.cpp @@ -501,147 +501,156 @@ allTests(const Ice::CommunicatorPtr& communicator) } localOAEndpoint = ostr.str(); } +#ifdef ICE_OS_WINRT + bool winrt = true; +#else + bool winrt = false; +#endif - cout << "testing object adapter registration exceptions... " << flush; + if(!winrt || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" && + communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss")) { - Ice::ObjectAdapterPtr first; - try - { - first = communicator->createObjectAdapter("TestAdapter0"); - test(false); - } - catch(const Ice::InitializationException& ex) + cout << "testing object adapter registration exceptions... " << flush; { - if(printException) + Ice::ObjectAdapterPtr first; + try { - Ice::Print printer(communicator->getLogger()); - printer << ex; + first = communicator->createObjectAdapter("TestAdapter0"); + test(false); + } + catch(const Ice::InitializationException& ex) + { + if(printException) + { + Ice::Print printer(communicator->getLogger()); + printer << ex; + } + // Expected } - // Expected - } - communicator->getProperties()->setProperty("TestAdapter0.Endpoints", localOAEndpoint); - first = communicator->createObjectAdapter("TestAdapter0"); - try - { - Ice::ObjectAdapterPtr second = communicator->createObjectAdapter("TestAdapter0"); - test(false); - } - catch(const Ice::AlreadyRegisteredException& ex) - { - if(printException) + communicator->getProperties()->setProperty("TestAdapter0.Endpoints", localOAEndpoint); + first = communicator->createObjectAdapter("TestAdapter0"); + try { - Ice::Print printer(communicator->getLogger()); - printer << ex; + Ice::ObjectAdapterPtr second = communicator->createObjectAdapter("TestAdapter0"); + test(false); } + catch(const Ice::AlreadyRegisteredException& ex) + { + if(printException) + { + Ice::Print printer(communicator->getLogger()); + printer << ex; + } - // Expected - } + // Expected + } - try - { - Ice::ObjectAdapterPtr second = - communicator->createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12011"); - test(false); - } - catch(const Ice::AlreadyRegisteredException& ex) - { - if(printException) + try { - Ice::Print printer(communicator->getLogger()); - printer << ex; + Ice::ObjectAdapterPtr second = + communicator->createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12011"); + test(false); } + catch(const Ice::AlreadyRegisteredException& ex) + { + if(printException) + { + Ice::Print printer(communicator->getLogger()); + printer << ex; + } - // Expected. + // Expected. + } + first->deactivate(); } - first->deactivate(); - } - cout << "ok" << endl; + cout << "ok" << endl; - cout << "testing servant registration exceptions... " << flush; - { - communicator->getProperties()->setProperty("TestAdapter1.Endpoints", localOAEndpoint); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter1"); - Ice::ObjectPtr obj = ICE_MAKE_SHARED(EmptyI); - adapter->add(obj, Ice::stringToIdentity("x")); - try + cout << "testing servant registration exceptions... " << flush; { + communicator->getProperties()->setProperty("TestAdapter1.Endpoints", localOAEndpoint); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter1"); + Ice::ObjectPtr obj = ICE_MAKE_SHARED(EmptyI); adapter->add(obj, Ice::stringToIdentity("x")); - test(false); - } - catch(const Ice::AlreadyRegisteredException& ex) - { - if(printException) + try { - Ice::Print printer(communicator->getLogger()); - printer << ex; + adapter->add(obj, Ice::stringToIdentity("x")); + test(false); + } + catch(const Ice::AlreadyRegisteredException& ex) + { + if(printException) + { + Ice::Print printer(communicator->getLogger()); + printer << ex; + } } - } - try - { - adapter->add(obj, Ice::stringToIdentity("")); - } - catch(const Ice::IllegalIdentityException& ex) - { - test(ex.id.name == ""); - if(printException) + try { - Ice::Print printer(communicator->getLogger()); - printer << ex; + adapter->add(obj, Ice::stringToIdentity("")); + } + catch(const Ice::IllegalIdentityException& ex) + { + test(ex.id.name == ""); + if(printException) + { + Ice::Print printer(communicator->getLogger()); + printer << ex; + } } - } - try - { - adapter->add(0, Ice::stringToIdentity("x")); - } - catch(const Ice::IllegalServantException& ex) - { - if(printException) + try { - Ice::Print printer(communicator->getLogger()); - printer << ex; + adapter->add(0, Ice::stringToIdentity("x")); + } + catch(const Ice::IllegalServantException& ex) + { + if(printException) + { + Ice::Print printer(communicator->getLogger()); + printer << ex; + } } - } - adapter->remove(Ice::stringToIdentity("x")); - try - { adapter->remove(Ice::stringToIdentity("x")); - test(false); - } - catch(const Ice::NotRegisteredException& ex) - { - if(printException) + try { - Ice::Print printer(communicator->getLogger()); - printer << ex; + adapter->remove(Ice::stringToIdentity("x")); + test(false); + } + catch(const Ice::NotRegisteredException& ex) + { + if(printException) + { + Ice::Print printer(communicator->getLogger()); + printer << ex; + } } - } - adapter->deactivate(); - } - cout << "ok" << endl; + adapter->deactivate(); + } + cout << "ok" << endl; - cout << "testing servant locator registrations exceptions... " << flush; - { - communicator->getProperties()->setProperty("TestAdapter2.Endpoints", localOAEndpoint); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter2"); - Ice::ServantLocatorPtr loc = ICE_MAKE_SHARED(ServantLocatorI); - adapter->addServantLocator(loc, "x"); - try + cout << "testing servant locator registrations exceptions... " << flush; { + communicator->getProperties()->setProperty("TestAdapter2.Endpoints", localOAEndpoint); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter2"); + Ice::ServantLocatorPtr loc = ICE_MAKE_SHARED(ServantLocatorI); adapter->addServantLocator(loc, "x"); - test(false); - } - catch(const Ice::AlreadyRegisteredException&) - { - } + try + { + adapter->addServantLocator(loc, "x"); + test(false); + } + catch(const Ice::AlreadyRegisteredException&) + { + } - adapter->deactivate(); + adapter->deactivate(); + } + cout << "ok" << endl; } - cout << "ok" << endl; cout << "testing value factory registration exception... " << flush; { diff --git a/cpp/test/Ice/facets/AllTests.cpp b/cpp/test/Ice/facets/AllTests.cpp index 01cd33cf1d6..fc9a76105ba 100644 --- a/cpp/test/Ice/facets/AllTests.cpp +++ b/cpp/test/Ice/facets/AllTests.cpp @@ -22,6 +22,12 @@ class EmptyI : public virtual Empty GPrxPtr allTests(const Ice::CommunicatorPtr& communicator) { +#ifdef ICE_OS_WINRT + bool winrt = true; +#else + bool winrt = false; +#endif + cout << "testing Ice.Admin.Facets property... " << flush; test(communicator->getProperties()->getPropertyAsList("Ice.Admin.Facets").empty()); communicator->getProperties()->setProperty("Ice.Admin.Facets", "foobar"); @@ -58,58 +64,62 @@ allTests(const Ice::CommunicatorPtr& communicator) localOAEndpoint = ostr.str(); } communicator->getProperties()->setProperty("FacetExceptionTestAdapter.Endpoints", localOAEndpoint); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("FacetExceptionTestAdapter"); - Ice::ObjectPtr obj = ICE_MAKE_SHARED(EmptyI); - adapter->add(obj, Ice::stringToIdentity("d")); - adapter->addFacet(obj, Ice::stringToIdentity("d"), "facetABCD"); - try + if(winrt || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" && + communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss")) { + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("FacetExceptionTestAdapter"); + Ice::ObjectPtr obj = ICE_MAKE_SHARED(EmptyI); + adapter->add(obj, Ice::stringToIdentity("d")); adapter->addFacet(obj, Ice::stringToIdentity("d"), "facetABCD"); - test(false); - } - catch(const Ice::AlreadyRegisteredException&) - { - } - adapter->removeFacet(Ice::stringToIdentity("d"), "facetABCD"); - try - { + try + { + adapter->addFacet(obj, Ice::stringToIdentity("d"), "facetABCD"); + test(false); + } + catch(const Ice::AlreadyRegisteredException&) + { + } adapter->removeFacet(Ice::stringToIdentity("d"), "facetABCD"); - test(false); - } - catch(const Ice::NotRegisteredException&) - { - } - cout << "ok" << endl; + try + { + adapter->removeFacet(Ice::stringToIdentity("d"), "facetABCD"); + test(false); + } + catch(const Ice::NotRegisteredException&) + { + } + cout << "ok" << endl; - cout << "testing removeAllFacets... " << flush; - Ice::ObjectPtr obj1 = ICE_MAKE_SHARED(EmptyI); - Ice::ObjectPtr obj2 = ICE_MAKE_SHARED(EmptyI); - adapter->addFacet(obj1, Ice::stringToIdentity("id1"), "f1"); - adapter->addFacet(obj2, Ice::stringToIdentity("id1"), "f2"); - Ice::ObjectPtr obj3 = ICE_MAKE_SHARED(EmptyI); - adapter->addFacet(obj1, Ice::stringToIdentity("id2"), "f1"); - adapter->addFacet(obj2, Ice::stringToIdentity("id2"), "f2"); - adapter->addFacet(obj3, Ice::stringToIdentity("id2"), ""); - Ice::FacetMap fm = adapter->removeAllFacets(Ice::stringToIdentity("id1")); - test(fm.size() == 2); - test(fm["f1"] == obj1); - test(fm["f2"] == obj2); - try - { - adapter->removeAllFacets(Ice::stringToIdentity("id1")); - test(false); - } - catch(const Ice::NotRegisteredException&) - { - } - fm = adapter->removeAllFacets(Ice::stringToIdentity("id2")); - test(fm.size() == 3); - test(fm["f1"] == obj1); - test(fm["f2"] == obj2); - test(fm[""] == obj3); - cout << "ok" << endl; + cout << "testing removeAllFacets... " << flush; + Ice::ObjectPtr obj1 = ICE_MAKE_SHARED(EmptyI); + Ice::ObjectPtr obj2 = ICE_MAKE_SHARED(EmptyI); + adapter->addFacet(obj1, Ice::stringToIdentity("id1"), "f1"); + adapter->addFacet(obj2, Ice::stringToIdentity("id1"), "f2"); + Ice::ObjectPtr obj3 = ICE_MAKE_SHARED(EmptyI); + adapter->addFacet(obj1, Ice::stringToIdentity("id2"), "f1"); + adapter->addFacet(obj2, Ice::stringToIdentity("id2"), "f2"); + adapter->addFacet(obj3, Ice::stringToIdentity("id2"), ""); + Ice::FacetMap fm = adapter->removeAllFacets(Ice::stringToIdentity("id1")); + test(fm.size() == 2); + test(fm["f1"] == obj1); + test(fm["f2"] == obj2); + try + { + adapter->removeAllFacets(Ice::stringToIdentity("id1")); + test(false); + } + catch(const Ice::NotRegisteredException&) + { + } + fm = adapter->removeAllFacets(Ice::stringToIdentity("id2")); + test(fm.size() == 3); + test(fm["f1"] == obj1); + test(fm["f2"] == obj2); + test(fm[""] == obj3); + cout << "ok" << endl; - adapter->deactivate(); + adapter->deactivate(); + } cout << "testing stringToProxy... " << flush; string ref = "d:" + getTestEndpoint(communicator, 0); diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp index e9edf0327ee..18fb252424c 100644 --- a/cpp/test/Ice/info/AllTests.cpp +++ b/cpp/test/Ice/info/AllTests.cpp @@ -106,55 +106,64 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "ok" << endl; string defaultHost = communicator->getProperties()->getProperty("Ice.Default.Host"); - cout << "test object adapter endpoint information... " << flush; +#ifdef ICE_OS_WINRT + bool winrt = true; +#else + bool winrt = false; +#endif + if(!winrt || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" && + communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss")) { - communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -h 127.0.0.1 -t 15000:udp -h 127.0.0.1"); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); - - Ice::EndpointSeq endpoints = adapter->getEndpoints(); - test(endpoints.size() == 2); - Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints(); - test(endpoints == publishedEndpoints); - - Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(endpoints[0]->getInfo()); - test(ipEndpoint); - test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == Ice::SSLEndpointType || - ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType); - test(ipEndpoint->host == "127.0.0.1"); - test(ipEndpoint->port > 0); - test(ipEndpoint->timeout == 15000); - - Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endpoints[1]->getInfo()); - test(udpEndpoint); - test(udpEndpoint->host == "127.0.0.1"); - test(udpEndpoint->datagram()); - test(udpEndpoint->port > 0); - - adapter->destroy(); - - communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -h * -p 12020"); - communicator->getProperties()->setProperty("TestAdapter.PublishedEndpoints", "default -h 127.0.0.1 -p 12020"); - adapter = communicator->createObjectAdapter("TestAdapter"); - - endpoints = adapter->getEndpoints(); - test(endpoints.size() >= 1); - publishedEndpoints = adapter->getPublishedEndpoints(); - test(publishedEndpoints.size() == 1); - - for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) + cout << "test object adapter endpoint information... " << flush; { - ipEndpoint = getTCPEndpointInfo((*p)->getInfo()); - test(ipEndpoint->port == 12020); - } + communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -h 127.0.0.1 -t 15000:udp -h 127.0.0.1"); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + + Ice::EndpointSeq endpoints = adapter->getEndpoints(); + test(endpoints.size() == 2); + Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints(); + test(endpoints == publishedEndpoints); + + Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(endpoints[0]->getInfo()); + test(ipEndpoint); + test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == Ice::SSLEndpointType || + ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType); + test(ipEndpoint->host == "127.0.0.1"); + test(ipEndpoint->port > 0); + test(ipEndpoint->timeout == 15000); + + Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endpoints[1]->getInfo()); + test(udpEndpoint); + test(udpEndpoint->host == "127.0.0.1"); + test(udpEndpoint->datagram()); + test(udpEndpoint->port > 0); + + adapter->destroy(); + + communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -h * -p 12020"); + communicator->getProperties()->setProperty("TestAdapter.PublishedEndpoints", "default -h 127.0.0.1 -p 12020"); + adapter = communicator->createObjectAdapter("TestAdapter"); + + endpoints = adapter->getEndpoints(); + test(endpoints.size() >= 1); + publishedEndpoints = adapter->getPublishedEndpoints(); + test(publishedEndpoints.size() == 1); + + for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) + { + ipEndpoint = getTCPEndpointInfo((*p)->getInfo()); + test(ipEndpoint->port == 12020); + } - ipEndpoint = getTCPEndpointInfo(publishedEndpoints[0]->getInfo()); - test(ipEndpoint->host == "127.0.0.1"); - test(ipEndpoint->port == 12020); + ipEndpoint = getTCPEndpointInfo(publishedEndpoints[0]->getInfo()); + test(ipEndpoint->host == "127.0.0.1"); + test(ipEndpoint->port == 12020); - adapter->destroy(); + adapter->destroy(); + } + cout << "ok" << endl; } - cout << "ok" << endl; - + Ice::ObjectPrxPtr base = communicator->stringToProxy("test:default -p 12010:udp -p 12010 -c"); TestIntfPrxPtr testIntf = ICE_CHECKED_CAST(TestIntfPrx, base); diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp index 4eae1d66007..80e10c780db 100644 --- a/cpp/test/Ice/location/AllTests.cpp +++ b/cpp/test/Ice/location/AllTests.cpp @@ -20,7 +20,7 @@ using namespace Test; class HelloI : public virtual Hello { public: - + virtual void sayHello(const Ice::Current&) { @@ -689,29 +689,39 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) } cout << "ok" << endl; - string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ? +#ifdef ICE_OS_WINRT + bool winrt = true; +#else + bool winrt = false; +#endif + string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ? "127.0.0.1" : "\"0:0:0:0:0:0:0:1\""; - if(communicator->getProperties()->getProperty("Ice.Default.Host") == host) - { - cout << "testing indirect proxies to collocated objects... " << flush; - // - // Set up test for calling a collocated object through an indirect, adapterless reference. - // - Ice::PropertiesPtr properties = communicator->getProperties(); - properties->setProperty("Ice.PrintAdapterReady", "0"); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "default"); - adapter->setLocator(locator); - - Ice::Identity id; - id.name = Ice::generateUUID(); - registry->addObject(adapter->add(ICE_MAKE_SHARED(HelloI), id)); - adapter->activate(); - HelloPrxPtr helloPrx = ICE_CHECKED_CAST(HelloPrx, communicator->stringToProxy(identityToString(id))); - test(!helloPrx->ice_getConnection()); - - adapter->deactivate(); - cout << "ok" << endl; + if(!winrt || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" && + communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss")) + { + if(communicator->getProperties()->getProperty("Ice.Default.Host") == host) + { + cout << "testing indirect proxies to collocated objects... " << flush; + // + // Set up test for calling a collocated object through an indirect, adapterless reference. + // + Ice::PropertiesPtr properties = communicator->getProperties(); + properties->setProperty("Ice.PrintAdapterReady", "0"); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "default"); + adapter->setLocator(locator); + + Ice::Identity id; + id.name = Ice::generateUUID(); + registry->addObject(adapter->add(ICE_MAKE_SHARED(HelloI), id)); + adapter->activate(); + + HelloPrxPtr helloPrx = ICE_CHECKED_CAST(HelloPrx, communicator->stringToProxy(identityToString(id))); + test(!helloPrx->ice_getConnection()); + + adapter->deactivate(); + cout << "ok" << endl; + } } cout << "shutdown server manager... " << flush; manager->shutdown(); diff --git a/cpp/test/Ice/logger/run.py b/cpp/test/Ice/logger/run.py index 06bccf316d7..4744ede4eb4 100755 --- a/cpp/test/Ice/logger/run.py +++ b/cpp/test/Ice/logger/run.py @@ -9,7 +9,7 @@ # # ********************************************************************** -import os, sys, subprocess, glob, atexit +import os, sys, subprocess, glob, atexit, shutil path = [ ".", "..", "../..", "../../..", "../../../..", "../../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -71,7 +71,7 @@ if not os.path.exists("log"): open("log/client5-4.log", 'a').close() if TestUtil.isWin32(): - os.system("echo Y|cacls log /P %USERNAME%:R 1> nul") + os.system("echo Y|cacls log /P \"%USERNAME%\":R 1> nul") else: os.system("chmod -w log") @@ -83,7 +83,7 @@ if ret != 0: sys.exit(1) if TestUtil.isWin32(): - os.system("echo Y|cacls log /P %USERNAME%:F 1> nul") + os.system("echo Y|cacls log /P \"%USERNAME%\":F 1> nul") else: os.system("chmod +w log") @@ -126,15 +126,22 @@ for f in glob.glob("client5-3-*.log"): print("failed! file {0} size: {1} unexpected".format(f, os.stat(f).st_size)) sys.exit(1) -if (not os.path.isfile("log/client5-4.log") or - os.stat("log/client5-4.log").st_size < 1024 or - len(glob.glob("log/client5-4-*.log")) > 0): - print("failed!") - sys.exit(1) - -with open("log/client5-4.log", 'r') as f: - if f.read().count("error: FileLogger: cannot rename `log/client5-4.log'") != 1: +# +# When running as root log rotation will not fail as +# root always has write access. +# +if TestUtil.isWin32() or os.getuid() != 0: + if (not os.path.isfile("log/client5-4.log") or + os.stat("log/client5-4.log").st_size < 1024 or + len(glob.glob("log/client5-4-*.log")) > 0): print("failed!") sys.exit(1) + with open("log/client5-4.log", 'r') as f: + if f.read().count("error: FileLogger: cannot rename `log/client5-4.log'") != 1: + print("failed!") + sys.exit(1) + +shutil.rmtree("log") + print("ok") diff --git a/cpp/test/Ice/properties/run.py b/cpp/test/Ice/properties/run.py index c77d767545b..c31a553ab06 100755 --- a/cpp/test/Ice/properties/run.py +++ b/cpp/test/Ice/properties/run.py @@ -40,13 +40,14 @@ else: configPath = "./config/\u4e2d\u56fd_client.config" decodedPath = configPath # No need to decode with Python3, strings are already Unicode -TestUtil.createConfig(decodedPath, - ["# Automatically generated by Ice test driver.", - "Ice.Trace.Protocol=1", - "Ice.Trace.Network=1", - "Ice.ProgramName=PropertiesClient", - "Config.Path=" + configPath], - "utf-8") + +TestUtil.createFile(decodedPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=" + configPath], + "utf-8") TestUtil.simpleTest(client) diff --git a/cpp/test/IceGrid/deployer/AllTests.cpp b/cpp/test/IceGrid/deployer/AllTests.cpp index 301692a25aa..222a243ba6c 100644 --- a/cpp/test/IceGrid/deployer/AllTests.cpp +++ b/cpp/test/IceGrid/deployer/AllTests.cpp @@ -414,6 +414,7 @@ allTests(const Ice::CommunicatorPtr& comm) test(find(adapterIds.begin(), adapterIds.end(), "IceBox2Service2Adapter") != adapterIds.end()); test(find(adapterIds.begin(), adapterIds.end(), "SimpleIceBox.SimpleService.SimpleService") != adapterIds.end()); test(find(adapterIds.begin(), adapterIds.end(), "ReplicatedAdapter") != adapterIds.end()); + test(find(adapterIds.begin(), adapterIds.end(), "ReplicatedAdapter 2") != adapterIds.end()); cout << "ok" << endl; cout << "testing object registration... " << flush; diff --git a/cpp/test/IceGrid/deployer/application.xml b/cpp/test/IceGrid/deployer/application.xml index 95ea1e7c344..99f7ec881de 100644 --- a/cpp/test/IceGrid/deployer/application.xml +++ b/cpp/test/IceGrid/deployer/application.xml @@ -23,7 +23,7 @@ <object identity="ReplicatedObject" type="::Test"/> </replica-group> - <replica-group id="ReplicatedAdapter2" proxy-options="-e 1.4"> + <replica-group id="ReplicatedAdapter 2" proxy-options="-e 1.4"> <description>REPLICA GROUP ${AppVar}</description> <object identity="ReplicatedObject15" type="::Test" proxy-options="-e 1.5"/> <object identity="ReplicatedObject14" type="::Test"/> diff --git a/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp b/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp index 560df6f98d3..472b5c25d1c 100644 --- a/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp +++ b/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp @@ -545,6 +545,10 @@ allTests(const Ice::CommunicatorPtr& communicator) #if defined(__linux) && defined(__i386) iceboxExe += "32"; #endif + +#if defined(_WIN32) && !defined(NDEBUG) + iceboxExe += "d"; +#endif IceBoxDescriptorPtr icebox = new IceBoxDescriptor(); icebox->id = "IceBox"; icebox->exe = properties->getProperty("IceBinDir") + iceboxExe; diff --git a/cpp/test/IceGrid/simple/AllTests.cpp b/cpp/test/IceGrid/simple/AllTests.cpp index e2330ec8451..26ba499de28 100644 --- a/cpp/test/IceGrid/simple/AllTests.cpp +++ b/cpp/test/IceGrid/simple/AllTests.cpp @@ -48,94 +48,102 @@ allTests(const Ice::CommunicatorPtr& communicator) test(finder->getLocator()); cout << "ok" << endl; - cout << "testing discovery... " << flush; + Ice::CommunicatorPtr com; + try { - // Add test well-known object - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); - test(registry); - - IceGrid::AdminSessionPrx session = registry->createAdminSession("foo", "bar"); - session->getAdmin()->addObjectWithType(base, "::Test"); - session->destroy(); - - // - // Ensure the IceGrid discovery locator can discover the - // registries and make sure locator requests are forwarded. - // - Ice::InitializationData initData; - initData.properties = communicator->getProperties()->clone(); - initData.properties->setProperty("Ice.Default.Locator", ""); - initData.properties->setProperty("Ice.Plugin.IceLocatorDiscovery", "IceLocatorDiscovery:createIceLocatorDiscovery"); -#ifdef __APPLE__ - if(initData.properties->getPropertyAsInt("Ice.PreferIPv6Address") > 0) + cout << "testing discovery... " << flush; { - initData.properties->setProperty("IceLocatorDiscovery.Interface", "::1"); - } + // Add test well-known object + IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( + communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); + test(registry); + + IceGrid::AdminSessionPrx session = registry->createAdminSession("foo", "bar"); + session->getAdmin()->addObjectWithType(base, "::Test"); + session->destroy(); + + // + // Ensure the IceGrid discovery locator can discover the + // registries and make sure locator requests are forwarded. + // + Ice::InitializationData initData; + initData.properties = communicator->getProperties()->clone(); + initData.properties->setProperty("Ice.Default.Locator", ""); + initData.properties->setProperty("Ice.Plugin.IceLocatorDiscovery", "IceLocatorDiscovery:createIceLocatorDiscovery"); +#ifdef __APPLE__ + if(initData.properties->getPropertyAsInt("Ice.PreferIPv6Address") > 0) + { + initData.properties->setProperty("IceLocatorDiscovery.Interface", "::1"); + } #endif - initData.properties->setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter"); - initData.properties->setProperty("AdapterForDiscoveryTest.Endpoints", "default"); - - Ice::CommunicatorPtr com = Ice::initialize(initData); - test(com->getDefaultLocator()); - com->stringToProxy("test @ TestAdapter")->ice_ping(); - com->stringToProxy("test")->ice_ping(); - - test(com->getDefaultLocator()->getRegistry()); - test(IceGrid::LocatorPrx::checkedCast(com->getDefaultLocator())); - test(IceGrid::LocatorPrx::uncheckedCast(com->getDefaultLocator())->getLocalRegistry()); - test(IceGrid::LocatorPrx::uncheckedCast(com->getDefaultLocator())->getLocalQuery()); - - Ice::ObjectAdapterPtr adapter = com->createObjectAdapter("AdapterForDiscoveryTest"); - adapter->activate(); - adapter->deactivate(); + initData.properties->setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter"); + initData.properties->setProperty("AdapterForDiscoveryTest.Endpoints", "default"); - com->destroy(); + com = Ice::initialize(initData); + test(com->getDefaultLocator()); - // - // Now, ensure that the IceGrid discovery locator correctly - // handles failure to find a locator. Also test - // Ice::registerIceLocatorDiscovery() - // - Ice::registerIceLocatorDiscovery(); - initData.properties->setProperty("Ice.Plugin.IceLocatorDiscovery", ""); - initData.properties->setProperty("IceLocatorDiscovery.InstanceName", "unknown"); - initData.properties->setProperty("IceLocatorDiscovery.RetryCount", "1"); - initData.properties->setProperty("IceLocatorDiscovery.Timeout", "100"); - com = Ice::initialize(initData); - test(com->getDefaultLocator()); - try - { com->stringToProxy("test @ TestAdapter")->ice_ping(); - } - catch(const Ice::NoEndpointException&) - { - } - try - { com->stringToProxy("test")->ice_ping(); - } - catch(const Ice::NoEndpointException&) - { - } - test(!com->getDefaultLocator()->getRegistry()); - test(!IceGrid::LocatorPrx::checkedCast(com->getDefaultLocator())); - try - { + test(com->getDefaultLocator()->getRegistry()); + test(IceGrid::LocatorPrx::checkedCast(com->getDefaultLocator())); + test(IceGrid::LocatorPrx::uncheckedCast(com->getDefaultLocator())->getLocalRegistry()); test(IceGrid::LocatorPrx::uncheckedCast(com->getDefaultLocator())->getLocalQuery()); - } - catch(const Ice::OperationNotExistException&) - { - } - - adapter = com->createObjectAdapter("AdapterForDiscoveryTest"); - adapter->activate(); - adapter->deactivate(); + Ice::ObjectAdapterPtr adapter = com->createObjectAdapter("AdapterForDiscoveryTest"); + adapter->activate(); + adapter->deactivate(); + + com->destroy(); + + // + // Now, ensure that the IceGrid discovery locator correctly + // handles failure to find a locator. Also test + // Ice::registerIceLocatorDiscovery() + // + Ice::registerIceLocatorDiscovery(); + initData.properties->setProperty("Ice.Plugin.IceLocatorDiscovery", ""); + initData.properties->setProperty("IceLocatorDiscovery.InstanceName", "unknown"); + initData.properties->setProperty("IceLocatorDiscovery.RetryCount", "1"); + initData.properties->setProperty("IceLocatorDiscovery.Timeout", "100"); + com = Ice::initialize(initData); + test(com->getDefaultLocator()); + try + { + com->stringToProxy("test @ TestAdapter")->ice_ping(); + } + catch(const Ice::NoEndpointException&) + { + } + try + { + com->stringToProxy("test")->ice_ping(); + } + catch(const Ice::NoEndpointException&) + { + } + test(!com->getDefaultLocator()->getRegistry()); + test(!IceGrid::LocatorPrx::checkedCast(com->getDefaultLocator())); + try + { + test(IceGrid::LocatorPrx::uncheckedCast(com->getDefaultLocator())->getLocalQuery()); + } + catch(const Ice::OperationNotExistException&) + { + } + + adapter = com->createObjectAdapter("AdapterForDiscoveryTest"); + adapter->activate(); + adapter->deactivate(); + + com->destroy(); + } + cout << "ok" << endl; + } + catch(const Ice::NoEndpointException&) + { com->destroy(); + cout << "failed (is a firewall enabled?)" << endl; } - cout << "ok" << endl; - cout << "shutting down server... " << flush; obj->shutdown(); cout << "ok" << endl; diff --git a/cpp/test/IceStorm/stress/Publisher.cpp b/cpp/test/IceStorm/stress/Publisher.cpp index b83347b2658..6b9c7801f68 100644 --- a/cpp/test/IceStorm/stress/Publisher.cpp +++ b/cpp/test/IceStorm/stress/Publisher.cpp @@ -23,6 +23,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) IceUtilInternal::Options opts; opts.addOpt("", "events", IceUtilInternal::Options::NeedArg); opts.addOpt("", "oneway"); + opts.addOpt("", "maxQueueTest"); try { @@ -47,6 +48,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } bool oneway = opts.isSet("oneway"); + bool maxQueueTest = opts.isSet("maxQueueTest"); PropertiesPtr properties = communicator->getProperties(); const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default"; @@ -74,7 +76,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) { cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; return EXIT_FAILURE; - + } EventPrx twowayProxy = EventPrx::uncheckedCast(topic->getPublisher()->ice_twoway()); @@ -90,6 +92,11 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) for(int i = 0; i < events; ++i) { + if(maxQueueTest && i == 10) + { + // Sleep one seconds to give some time to IceStorm to connect to the subscriber + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); + } proxy->pub(i); } diff --git a/cpp/test/IceStorm/stress/Subscriber.cpp b/cpp/test/IceStorm/stress/Subscriber.cpp index daa63ec5d75..132bd5c4d34 100644 --- a/cpp/test/IceStorm/stress/Subscriber.cpp +++ b/cpp/test/IceStorm/stress/Subscriber.cpp @@ -23,6 +23,8 @@ using namespace Ice; using namespace IceStorm; using namespace Test; +struct Subscription; // Forward declaration. + class EventI : public Event, public IceUtil::Mutex { public: @@ -38,6 +40,10 @@ public: return _count; } + virtual void check(const Subscription&) + { + } + protected: const CommunicatorPtr _communicator; @@ -46,6 +52,20 @@ protected: }; typedef IceUtil::Handle<EventI> EventIPtr; +struct Subscription +{ + Subscription() : activate(true) + { + } + + Ice::ObjectAdapterPtr adapter; + Ice::ObjectPrx obj; + EventIPtr servant; + IceStorm::QoS qos; + Ice::ObjectPrx publisher; + bool activate; +}; + class OrderEventI : public EventI { public: @@ -170,6 +190,89 @@ private: IceUtil::Mutex* ErraticEventI::_remainingMutex = 0; int ErraticEventI::_remaining = 0; +class MaxQueueEventI : public EventI +{ +public: + + MaxQueueEventI(const CommunicatorPtr& communicator, int expected, int total, bool removeSubscriber) : + EventI(communicator, total), _removeSubscriber(removeSubscriber), _expected(expected) + { + } + + virtual void + pub(int counter, const Ice::Current&) + { + Lock sync(*this); + + if(counter != _count) + { + cerr << "failed! expected event: " << _count << " received event: " << counter << endl; + } + + if(_removeSubscriber) + { + _count = _total; + _communicator->shutdown(); + return; + } + + if(_count == 0) + { + _count = _total - _expected; + } + else if(++_count == _total) + { + _communicator->shutdown(); + } + } + + virtual void + check(const Subscription& subscription) + { + if(_removeSubscriber) + { + try + { + subscription.publisher->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + } + } + +private: + + bool _removeSubscriber; + int _expected; +}; + + +class ControllerEventI: public EventI +{ +public: + + ControllerEventI(const CommunicatorPtr& communicator, int total, const Ice::ObjectAdapterPtr& adapter) : + EventI(communicator, total), _adapter(adapter) + { + } + + virtual void + pub(int, const Ice::Current&) + { + Lock sync(*this); + if(++_count == _total) + { + _adapter->activate(); + } + } + +private: + + const Ice::ObjectAdapterPtr _adapter; +}; + namespace { @@ -193,14 +296,6 @@ Init init; } -struct Subscription -{ - Ice::ObjectAdapterPtr adapter; - Ice::ObjectPrx obj; - EventIPtr servant; - IceStorm::QoS qos; -}; - int run(int argc, char* argv[], const CommunicatorPtr& communicator) { @@ -209,6 +304,8 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) opts.addOpt("", "qos", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); opts.addOpt("", "slow"); opts.addOpt("", "erratic", IceUtilInternal::Options::NeedArg); + opts.addOpt("", "maxQueueDropEvents", IceUtilInternal::Options::NeedArg); + opts.addOpt("", "maxQueueRemoveSub", IceUtilInternal::Options::NeedArg); try { @@ -247,6 +344,8 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } bool slow = opts.isSet("slow"); + int maxQueueDropEvents = opts.isSet("maxQueueDropEvents") ? atoi(opts.optArg("maxQueueDropEvents").c_str()) : 0; + int maxQueueRemoveSub = opts.isSet("maxQueueRemoveSub") ? atoi(opts.optArg("maxQueueRemoveSub").c_str()) : 0; bool erratic = false; int erraticNum = 0; s = opts.optArg("erratic"); @@ -301,6 +400,28 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) item.qos = cmdLineQos; subs.push_back(item); } + else if(maxQueueDropEvents || maxQueueRemoveSub) + { + Subscription item1; + item1.adapter = communicator->createObjectAdapterWithEndpoints("MaxQueueAdapter", "default"); + if(maxQueueDropEvents) + { + item1.servant = new MaxQueueEventI(communicator, maxQueueDropEvents, events, false); + } + else + { + item1.servant = new MaxQueueEventI(communicator, maxQueueRemoveSub, events, true); + } + item1.qos = cmdLineQos; + item1.activate = false; + subs.push_back(item1); + + Subscription item2; + item2.adapter = communicator->createObjectAdapterWithEndpoints("ControllerAdapter", "default"); + item2.servant = new ControllerEventI(communicator, events, item1.adapter); + item2.qos["reliability"] = "oneway"; + subs.push_back(item2); + } else { Subscription item; @@ -357,14 +478,17 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) { p->obj = p->obj->ice_oneway(); } - topic->subscribeAndGetPublisher(qos, p->obj); + p->publisher = topic->subscribeAndGetPublisher(qos, p->obj); } } { for(vector<Subscription>::iterator p = subs.begin(); p != subs.end(); ++p) { - p->adapter->activate(); + if(p->activate) + { + p->adapter->activate(); + } } } @@ -373,6 +497,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) { for(vector<Subscription>::const_iterator p = subs.begin(); p != subs.end(); ++p) { + p->servant->check(*p); topic->unsubscribe(p->obj); if(p->servant->count() != events) { diff --git a/cpp/test/IceStorm/stress/run.py b/cpp/test/IceStorm/stress/run.py index 0cfb71796f0..23765c8174e 100755 --- a/cpp/test/IceStorm/stress/run.py +++ b/cpp/test/IceStorm/stress/run.py @@ -31,7 +31,7 @@ if TestUtil.appverifier: TestUtil.getIceStormAdmin()] TestUtil.setAppVerifierSettings(targets, cwd = os.getcwd()) -def doTest(server1, server2, subOpts, pubOpts): +def doTest(server1, subOpts, pubOpts): subscriberProcs = [] if type(subOpts) != type([]): @@ -80,49 +80,49 @@ def runtest(type): sys.stdout.write("Sending 5000 ordered events... ") sys.stdout.flush() - doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server1.reference(), '--events 5000') + doTest(server1, '--events 5000 --qos "reliability,ordered" ' + server1.reference(), '--events 5000') print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") sys.stdout.write("Sending 5000 ordered events across a link... ") sys.stdout.flush() - doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server2.reference(), '--events 5000') + doTest(server1, '--events 5000 --qos "reliability,ordered" ' + server2.reference(), '--events 5000') print("ok") runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") sys.stdout.write("Sending 20000 unordered events... ") sys.stdout.flush() - doTest(server1, server2, '--events 20000 ' + server1.reference(), '--events 20000 --oneway') + doTest(server1, '--events 20000 ' + server1.reference(), '--events 20000 --oneway') print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") sys.stdout.write("Sending 20000 unordered events across a link... ") sys.stdout.flush() - doTest(server1, server2, '--events 20000 ' + server2.reference(), '--events 20000 --oneway') + doTest(server1, '--events 20000 ' + server2.reference(), '--events 20000 --oneway') print("ok") runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") sys.stdout.write("Sending 20000 unordered batch events... ") sys.stdout.flush() - doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server1.reference(), '--events 20000 --oneway') + doTest(server1, '--events 20000 --qos "reliability,batch" ' + server1.reference(), '--events 20000 --oneway') print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") sys.stdout.write("Sending 20000 unordered batch events across a link... ") sys.stdout.flush() - doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server2.reference(), '--events 20000 --oneway') + doTest(server1, '--events 20000 --qos "reliability,batch" ' + server2.reference(), '--events 20000 --oneway') print("ok") runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") sys.stdout.write("Sending 20000 unordered events with slow subscriber... ") sys.stdout.flush() - doTest(server1, server2, ['--events 2 --slow ' + server1.reference(), '--events 20000 ' + server1.reference()], '--events 20000 --oneway') + doTest(server1, ['--events 2 --slow ' + server1.reference(), '--events 20000 ' + server1.reference()], '--events 20000 --oneway') print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") sys.stdout.write("Sending 20000 unordered events with slow subscriber & link... ") sys.stdout.flush() - doTest(server1, server2, ['--events 2 --slow' + server1.reference(), '--events 20000' + server1.reference(), '--events 2 --slow' + server2.reference(), '--events 20000' + server2.reference()], '--events 20000 --oneway') + doTest(server1, ['--events 2 --slow' + server1.reference(), '--events 20000' + server1.reference(), '--events 2 --slow' + server2.reference(), '--events 20000' + server2.reference()], '--events 20000 --oneway') print("ok") sys.stdout.write("shutting down icestorm services... ") @@ -146,7 +146,7 @@ def runtest(type): sys.stdout.write("Sending 20000 unordered events with erratic subscriber... ") sys.stdout.flush() - doTest(server1, server2, + doTest(server1, [ '--erratic 5 --qos "reliability,ordered" --events 20000' + server1.reference(), '--erratic 5 --events 20000' + server1.reference(), '--events 20000' + server1.reference()], @@ -175,6 +175,28 @@ def runtest(type): server2.stop() print("ok") + sys.stdout.write("Sending 5000 ordered events with max queue size drop events... ") + sys.stdout.flush() + opts = " --IceStorm.Send.QueueSizeMax=2000 --IceStorm.Send.QueueSizeMaxPolicy=DropEvents" + server1.start(echo=False, additionalOptions = opts) + doTest(server1, + '--events 5000 --qos "reliability,ordered" --maxQueueDropEvents=2000 ' + server1.reference(), + '--events 5000 --maxQueueTest') + server1.stop() + print("ok") + + sys.stdout.write("Sending 5000 ordered events with max queue size remove subscriber... ") + sys.stdout.flush() + opts = " --IceStorm.Send.QueueSizeMax=2000 --IceStorm.Send.QueueSizeMaxPolicy=RemoveSubscriber" + server1.start(echo=False, additionalOptions = opts) + doTest(server1, + '--events 5000 --qos "reliability,ordered" --maxQueueRemoveSub=2000 ' + server1.reference(), + '--events 5000 --maxQueueTest') + server1.stop() + print("ok") + + + runtest("persistent") runtest("replicated") diff --git a/cpp/test/IceUtil/stacktrace/Client.cpp b/cpp/test/IceUtil/stacktrace/Client.cpp index 503d83ccdcf..fbf133fa329 100644 --- a/cpp/test/IceUtil/stacktrace/Client.cpp +++ b/cpp/test/IceUtil/stacktrace/Client.cpp @@ -200,7 +200,9 @@ int main(int argc, char* argv[]) { filename += "release"; #if defined(_MSC_VER) -# if(_MSC_VER == 1800) +# if(_MSC_VER == 1700) + filename += "-vc110"; +# elif(_MSC_VER == 1800) filename += "-vc120"; # elif(_MSC_VER == 1900) filename += "-vc140"; diff --git a/cpp/test/IceUtil/stacktrace/StackTrace.release-vc110.Win32 b/cpp/test/IceUtil/stacktrace/StackTrace.release-vc110.Win32 new file mode 100644 index 00000000000..823da2cd4fc --- /dev/null +++ b/cpp/test/IceUtil/stacktrace/StackTrace.release-vc110.Win32 @@ -0,0 +1,4 @@ + 0 IceUtil::Exception::Exception + 1 IceUtil::NullHandleException::NullHandleException + 2 `anonymous namespace'::Thrower::fifth + 3 main diff --git a/cpp/test/Slice/headers/run.py b/cpp/test/Slice/headers/run.py index b85cd79d908..0747f0c8e63 100755 --- a/cpp/test/Slice/headers/run.py +++ b/cpp/test/Slice/headers/run.py @@ -149,7 +149,7 @@ f.close() os.system("cd project1 && %s -I%s/tmp/Ice/slice A.ice" % (slice2cpp, basedir)) f = open("project1/A.h") if not re.search(re.escape('#include <Ice/Identity.h>'), f.read()): - print("failed!") + print("failed!2") sys.exit(1) clean() diff --git a/cpp/test/Slice/unicodePaths/run.py b/cpp/test/Slice/unicodePaths/run.py new file mode 100644 index 00000000000..c8f999a0cab --- /dev/null +++ b/cpp/test/Slice/unicodePaths/run.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys, locale, shutil + +path = [ ".", "..", "../..", "../../..", "../../../..", "../../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil + +def test(b): + if not b: + print("failed!") + sys.exit(1) + +if TestUtil.isAIX() or TestUtil.isLinux(): + encoding = locale.getdefaultlocale()[1] + if encoding != "UTF-8": + print("Please set LC_ALL to xx_xx.UTF-8, for example FR_FR.UTF-8") + print("Skipping test") + sys.exit(0) + +if sys.version_info[0] == 2 and TestUtil.isWin32(): + print("To run this test on Windows you need to be using Python 3.x") + print("Python 2.x subprocess module doesn't support unicode on Windows") + print("Skipping tes") + sys.exit(0) + +sys.stdout.write("testing Slice compiler and unicode file paths... ") +sys.stdout.flush() +tests = [ + ("cpp", ["Test.cpp", "Test.h", "TestI.cpp", "TestI.h"], "--impl-c++11"), + ("cpp", ["Test.cpp", "Test.h", "TestI.cpp", "TestI.h"], "--impl-c++98"), + ("cs", ["Test.cs", "TestI.cs"], "--impl"), + ("html", ["index.html"], ""), + ("java", ["Test/Point.java", "Test/CanvasI.java"], "--impl"), + ("js", ["Test.js"], ""), + ("objc", ["Test.m"], ""), + ("php", ["Test.php"], "")] + +# +# Write config +# +if sys.version_info[0] == 2: + srcPath = "./\xe4\xb8\xad\xe5\x9b\xbd".decode("utf-8") +else: + srcPath = "./\u4e2d\u56fd" +if os.path.exists(srcPath): + shutil.rmtree(srcPath) +os.mkdir(srcPath) +TestUtil.createFile("%s/Test.ice" % srcPath, ["module Test { ", + "class Point{int x; int y; };", + "interface Canvas{ void draw(Point p); };", + "};"], "utf-8") + +for language, generated, args in tests: + compiler = '%s' % TestUtil.getSliceTranslator(language) + if not os.path.isfile(compiler): + continue + p = TestUtil.runCommand('"%s" %s/Test.ice --output-dir %s %s' % (compiler, srcPath, srcPath, args)) + test(p.wait() == 0) + for f in generated: + test(os.path.isfile(os.path.join(srcPath, f))) + os.remove(os.path.join(srcPath, f)) + + +if os.path.exists(srcPath): + shutil.rmtree(srcPath) +print("ok") |