From 714924856d6d3149bebc01678ec0e13eb3ed2841 Mon Sep 17 00:00:00 2001 From: Martin Regen Date: Fri, 12 Jan 2018 16:06:48 +0100 Subject: [PATCH] fix mono test scrip and client --- .../Samples/NetCoreConsoleClient/Program.cs | 32 ++++++++++++++----- .../Samples/NetCoreConsoleServer/Program.cs | 5 ++- testclientserver.sh | 10 +++--- testmonoclientserver.sh | 14 ++++---- 4 files changed, 42 insertions(+), 19 deletions(-) mode change 100644 => 100755 testmonoclientserver.sh diff --git a/SampleApplications/Samples/NetCoreConsoleClient/Program.cs b/SampleApplications/Samples/NetCoreConsoleClient/Program.cs index 2d967ddc70..bf3d3522f7 100644 --- a/SampleApplications/Samples/NetCoreConsoleClient/Program.cs +++ b/SampleApplications/Samples/NetCoreConsoleClient/Program.cs @@ -42,7 +42,9 @@ namespace NetCoreConsoleClient public static int Main(string[] args) { - Console.WriteLine(".Net Core OPC UA Console Client sample"); + Console.WriteLine( + (Utils.IsRunningOnMono() ? "Mono" : ".Net Core") + + " OPC UA Console Client sample"); // command line options bool showHelp = false; @@ -115,6 +117,25 @@ namespace NetCoreConsoleClient Console.WriteLine("1 - Create an Application Configuration."); exitCode = ExitCode.ErrorCreateApplication; + CertificateIdentifier applicationCert; + if (Utils.IsRunningOnMono()) + { + applicationCert = new CertificateIdentifier + { + StoreType = "Directory", + StorePath = "OPC Foundation/CertificateStores/MachineAccount", + SubjectName = "UA Core Sample Client" + }; + } + else + { + applicationCert = new CertificateIdentifier + { + StoreType = "X509Store", + StorePath = "CurrentUser\\My", + SubjectName = "UA Core Sample Client" + }; + } Utils.SetTraceOutput(Utils.TraceOutput.DebugAndFile); var config = new ApplicationConfiguration() { @@ -123,12 +144,7 @@ namespace NetCoreConsoleClient ApplicationUri = "urn:" + Utils.GetHostName() + ":OPCFoundation:CoreSampleClient", SecurityConfiguration = new SecurityConfiguration { - ApplicationCertificate = new CertificateIdentifier - { - StoreType = "X509Store", - StorePath = "CurrentUser\\My", - SubjectName = "UA Core Sample Client" - }, + ApplicationCertificate = applicationCert, TrustedPeerCertificates = new CertificateTrustList { StoreType = "Directory", @@ -207,7 +223,7 @@ namespace NetCoreConsoleClient exitCode = ExitCode.ErrorCreateSession; var endpointConfiguration = EndpointConfiguration.Create(config); var endpoint = new ConfiguredEndpoint(null, selectedEndpoint, endpointConfiguration); - var session = await Session.Create(config, endpoint, false, ".Net Core OPC UA Console Client", 60000, new UserIdentity(new AnonymousIdentityToken()), null); + var session = await Session.Create(config, endpoint, false, "OPC UA Console Client", 60000, new UserIdentity(new AnonymousIdentityToken()), null); Console.WriteLine("4 - Browse the OPC UA server namespace."); exitCode = ExitCode.ErrorBrowseNamespace; diff --git a/SampleApplications/Samples/NetCoreConsoleServer/Program.cs b/SampleApplications/Samples/NetCoreConsoleServer/Program.cs index d58f28a0c7..152ac44093 100644 --- a/SampleApplications/Samples/NetCoreConsoleServer/Program.cs +++ b/SampleApplications/Samples/NetCoreConsoleServer/Program.cs @@ -75,7 +75,10 @@ namespace NetCoreConsoleServer public static int Main(string[] args) { - Console.WriteLine(".Net Core OPC UA Console Server sample"); + Console.WriteLine( + (Utils.IsRunningOnMono() ? "Mono" : ".Net Core") + + " OPC UA Console Server sample"); + // command line options bool showHelp = false; diff --git a/testclientserver.sh b/testclientserver.sh index ca6159ca8e..5cb3abd6bc 100755 --- a/testclientserver.sh +++ b/testclientserver.sh @@ -5,6 +5,7 @@ testresult=0 cd SampleApplications/Samples/NetCoreConsoleServer echo build server +rm -r obj dotnet build NetCoreConsoleServer.csproj echo start server dotnet run --no-restore --no-build --project NetCoreConsoleServer.csproj -t 60 -a & @@ -13,9 +14,10 @@ cd $workdir cd SampleApplications/Samples/NetCoreConsoleClient echo build client -dotnet build NetCoreConsoleServer.csproj +rm -r obj +dotnet build NetCoreConsoleClient.csproj echo start client -dotnet run --no-restore --no-build --project NetCoreConsoleServer.csproj -t 20 & +dotnet run --no-restore --no-build --project NetCoreConsoleClient.csproj -t 20 & clientpid="$!" cd $workdir @@ -35,8 +37,8 @@ serverresult=$? if [ $? -eq 0 ]; then echo "SUCCESS - Server test passed" else - testresult=$? - echo "FAILED - Server test failed with a status of $testresult" + serverresult=$? + echo "FAILED - Server test failed with a status of $serverresult" fi exit $testresult diff --git a/testmonoclientserver.sh b/testmonoclientserver.sh old mode 100644 new mode 100755 index da61be0f29..1476ee511f --- a/testmonoclientserver.sh +++ b/testmonoclientserver.sh @@ -5,18 +5,20 @@ testresult=0 cd SampleApplications/Samples/NetCoreConsoleServer echo build server -msbuild /p:configuration=Debug /t:restore,compile MonoConsoleServer.csproj +rm -r obj +msbuild /p:configuration=Debug /t:restore,build MonoConsoleServer.csproj echo start server -cd SampleApplications/Samples/NetCoreConsoleServer/bin/Debug/net46 +cd bin/Debug/net46 mono MonoConsoleServer.exe -t 60 -a & serverpid="$!" cd $workdir cd SampleApplications/Samples/NetCoreConsoleClient echo build client -msbuild /p:configuration=Debug /t:restore,compile MonoConsoleClient.csproj +rm -r obj +msbuild /p:configuration=Debug /t:restore,build MonoConsoleClient.csproj echo start client -cd SampleApplications/Samples/NetCoreConsoleClient/bin/Debug/net46 +cd bin/Debug/net46 mono MonoConsoleClient.exe -t 20 & clientpid="$!" cd $workdir @@ -37,8 +39,8 @@ serverresult=$? if [ $? -eq 0 ]; then echo "SUCCESS - Server test passed" else - testresult=$? - echo "FAILED - Server test failed with a status of $testresult" + serverresult=$? + echo "FAILED - Server test failed with a status of $serverresult" fi exit $testresult