This commit is contained in:
Taha Afzal committed 2017-10-02 10:30:49 -04:00
commit 45660febc1
41 files changed
+627 -119

No files matched your search

@@ -47,7 +47,7 @@ namespace System.Threading.Tasks
await Task.Delay(delay);
if (!cts.IsCancellationRequested) action();
});
return Disposable.Create(cts.Cancel);
return Disposable.Create((Action)cts.Cancel);
}
}
}
@@ -18,8 +18,8 @@ namespace mbts.ui.spark
public Security security { get; private set; }
public Venue exchange => security.Exchange;
public ContractOneofCase type => security.ContractCase;
public string symbol => _get_symbol(security);
public string display_name => get_display_name(security);
public string symbol => security.ForceSymbol();
public string display_name => security.ToString(null);
public bool is_selected {
get => _is_selected;
set {
@@ -31,12 +31,6 @@ namespace mbts.ui.spark
}
}
public event Action<Security, bool> IsSelectedChanged;
public static string get_display_name(Security s) { return s.ContractCase == ContractOneofCase.Synthetic ? "{0} ({1:q/n:./m:c})".fmt(s.Synthetic.Name, s) : s.ToString("q/n:./m:c"); }
private static string _get_symbol(Security s) {
if (s.ContractCase == ContractOneofCase.Synthetic) return _get_symbol(s.Synthetic.Legs.First().Security);
else return s.Symbol;
}
}
}
}
@@ -125,7 +125,7 @@ namespace mbts.ui.spark
Predicate<string> filter = SearchHelper.get_filter(text);
vs.View.Filter = item => filter(((SecurityItem)item).display_name);
// deselect SecurityItems that do not pass the filter
target.SelectedSecurities.RemoveAll(s => !filter(SecurityItem.get_display_name(s)));
target.SelectedSecurities.RemoveAll(s => !filter(s.ToString(null)));
vs.View.RaiseOnSearch();
}
}
@@ -86,16 +86,38 @@ namespace bts.api.core {
};
var subscription = ApiNativeMethods.api_client_subscribe(_client, method_and_qualifier, cb, IntPtr.Zero);
_subscriptions.Add(subscription);
return Disposable.Create(() => {
return FinalizeableAnonymousDisposable.Create((disposing) => {
ApiNativeMethods.api_client_unsubscribe(_client, subscription);
_subscriptions.Remove(subscription);
// keepalive
cb = null;
if (!disposing) {
observer.OnError(new ObjectDisposedException("Subscription has been terminated because the returned IDisposable has been finalized."));
}
});
});
return result;
}
private class FinalizeableAnonymousDisposable : IDisposable {
private Action<bool> _action;
public FinalizeableAnonymousDisposable(Action<bool> dispose) {
_action = dispose;
}
public static FinalizeableAnonymousDisposable Create(Action<bool> dispose) { return new FinalizeableAnonymousDisposable(dispose); }
~FinalizeableAnonymousDisposable() {
Dispose(false);
}
public void Dispose() {
GC.SuppressFinalize(this);
Dispose(true);
}
protected virtual void Dispose(bool disposing) {
_action?.Invoke(disposing);
_action = null;
}
}
public override bool is_sync_call_ok() {
return !ApiNativeMethods.api_client_is_on_qb_thread(_client);
}
@@ -61,6 +61,11 @@ namespace bts.api
}
public static int SignedQuantity(this ContractLeg leg) { return leg.Side == BuySell.Buy ? (int)leg.Quantity : -(int)leg.Quantity; }
public static string ForceSymbol(this Security security) {
if (security.ContractCase == ContractOneofCase.Synthetic) return ForceSymbol(security.Synthetic.Legs.First().Security);
else return security.Symbol;
}
#endregion
}
}
@@ -18,14 +18,33 @@ namespace mbts
}
public void Dispose() {
if (_action != null) {
_action();
}
_action?.Invoke();
}
}
private class FinalizeableAnonymousDisposable : IDisposable {
private Action<bool> _action;
public FinalizeableAnonymousDisposable(Action<bool> dispose) {
_action = dispose;
}
~FinalizeableAnonymousDisposable() {
Dispose(false);
}
public void Dispose() {
GC.SuppressFinalize(this);
Dispose(true);
}
protected virtual void Dispose(bool disposing) {
_action?.Invoke(disposing);
_action = null;
}
}
public static IDisposable Create(Action a) {
return new AnonymousDisposable(a);
}
public static IDisposable Create(Action<bool> a) {
return new FinalizeableAnonymousDisposable(a);
}
public static IDisposable Create(params Action[] actions) {
return Create(actions.Select(a => Disposable.Create(a)).ToArray());
}
Regular → Executable
+1 -1
View File
@@ -1 +1 @@
set(sources api/apicore.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/services/ApiUnitTestService.proto;api/services/HelloService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/UserService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/Account.conf;config/defaults/Executor.conf;config/defaults/MarketData.conf;config/defaults/Symbols.conf;config/defaults/User.conf;config/defaults/edge.conf;config/defaults/expiration_display_offset.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/testkeys.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/Account.proto;config/protos/Executor.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/User.proto;config/protos/environment.proto;config/protos/expiration_display_offset.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/quickbus_cfg.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPriceLantencyTester.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Structure/FixedSecurity.cpp;md/Structure/PriceSize.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;security_model/SecurityHelper.cpp;security_model/old_security.proto;sparkproto/SparkProtos.proto;testing/windows_test_driver.cpp;utils/Dispatcher.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp)
set(sources api/apicore.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/services/ApiUnitTestService.proto;api/services/HelloService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/UserService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/Account.conf;config/defaults/Executor.conf;config/defaults/MarketData.conf;config/defaults/Symbols.conf;config/defaults/User.conf;config/defaults/edge.conf;config/defaults/expiration_display_offset.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/testkeys.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/Account.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/User.proto;config/protos/environment.proto;config/protos/expiration_display_offset.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/quickbus_cfg.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPriceLantencyTester.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Structure/FixedSecurity.cpp;md/Structure/PriceSize.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;security_model/SecurityHelper.cpp;security_model/old_security.proto;sparkproto/SparkProtos.proto;testing/windows_test_driver.cpp;utils/Dispatcher.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp)
+22 -5
View File
@@ -60,13 +60,20 @@ enum OrderError
{
OE_OK = 0 ;
OE_UNSUPPORTED_ORDER_TYPE = 1 ;
OE_VENUE_NOT_READY = 2 ;
OE_GATEWAY_NOT_READY = 2 ;
OE_UNKNOWN_ORDER = 5 ;
OE_UNKNOWN_SECURITY = 6 ;
OE_ORDER_NOT_ACK = 7 ;
OE_SERVER_NOT_READY = 8 ;
}
enum GatewayStatus
{
GATEWAYSTATUS_UNDEFINED = 0 ;
GATEWAYSTATUS_READY = 2 ;
GATEWAYSTATUS_NOT_READY = 3 ;
}
enum CTICode
{
CTI_UNDEFINED = 0 ;
@@ -98,8 +105,8 @@ enum ExecType
}
enum ManualOrderIndicator {
MOI_NO = 0;
MOI_YES = 1;
MOI_NO = 0 ;
MOI_YES = 1 ;
}
message NativeOrderState {
@@ -187,7 +194,7 @@ message CancelSpreaderOrder {}
message CancelOrderRequest {
uint32 order_key = 1;
google.protobuf.Timestamp transact_timestamp = 2;
google.protobuf.Timestamp timestamp = 2;
oneof cancel {
CancelNativeOrder native_order = 3;
CancelSpreaderOrder spreader = 4;
@@ -221,8 +228,16 @@ message NativeFill {
google.protobuf.Timestamp timestamp = 8;
}
message GatewayStatusUpdate {
google.protobuf.Timestamp timestamp = 1;
GatewayStatus gateway_status = 2;
string gateway_name = 3 [(bts.api.key)=true];
uint32 order_key = 4; // Work around bug in code gen
}
message OrdersSub {}
message FillsSub {}
message GatewayStatusSub {}
service OrderService {
option (bts.api.service_description)="Implements algo management";
@@ -230,7 +245,9 @@ service OrderService {
rpc create_order(CreateOrderRequest) returns (CreateOrderResponse);
rpc cancel_order(CancelOrderRequest) returns (CancelOrderResponse);
rpc update_order(UpdateOrderRequest) returns (UpdateOrderResponse);
rpc orders (OrdersSub) returns (stream OrderState);
rpc fills (FillsSub) returns (stream NativeFill);
rpc fills (FillsSub) returns (stream NativeFill);
rpc gateway (GatewayStatusSub) returns (stream GatewayStatusUpdate);
}
+1 -1
View File
@@ -14,7 +14,7 @@ JetFIX {
start_day: "sunday"
end_day: "friday"
sender_subid: "BTS"
raw_data: "T4CTS"
raw_data: "T4CST"
}
}
}
-12
View File
@@ -1,12 +0,0 @@
syntax='proto2';
package bts.config;
message Executor {
optional int32 affinity = 1 [default = -1];
optional bool yield_cpu = 2 [default = true];
repeated string actor = 3;
}
message ExecutorCfg {
repeated Executor executor = 1;
}
+3
View File
@@ -994,6 +994,9 @@ BTS_EXPORT void debug_break()
DEBUG_BREAK();
}
BTS_EXPORT void set_thread_name(std::string const&n)
{set_thread_name(n.c_str());}
BTS_EXPORT void set_thread_name(const char* name)
{
#ifdef _WIN32
+1
View File
@@ -74,6 +74,7 @@ BTS_EXPORT char* strncpy(char* dest, const char* src, size_t count);
BTS_EXPORT void setenv(const char* name, const char* value);
BTS_EXPORT void debug_break();
BTS_EXPORT void set_thread_name(std::string const&);
BTS_EXPORT void set_thread_name(const char* name);
BTS_EXPORT bool is_nan(double d);
+10
View File
@@ -1,6 +1,9 @@
#include "PBUtils.h"
#include <google/protobuf/text_format.h>
#include <google/protobuf/timestamp.pb.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
namespace bts {
namespace utils {
@@ -13,5 +16,12 @@ std::string to_string (google::protobuf::Message const &msg)
return result;
}
google::protobuf::Timestamp to_timestamp(datetime::PTime const &ptime)
{
google::protobuf::Timestamp gts;
gts.set_seconds(boost::posix_time::to_time_t(ptime));
gts.set_nanos(0);
return gts;
}
}}}
+9 -1
View File
@@ -2,23 +2,31 @@
#include <string>
#include <google/protobuf/text_format.h>
#include "lib/utils/datetime.h"
#include "bts_export.h"
namespace google {
namespace protobuf {
class Message;
class Timestamp;
}}
namespace bts {
namespace utils {
namespace pb {
BTS_EXPORT std::string to_string (google::protobuf::Message const &msg);
BTS_EXPORT google::protobuf::Timestamp to_timestamp(datetime::PTime const &ptime);
template <class T> bool from_string(const std::string &str, T*out)
{
return google::protobuf::TextFormat::ParseFromString (str,out);
}
}}}
}}
}
+1 -1
View File
@@ -1 +1 @@
set(sources ;event_grid/EventNode.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/store_tests.cpp;main.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/MDP3Utils.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;orderman/components/FillRecorder.cpp;orderman/components/Gateway.cpp;orderman/components/MDSource.cpp;orderman/components/NativeOrderMan.cpp;orderman/components/OrderRecorder.cpp;orderman/events/ExecutionReport.cpp;orderman/events/NativeOrderStateChange.cpp;orderman/events/TimeChange.cpp;orderman/native_orders/NativeOrder.cpp;orderman/persistence/FillDB.cpp;orderman/persistence/OrderDB.cpp;orderman/persistence/gen_order_id.cpp;orderman/service/OrderServiceServer.cpp;orderman/utils/fix_order_codec.cpp;orderman/utils/orderman_utils.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;risk_limits/IRiskLimitObserver.cpp;risk_limits/RiskLimitManager.cpp;risk_limits/RiskLimiter.cpp;risk_limits/SharedRiskLimiter.cpp;risk_limits/SymbolKey.cpp;risk_limits/tests/RiskLimitsTests.cpp;securities/SecurityDB.cpp;spreader/QuoteLegPriceQuantityState.cpp;spreader/SimpleSpreader.cpp;spreader/SingleFillHedger.cpp;spreader/SingleLegQuoter.cpp;spreader/SpreaderBase.cpp;spreader/SpreaderTests.cpp;testing/catch_test_runner.cpp;user/UserServiceServer.cpp)
set(sources ;cmds/CmdRegistry.cpp;cmds/Help.cpp;cmds/Run.cpp;cmds/Test.cpp;cmds/TestOrderman.cpp;event_grid/EventNode.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/store_tests.cpp;main.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/MDP3Utils.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;orderman/components/FillRecorder.cpp;orderman/components/Gateway.cpp;orderman/components/MDSource.cpp;orderman/components/NativeOrderMan.cpp;orderman/components/OrderRecorder.cpp;orderman/events/ExecutionReport.cpp;orderman/events/NativeOrderStateChange.cpp;orderman/events/TimeChange.cpp;orderman/native_orders/NativeOrder.cpp;orderman/persistence/FillDB.cpp;orderman/persistence/OrderDB.cpp;orderman/persistence/gen_order_id.cpp;orderman/service/OrderServiceServer.cpp;orderman/utils/fix_order_codec.cpp;orderman/utils/orderman_utils.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;risk_limits/IRiskLimitObserver.cpp;risk_limits/RiskLimitManager.cpp;risk_limits/RiskLimiter.cpp;risk_limits/SharedRiskLimiter.cpp;risk_limits/SymbolKey.cpp;risk_limits/tests/RiskLimitsTests.cpp;securities/SecurityDB.cpp;spreader/QuoteLegPriceQuantityState.cpp;spreader/SimpleSpreader.cpp;spreader/SingleFillHedger.cpp;spreader/SingleLegQuoter.cpp;spreader/SpreaderBase.cpp;spreader/SpreaderTests.cpp;testing/catch_test_runner.cpp;user/UserServiceServer.cpp)
+62
View File
@@ -0,0 +1,62 @@
#include "CmdRegistry.h"
#include "ICmd.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <fstream>
#include <vector>
namespace bts {
namespace cmd {
std::map<std::string, std::unique_ptr<ICmd>> CmdRegistry::_cmds;
int CmdRegistry::dispatch (int argc, char **argv)
{
if (argc < 2)
return _cmds["help"]->execute (std::vector<std::string> ());
else {
std::vector<std::string> args;
for (int i = 1; i < argc; i++) {
std::string arg (argv[i]);
if (boost::starts_with(boost::to_lower_copy(arg),"-configserver")) {
// skip configserver flag as well as url
i++;
}
else
args.push_back (arg);
}
ICmd *cmd = retrieve (std::string (args[0]));
if (cmd == 0) {
return _cmds["help"]->execute(std::vector<std::string>());
}
else {
args.erase (args.begin ());
return cmd->execute (args);
}
}
}
ICmd * CmdRegistry::retrieve (std::string const &name)
{
std::string lname (name);
boost::to_lower (lname);
if (_cmds.find (lname) == _cmds.end ())
return 0;
else
return _cmds[lname].get ();
}
std::vector<std::string> CmdRegistry::cmds ()
{
std::vector<std::string> result;
for (auto&p : _cmds)
result.push_back (p.first);
return result;
}
}}
+33
View File
@@ -0,0 +1,33 @@
#pragma once
#include <boost/algorithm/string.hpp>
#include <string>
#include <map>
#include <memory>
#include <vector>
#include "lib/utils/bts_assert.h"
namespace bts {
namespace cmd {
class ICmd;
class CmdRegistry
{
public:
template <class CMD> static void register_cmd (std::string const &name)
{
std::string lname = name;
boost::to_lower (lname);
bts_assert (_cmds.find (lname) == _cmds.end ());
_cmds[lname].reset (new CMD ());
}
static std::vector<std::string> cmds ();
static int dispatch (int argc, char **argv) ;
static ICmd * retrieve (std::string const &name);
private:
static std::map<std::string, std::unique_ptr<ICmd>> _cmds;
};
}}
+31
View File
@@ -0,0 +1,31 @@
#include "Help.h"
#include "server/sparkd/cmds/CmdRegistry.h"
#include <iostream>
namespace bts {
namespace cmd {
int Help::execute(std::vector<std::string> const &args)
{
auto commands = CmdRegistry::cmds ();
if (args.size () != 1 || CmdRegistry::retrieve (args[0]) == 0) {
std::cerr << "Syntax: sparkd <cmd> <args> or sparkd help <cmd>, where cmd is one of: "
<< std::endl;
for (auto &cmd : commands)
std::cerr << "\t" << cmd << std::endl;
return 0;
} else {
auto cmd = CmdRegistry::retrieve (args[0]);
std::cerr << "sparkd " << args[0] << ":" << std::endl << cmd->help () << std::endl;
return 0;
}
}
std::string Help::help ()
{
return "Display help.";
}
}}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include "ICmd.h"
namespace bts {
namespace cmd {
class Help : public ICmd
{
public:
int execute(std::vector<std::string> const &args);
std::string help ();
};
}}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include <vector>
#include <string>
namespace bts {
namespace cmd {
class ICmd
{
public:
virtual int execute(std::vector<std::string> const &args) = 0;
virtual std::string help () = 0;
virtual ~ICmd (){}
};
}}
+43
View File
@@ -0,0 +1,43 @@
#include "Run.h"
#include "ICmd.h"
#include "lib/config/config.h"
#include "lib/config/protos/quickbus_cfg.pb.h"
#include "lib/config/protos/Ports.pb.h"
#include "lib/quickbus/quickbus.h"
#include "lib/api/public/ServiceContext.h"
#include "server/sparkd/persistence/PersistenceServiceServer.h"
#include "server/sparkd/user/UserServiceServer.h"
#include "server/sparkd/md/run_md.h"
#include "server/sparkd/orderman/service/OrderServiceServer.h"
#include "lib/md/relay/QueryServer.h"
namespace bts {
namespace cmd {
int Run::execute(std::vector<std::string> const &)
{
using namespace bts;
config::QuickbusNodeCfg qb_cfg;
qb_cfg.set_my_port(config::get<config::Ports>().qbus_port());
qbus::Quickbus quickbus(qb_cfg);
api::ServiceContext sc(&quickbus);
persistence::PersistenceServiceServer settings_saver(sc,"settings");
user::UserServiceServer login_server(sc);
run_market_datapublishers();
md::QueryServerPtr md_query_server(md::run_query_server(sc));
orderman::OrderServiceServer order_server(sc);
std::this_thread::sleep_until(std::chrono::time_point<std::chrono::system_clock>::max());
return 0;
}
std::string Run::help () {return "\t run default sparkd services";}
}}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include "ICmd.h"
namespace bts {
namespace cmd {
class Run : public ICmd
{
public:
int execute(std::vector<std::string> const &args);
std::string help ();
};
}}
+20
View File
@@ -0,0 +1,20 @@
#include "Test.h"
#include "ICmd.h"
#include "server/sparkd/testing/catch_test_runner.h"
namespace bts {
namespace cmd {
int Test::execute(std::vector<std::string> const &args)
{
return run_tests(args);
}
std::string Test::help ()
{return "\t see https://github.com/philsquared/Catch/blob/master/docs/command-line.md";}
}}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include "ICmd.h"
namespace bts {
namespace cmd {
class Test : public ICmd
{
public:
int execute(std::vector<std::string> const &args);
std::string help ();
};
}}
+150
View File
@@ -0,0 +1,150 @@
#include "TestOrderman.h"
#include "ICmd.h"
#include "server/sparkd/orderman/utils/orderman_utils.h"
#include "server/sparkd/orderman/persistence/gen_order_id.h"
#include "lib/api/services/OrderService.pb.h"
#include "server/sparkd/orderman/service/OrderServiceServer.h"
#include "lib/api/public/ServiceContext.h"
#include "lib/api/services/OrderService.client.pb.h"
#include "lib/utils/datetime.h"
#include "lib/utils/PBUtils.h"
#include "server/sparkd/event_grid/EventNode.h"
#include "server/sparkd/orderman/events/GatewayBeginReplay.h"
#include "server/sparkd/event_grid/events/Init.h"
#include <boost/date_time/posix_time/posix_time.hpp>
namespace bts {
namespace cmd {
using namespace orderman;
template <class T>
inline void print_buffer(const char*label,T const&array)
{
const char * p = (const char*) &array;
std::cout << label << ": " ;
for (size_t i = 0; i < sizeof(array); i++) {
std::cout << (int) p[i] << ",";
}
std::cout << "\n";
}
api::orderman::CreateOrderRequest make_create_request(SecurityKey sec, api::BuySell side, Price price, Quantity quantity)
{
api::orderman::CreateOrderRequest result;
*result.mutable_timestamp() = utils::pb::to_timestamp(datetime::now());
auto &native = *result.mutable_native_order();
native.set_account_name("BTS");
native.set_operator_id("BTS");
native.set_security_key(sec.value());
native.set_side(side);
native.set_time_in_force(api::orderman::TIF_DAY);
native.set_order_type(api::orderman::OT_LIMIT);
native.set_customer_or_firm(api::orderman::COF_FIRM);
native.set_cti_code(api::orderman::CTI_CTI1);
native.set_manual_order_indicator(api::orderman::MOI_YES);
native.set_price(price.value());
native.set_quantity(quantity.value());
return result;
}
api::orderman::UpdateOrderRequest make_update_request(OrderKey k, Price price, Quantity quantity)
{
api::orderman::UpdateOrderRequest result;
result.set_order_key(k.value());
*result.mutable_timestamp() = utils::pb::to_timestamp(datetime::now());
auto &native = *result.mutable_native_order();
native.set_price(price.value());
native.set_quantity(quantity.value());
return result;
}
api::orderman::CancelOrderRequest make_cancel_request(OrderKey k)
{
api::orderman::CancelOrderRequest result;
result.set_order_key(k.value());
*result.mutable_timestamp() = utils::pb::to_timestamp(datetime::now());
result.mutable_native_order();
return result;
}
int TestOrderman::execute(std::vector<std::string> const &)
{
using Node = event_grid::EventNode<event::GatewayBeginReplay, event_grid::event::Init> ;
Node::Msg msg;
auto ev = event::GatewayBeginReplay { GatewayName ("hello") };
print_buffer("ev",ev);
new (&msg.payload[0]) event::GatewayBeginReplay (ev);
print_buffer("pl",msg.payload);
auto ptr = *(event::GatewayBeginReplay*) (&msg.payload[0]);
print_buffer("*ptr",ptr);
std::cout << ptr.name.value() << "\n";
return 0;
// OrderKey current_order (null_order_key());
// api::ServiceContext ctx;
// OrderServiceServer server(ctx);
// api::orderman::OrderService client(ctx.locate<api::orderman::OrderService> ());
// while (true) {
// std::cout << "create order: c sec_key b/s price quantity\nupdate order: u price quantity\ncancel order: x\nchange current order: o order_key\n";
// char choice;
// std::cin >> choice;
// switch (choice) {
// case 'c': {
// uint32_t sec_key;char side; double price; int quantity;
// std::cin >> sec_key >> side >> price >> quantity;
// auto resp = client.create_order(make_create_request(SecurityKey(sec_key),
// side == 'b' ? api::BUY : api::SELL,
// Price(price),
// Quantity(quantity)));
// if (resp.success()) {
// current_order = OrderKey(resp.result()->order_key());
// std::cout << utils::pb::to_string(*resp.result()) << "\n";
// }
// else
// std::cout << resp.error_message() << "\n";
// break;
// }
// case 'u': {
// double price; int quantity;
// std::cin >> price >> quantity;
// auto resp = client.update_order(make_update_request(current_order,
// Price(price),
// Quantity(quantity)));
// if (resp.success())
// std::cout << utils::pb::to_string(*resp.result()) << "\n";
// else
// std::cout << resp.error_message() << "\n";
// break;
// }
// case 'x': {
// auto resp = client.cancel_order(make_cancel_request(current_order));
// if (resp.success())
// std::cout << utils::pb::to_string(*resp.result()) << "\n";
// else
// std::cout << resp.error_message() << "\n";
// break;
// }
// case 'o': {
// std::cin >> current_order.value();
// std::cout << "Current order: " << current_order.value() << "\n";
// break;
// }
// }
// }
}
std::string TestOrderman::help ()
{return "\t run interactive order management client\n";}
}}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include <memory>
#include <vector>
#include "server/sparkd/cmds/ICmd.h"
namespace bts {
namespace cmd {
class TestOrderman : public ICmd
{
public:
int execute(std::vector<std::string> const &args);
std::string help ();
};
}}
+6 -3
View File
@@ -10,6 +10,7 @@
namespace bts {
namespace event_grid {
template <class E,size_t MaxObs=10>
class EventRecord
{
@@ -36,6 +37,7 @@ private:
std::array<Observer,MaxObs> _observers;
};
template <int N,typename HandlerArray,typename EventRecordTuple, typename Payload>
struct HandlerInit {
static void init(HandlerArray &handlers,EventRecordTuple &event_records)
@@ -52,7 +54,7 @@ struct HandlerInit<-1,HandlerArray,EventRecordTuple,Payload>
{
static void init(HandlerArray &,EventRecordTuple &) {}
};
template <typename... Events>
@@ -70,7 +72,7 @@ public:
_events()
{
HandlerInit<NumberEvents-1,HandlerArray,EventRecordTuple,Payload>::init (_handlers,_events);
send(event::Init());
// send(event::Init());
}
template <class Event>
@@ -106,7 +108,7 @@ public:
template <class Event, class N1, class N2>
friend void forward(N1 &from, N2& to);
private:
public:
struct Msg {
uint8_t handler_idx;
uint8_t forwarded;
@@ -119,6 +121,7 @@ private:
Msg m;
m.handler_idx = meta::GetTypeIdxInTuple<EventRecord<Event>,EventRecordTuple>::value;
m.forwarded = fwd;
new (&m.payload[0]) Event (ev);
_queue.enqueue(m);
}
@@ -5,6 +5,7 @@
#include "IConnection.h"
#include "server/sparkd/jetfix/gateway/ICoreGatewayEventSink.h"
#include "lib/utils/bts_assert.h"
#include "lib/os/os.h"
#include <fstream>
@@ -66,6 +67,7 @@ size_t extract (char *start, char *end,
struct AsyncReader::PImpl
{
PImpl(IConnection &connection,
std::string const&connection_name,
ICoreGatewayEventSink &sink,
size_t buffer_sz,
size_t high_water_mark)
@@ -76,7 +78,8 @@ struct AsyncReader::PImpl
write_cursor (0),
reader_thread (),
sink (sink),
high_water_mark (high_water_mark)
high_water_mark (high_water_mark),
connection_name(connection_name)
{}
// abstraction for source of raw bytes
@@ -95,17 +98,22 @@ struct AsyncReader::PImpl
// a position in the current buffer that if reached signals the
// need to increase the buffer size
uint32_t high_water_mark;
const std::string connection_name;
};
AsyncReader::AsyncReader (IConnection &connection,
std::string const&connection_name,
ICoreGatewayEventSink &sink,
size_t buffer_sz, size_t high_water_mark):
me (new PImpl(connection,sink,buffer_sz,high_water_mark))
me (new PImpl(connection,connection_name,sink,buffer_sz,high_water_mark))
{}
void AsyncReader::start ()
{
me->reader_thread = std::thread ([this] () {dispatch();});
me->reader_thread = std::thread ([this] () {
os::set_thread_name(me->connection_name+"_asyncr");
dispatch();
});
}
char* AsyncReader::cursor ()
@@ -14,6 +14,7 @@ class AsyncReader
{
public:
AsyncReader(IConnection &connection,
std::string const&connection_name,
ICoreGatewayEventSink &sink,
size_t buffer_sz, // initial buffer size to use
size_t high_water_mark); // when do we allocate a new buffer
@@ -431,6 +431,7 @@ void CoreGateway::sync_time (EventData const &ev)
*this,
[] () {return utils::TimeStamp::now ();}));
me->session_info->reader.reset (new AsyncReader (*me->session_info->connection,
me->cfg.name(),
*this,
me->cfg.msg_buffer_sz (),
me->cfg.msg_high_water_mark ()));
@@ -127,7 +127,7 @@ TEST_CASE ("JetFIX AsyncReaderTests", "[jetfix]")
MyGWObserver ob;
{
AsyncReader r (c,ob,10,5);
AsyncReader r (c,"test",ob,10,5);
r.start ();
}
@@ -143,7 +143,7 @@ TEST_CASE ("JetFIX AsyncReaderTests", "[jetfix]")
MyGWObserver ob;
{
AsyncReader r (c,ob,10,5);
AsyncReader r (c,"test",ob,10,5);
r.start ();
}
REQUIRE (ob.got_eof);
+19 -44
View File
@@ -1,55 +1,30 @@
#include "lib/os/os.h"
#include "lib/utils/init_spark_lib.h"
#include "testing/catch_test_runner.h"
#include "lib/os/os.h"
#include "server/sparkd/cmds/CmdRegistry.h"
#include "server/sparkd/cmds/Test.h"
#include "server/sparkd/cmds/Run.h"
#include "server/sparkd/cmds/Help.h"
#include "server/sparkd/cmds/TestOrderman.h"
#include "lib/config/config.h"
#include "lib/config/protos/quickbus_cfg.pb.h"
#include "lib/config/protos/Ports.pb.h"
#include "lib/quickbus/quickbus.h"
#include "lib/api/public/ServiceContext.h"
#include "server/sparkd/persistence/PersistenceServiceServer.h"
#include "server/sparkd/user/UserServiceServer.h"
#include "server/sparkd/md/run_md.h"
#include "server/sparkd/orderman/service/OrderServiceServer.h"
#include "lib/md/relay/QueryServer.h"
#include "server/sparkd/orderman/events/ExecutionReport.h"
namespace bts {
config::QuickbusNodeCfg make_cfg()
{
config::QuickbusNodeCfg result;
result.set_my_port(config::get<config::Ports>().qbus_port());
return result;
}
void start_services()
{
qbus::Quickbus quickbus(make_cfg());
api::ServiceContext sc(&quickbus);
persistence::PersistenceServiceServer settings_saver(sc,"settings");
user::UserServiceServer login_server(sc);
run_market_datapublishers();
md::QueryServerPtr md_query_server(md::run_query_server(sc));
std::this_thread::sleep_until(std::chrono::time_point<std::chrono::system_clock>::max());
}
}
#define BEGIN_CMD
#define REGISTER(CMD) bts::cmd::CmdRegistry::register_cmd<bts::cmd::CMD> (#CMD)
#define END_CMD return bts::cmd::CmdRegistry::dispatch (argc,argv)
int main( int argc, char*argv [] )
{
using namespace bts;
os::set_thread_name("main");
bts::os::set_thread_name("main");
bts::utils::init_spark_lib();
if (argc > 1 && std::string(argv[1]) == "test")
bts::run_tests(--argc, ++argv);
else {
utils::init_spark_lib();
start_services();
utils::finit_spark_lib();
}
BEGIN_CMD;
REGISTER (Test);
REGISTER (Help);
REGISTER (Run);
REGISTER (TestOrderman);
END_CMD;
bts::utils::finit_spark_lib();
return 0;
}
@@ -178,6 +178,8 @@ void NativeOrderMan::on(event::GatewayStatusChange const&status)
if (status.is_connected) {
switch (me->state) {
case State::REPLAY:
transition(State::CONNECTED);
break;
case State::CONNECTED:
bts_assert(false);
break;
@@ -1,10 +1,11 @@
#include "ExecutionReport.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
#include "lib/utils/datetime.h"
#include "lib/utils/PBUtils.h"
#include <google/protobuf/timestamp.pb.h>
#include <fmt/format.h>
#include <boost/date_time/posix_time/posix_time.hpp>
namespace bts {
namespace orderman {
@@ -20,11 +21,9 @@ api::orderman::NativeFill to_pb(ExecutionReport::Data const&r)
result.set_last_price(r.last_price.value());
result.set_avg_price(r.avg_price.value());
result.set_fill_id(fmt::format("{}/{}",r.order_key.value(),to_str(r.exchange_fill_id)));
auto ts = datetime::parse_FIX_timestamp(to_str(r.transact_time));
google::protobuf::Timestamp gts;
gts.set_seconds(boost::posix_time::to_time_t(ts));
gts.set_nanos(0);
*result.mutable_timestamp() = gts;
*result.mutable_timestamp() = utils::pb::to_timestamp(ts);
return result;
}
@@ -16,6 +16,7 @@ api::orderman::OrderState to_pb(NativeOrderHeader const&header,NativeOrderState
result.set_order_key(header.order_key.value());
result.set_parent_order_key(header.parent_order_key.value());
auto &ts = *result.mutable_timestamp();
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -34,6 +34,7 @@
#include "lib/api/public/ServiceContext.h"
#include "server/sparkd/event_grid/events/Init.h"
#include "lib/utils/PBUtils.h"
namespace bts {
namespace orderman {
@@ -139,6 +140,7 @@ struct FastExecutor {
void run () {
worker = std::thread ([this] () {
os::set_thread_name("orderman_fast");
while (!done) {
md.do_work();
gw.do_work();
@@ -192,6 +194,7 @@ struct SlowExecutor {
void run () {
worker = std::thread ([this] () {
os::set_thread_name("orderman_slow");
while (!done) {
sec_db.do_work();
time_source.do_work();
@@ -202,7 +205,7 @@ struct SlowExecutor {
}
};
enum class OrderServiceServer::State { PENDING_INIT,VENUE_READY, VENUE_NOT_READY};
enum class OrderServiceServer::State { PENDING_INIT,CONNECTED, DISCONNECTED};
struct OrderServiceServer::PImpl
{
@@ -218,7 +221,8 @@ struct OrderServiceServer::PImpl
known_orders(),
publish_fills(),
known_fills(),
native_order_objs()
native_order_objs(),
publish_gateway_status()
{
}
@@ -235,6 +239,7 @@ struct OrderServiceServer::PImpl
OrderServiceServer::FillsPublisher publish_fills;
std::set<std::string> known_fills;
std::map<OrderKey,const NativeOrder*> native_order_objs;
OrderServiceServer::GatewayPublisher publish_gateway_status;
};
OrderServiceServer::OrderServiceServer (bts::api::ServiceContext& ctx)
@@ -248,7 +253,7 @@ OrderServiceServer::OrderServiceServer (bts::api::ServiceContext& ctx)
event_grid::forward<event::NativeOrderStateChange> (me->fast.node,me->slow.node);
me->publish_orders = make_orders_publisher();
me->publish_fills = make_fills_publisher();
me->publish_gateway_status = make_gateway_publisher();
me->fast.node.observe<event::GatewayStatusChange> ([&ctx,this] (auto const&s) {
ctx.post([this,s] () { this->on_gateway_status_change(s);});
});
@@ -257,7 +262,7 @@ OrderServiceServer::OrderServiceServer (bts::api::ServiceContext& ctx)
ctx.post([this,f] () {
this->on_fills(f);
});
});
});
me->slow.node.observe<event::OrderStateChange> ([&ctx,this] (auto const&os) {
ctx.post([this,os] () {
@@ -281,7 +286,7 @@ void OrderServiceServer::init()
bts_assert(me->state == State::PENDING_INIT);
me->fast.run();
me->slow.run();
me->state = State::VENUE_NOT_READY;
me->state = State::DISCONNECTED;
}
void OrderServiceServer::on_fills(event::NativeFills const&f)
@@ -330,15 +335,24 @@ void OrderServiceServer::on_gateway_status_change(event::GatewayStatusChange con
case State::PENDING_INIT:
bts_assert(false);
break;
case State::VENUE_NOT_READY:
case State::DISCONNECTED:
bts_assert(st.is_connected);
me->state = State::VENUE_READY;
me->state = State::CONNECTED;
break;
case State::VENUE_READY:
case State::CONNECTED:
bts_assert(!st.is_connected);
me->state = State::VENUE_NOT_READY;
me->state = State::DISCONNECTED;
break;
}
api::orderman::GatewayStatusUpdate update;
*update.mutable_timestamp() = utils::pb::to_timestamp(datetime::now());
update.set_gateway_name(st.name.value());
update.set_gateway_status(st.is_connected?
api::orderman::GATEWAYSTATUS_READY :
api::orderman::GATEWAYSTATUS_NOT_READY);
std::vector<api::orderman::GatewayStatusUpdate> pub {update};
me->publish_gateway_status(&pub,nullptr,nullptr);
}
void OrderServiceServer::on_native_order_state_change(event::NativeOrderStateChange const&o)
@@ -365,8 +379,8 @@ void OrderServiceServer::create_order(const api::orderman::CreateOrderRequest& r
return;
}
if (me->state == State::VENUE_NOT_READY) {
resp.set_error_code(api::orderman::OE_VENUE_NOT_READY);
if (me->state == State::DISCONNECTED) {
resp.set_error_code(api::orderman::OE_GATEWAY_NOT_READY);
on_reply(resp);
return;
}
@@ -410,8 +424,8 @@ void OrderServiceServer::cancel_order(const api::orderman::CancelOrderRequest& c
api::orderman::CancelOrderResponse resp;
resp.set_order_key(cancel.order_key());
if (me->state == State::VENUE_NOT_READY) {
resp.set_error_code(api::orderman::OE_VENUE_NOT_READY);
if (me->state == State::DISCONNECTED) {
resp.set_error_code(api::orderman::OE_GATEWAY_NOT_READY);
on_reply(resp);
return;
}
@@ -450,8 +464,8 @@ void OrderServiceServer::update_order(const api::orderman::UpdateOrderRequest& u
auto const&native = update.native_order();
if (me->state == State::VENUE_NOT_READY) {
resp.set_error_code(api::orderman::OE_VENUE_NOT_READY);
if (me->state == State::DISCONNECTED) {
resp.set_error_code(api::orderman::OE_GATEWAY_NOT_READY);
on_reply(resp);
return;
}
@@ -134,7 +134,7 @@ SqliteStore::Data SqliteStore::retrieve_all() {
std::pair<bool,std::string> SqliteStore::retrieve_one(std::string const&ns, std::string const&k)
{
auto query_str = fmt::format ("select ns,key,value from store where ns='{}' and k='{}", ns,k);
auto query_str = fmt::format ("select ns,key,value from store where ns='{}' and k='{}'", ns,k);
sqlite3_stmt_ptr query = utils::prepare_query(me->conn,query_str.c_str());
std::pair<bool,std::string> result {false,""};
@@ -6,12 +6,14 @@
#include "lib/logging/logging.h"
#include "lib/config/config.h"
#include "lib/config/protos/logging.pb.h"
#include "lib/utils/bts_assert.h"
namespace bts {
int run_tests (int argc, char **argv)
int run_tests (std::vector<std::string> const&args)
{
// these are necessary to work around an issue with the catch auto
// registration
// https://groups.google.com/forum/#!msg/catch-forum/FV0Qo62DvgY/jxEO6c9_q3kJ
@@ -26,7 +28,12 @@ int run_tests (int argc, char **argv)
cfg.mutable_console()->set_default_level("Fatal");
log::configure_logging(cfg);
int result = Catch::Session().run( argc, argv );
bts_assert(args.size() < 100);
char const *argv[100];
for (size_t i = 1; i < args.size();i++)
argv[i-1] = args[i].c_str();
int result = Catch::Session().run( args.size()-1, argv );
return ( result < 0xff ? result : 0xff );
}
}
@@ -1,5 +1,8 @@
#pragma once
#include <vector>
#include <string>
namespace bts {
int run_tests (int argc, char **argv);
int run_tests (std::vector<std::string> const&args);
}
+1 -1
View File
@@ -17,4 +17,4 @@ fi
# and ssh for diagnostics
/usr/sbin/sshd
# and sparkd
./src/server/sparkd/sparkd
./src/server/sparkd/sparkd run
+8 -5
View File
@@ -1,11 +1,14 @@
@echo off
@setlocal
cd %~dp0\..
set ROOT=%cd%
mkdir c:\build 2> nul
pushd c:\build
rmdir /s /q Debug
rmdir /s /q Release
cmake.exe -G "Visual Studio 15 2017 Win64" ..
popd
rmdir /s /q c:\build\Debug
rmdir /s /q c:\build\Release
cd c:\build
c:
cmake.exe -G "Visual Studio 15 2017 Win64" %ROOT%
cd %ROOT%
P:
copy /y tools\cpp.build.props c:\build\Directory.Build.Props
del c:\build\spark.sln