Merge pull request #284 from Hackerpilot/unix-domain-sockets
Unix domain sockets
This commit is contained in:
commit
82ecc2d27a
17
README.md
17
README.md
|
@ -60,6 +60,23 @@ the issue.)
|
|||
1. ```dub build --build=release --config=server```
|
||||
|
||||
|
||||
# Sockets
|
||||
## TCP
|
||||
On Windows DCD will use TCP sockets to communicate between the client and server.
|
||||
Other operating systems can use TCP sockets if the client and server use the `--tcp`
|
||||
command-line switch.
|
||||
|
||||
## UNIX domain sockets
|
||||
Operating systems that support UNIX domain sockets will use them by default.
|
||||
|
||||
#### OSX
|
||||
The socket will be created at `/var/tmp/dcd-${UID}.socket`
|
||||
|
||||
#### Linux/BSD
|
||||
The client and server will attempt to create the socket in the following locations:
|
||||
* `${XDG_RUNTIME_DIR}/dcd.socket`
|
||||
* `/tmp/dcd-${UID}.socket`
|
||||
|
||||
# Client
|
||||
Because DCD is designed to be used from a text editor, this section is written
|
||||
primarily for plugin authors.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.TH dcd-client 1 "Oct 30 2015" "" https://github.com/Hackerpilot/DCD
|
||||
.TH dcd-client 1 "Jan 15 2016" "" https://github.com/Hackerpilot/DCD
|
||||
.SH NAME
|
||||
dcd-client \- autocompletion client for the D programming language
|
||||
.PD
|
||||
|
@ -6,6 +6,8 @@ dcd-client \- autocompletion client for the D programming language
|
|||
.SY dcd-client
|
||||
.OP "\-c, \-\-cursorPos" cursorPosition
|
||||
.OP "\-p, \-\-port" portNumber
|
||||
.OP \-\-tcp
|
||||
.OP \-\-socketFile filePath
|
||||
.OP "\-I" directory
|
||||
.OP "\-h, \-\-help"
|
||||
.OP "\-l, \-\-symbolLocation"
|
||||
|
@ -34,7 +36,20 @@ position is measured in bytes from the beginning of the source code.
|
|||
.RS
|
||||
Choose the port number on which
|
||||
.B dcd-client
|
||||
listens.
|
||||
listens. This has no effect unless
|
||||
.B dcd-client
|
||||
is being run on Windows or the \-\-tcp switch is used.
|
||||
.RE
|
||||
.B \-\-tcp
|
||||
.RS
|
||||
Listen on a TCP socket instead of a UNIX domain socket. This is the default on
|
||||
Windows.
|
||||
.RE
|
||||
.B \-\-socketFile
|
||||
.I filePath
|
||||
.RS
|
||||
Set the path to use for the UNIX domain socket. Has no effect if the \-\-tcp
|
||||
switch is used.
|
||||
.RE
|
||||
.B \-I
|
||||
.I directory
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.TH dcd-server 1 "Oct 30 2015" "" https://github.com/Hackerpilot/DCD
|
||||
.TH dcd-server 1 "Jan 15 2016" "" https://github.com/Hackerpilot/DCD
|
||||
.SH NAME
|
||||
dcd-server \- autocompletion server for the D programming language
|
||||
.PD
|
||||
|
@ -6,6 +6,8 @@ dcd-server \- autocompletion server for the D programming language
|
|||
.SY dcd-server
|
||||
.OP \-I directory
|
||||
.OP \-p|\-\-port portNumber
|
||||
.OP \-\-tcp
|
||||
.OP \-\-socketFile filePath
|
||||
.OP \-\-logLevel level
|
||||
.OP \-h|\-\-help
|
||||
.OP \-\-version
|
||||
|
@ -20,7 +22,20 @@ dcd-server \- autocompletion server for the D programming language
|
|||
.RS
|
||||
Choose the port number on which
|
||||
.B dcd-server
|
||||
listens.
|
||||
listens. This has no effect unless
|
||||
.B dcd-server
|
||||
is being run on Windows or the \-\-tcp switch is used.
|
||||
.RE
|
||||
.B \-\-tcp
|
||||
.RS
|
||||
Listen on a TCP socket instead of a UNIX domain socket. This is the default on
|
||||
Windows.
|
||||
.RE
|
||||
.B \-\-socketFile
|
||||
.I filePath
|
||||
.RS
|
||||
Set the path to use for the UNIX domain socket. Has no effect if the \-\-tcp
|
||||
switch is used.
|
||||
.RE
|
||||
.B \-\-logLevel
|
||||
.I level
|
||||
|
@ -60,10 +75,10 @@ This file should be placed in one of the following locations:
|
|||
.I /etc/dcd.conf
|
||||
.RE
|
||||
.IP \(bu
|
||||
.I $XDG_CONFIG_HOME/dcd/dcd.conf
|
||||
.I ${XDG_CONFIG_HOME}/dcd/dcd.conf
|
||||
.RE
|
||||
.IP \(bu
|
||||
.I $HOME/.config/dcd/dcd.conf
|
||||
.I ${HOME}/.config/dcd/dcd.conf
|
||||
.RE
|
||||
|
||||
Each line in the file should be a path to search for D source files. A line in
|
||||
|
@ -73,6 +88,18 @@ is equivalent to passing that same line to
|
|||
with the
|
||||
.I -I
|
||||
option. Lines that start with the '#' character are ignored.
|
||||
|
||||
Unless the \-\-tcp switch is used,
|
||||
.B dcd-server
|
||||
will default to communicating with the client over a UNIX domain socket.
|
||||
.B dcd-server
|
||||
will attempt to create the socket in the following locations:
|
||||
.IP \(bu
|
||||
.I ${XDG_RUNTIME_DIR}/dcd.socket
|
||||
.RE
|
||||
.IP \(bu
|
||||
.I /tmp/dcd-${UID}.socket
|
||||
.RE
|
||||
.SH AUTHOR
|
||||
Written by Brian Schott (@Hackerpilot on Github)
|
||||
.PD
|
||||
|
|
|
@ -33,6 +33,7 @@ import std.experimental.logger;
|
|||
import msgpack;
|
||||
import common.messages;
|
||||
import common.dcd_version;
|
||||
import common.socket;
|
||||
|
||||
int main(string[] args)
|
||||
{
|
||||
|
@ -48,6 +49,16 @@ int main(string[] args)
|
|||
bool printVersion;
|
||||
bool listImports;
|
||||
string search;
|
||||
version(Windows)
|
||||
{
|
||||
bool useTCP = true;
|
||||
string socketFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool useTCP = false;
|
||||
string socketFile = generateSocketName();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -55,7 +66,8 @@ int main(string[] args)
|
|||
"port|p", &port, "help|h", &help, "shutdown", &shutdown,
|
||||
"clearCache", &clearCache, "symbolLocation|l", &symbolLocation,
|
||||
"doc|d", &doc, "query|status|q", &query, "search|s", &search,
|
||||
"version", &printVersion, "listImports", &listImports);
|
||||
"version", &printVersion, "listImports", &listImports,
|
||||
"tcp", &useTCP, "socketFile", &socketFile);
|
||||
}
|
||||
catch (ConvException e)
|
||||
{
|
||||
|
@ -66,6 +78,12 @@ int main(string[] args)
|
|||
|
||||
AutocompleteRequest request;
|
||||
|
||||
if (help)
|
||||
{
|
||||
printHelp(args[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (printVersion)
|
||||
{
|
||||
version (Windows)
|
||||
|
@ -76,16 +94,21 @@ int main(string[] args)
|
|||
write(DCD_VERSION, " ", GIT_HASH);
|
||||
return 0;
|
||||
}
|
||||
else if (help)
|
||||
|
||||
version (Windows) if (socketFile !is null)
|
||||
{
|
||||
printHelp(args[0]);
|
||||
return 0;
|
||||
fatal("UNIX domain sockets not supported on Windows");
|
||||
return 1;
|
||||
}
|
||||
else if (query)
|
||||
|
||||
if (useTCP)
|
||||
socketFile = null;
|
||||
|
||||
if (query)
|
||||
{
|
||||
try
|
||||
{
|
||||
TcpSocket socket = createSocket(port);
|
||||
Socket socket = createSocket(socketFile, port);
|
||||
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
|
||||
request.kind = RequestKind.query;
|
||||
if (sendRequest(socket, request))
|
||||
|
@ -112,7 +135,7 @@ int main(string[] args)
|
|||
request.kind = RequestKind.shutdown;
|
||||
else if (clearCache)
|
||||
request.kind = RequestKind.clearCache;
|
||||
TcpSocket socket = createSocket(port);
|
||||
Socket socket = createSocket(socketFile, port);
|
||||
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
|
||||
return sendRequest(socket, request) ? 0 : 1;
|
||||
}
|
||||
|
@ -122,7 +145,7 @@ int main(string[] args)
|
|||
request.importPaths = importPaths.map!(a => absolutePath(a)).array;
|
||||
if (cursorPos == size_t.max)
|
||||
{
|
||||
TcpSocket socket = createSocket(port);
|
||||
Socket socket = createSocket(socketFile, port);
|
||||
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
|
||||
if (!sendRequest(socket, request))
|
||||
return 1;
|
||||
|
@ -132,7 +155,7 @@ int main(string[] args)
|
|||
else if (listImports)
|
||||
{
|
||||
request.kind |= RequestKind.listImports;
|
||||
TcpSocket socket = createSocket(port);
|
||||
Socket socket = createSocket(socketFile, port);
|
||||
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
|
||||
sendRequest(socket, request);
|
||||
AutocompleteResponse response = getResponse(socket);
|
||||
|
@ -194,7 +217,7 @@ int main(string[] args)
|
|||
request.kind |= RequestKind.autocomplete;
|
||||
|
||||
// Send message to server
|
||||
TcpSocket socket = createSocket(port);
|
||||
Socket socket = createSocket(socketFile, port);
|
||||
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
|
||||
if (!sendRequest(socket, request))
|
||||
return 1;
|
||||
|
@ -266,16 +289,33 @@ Options:
|
|||
|
||||
--port PORTNUMBER | -p PORTNUMBER
|
||||
Uses PORTNUMBER to communicate with the server instead of the default
|
||||
port 9166.`, programName);
|
||||
port 9166. Only used on Windows or when the --tcp option is set.
|
||||
|
||||
--tcp
|
||||
Send requests on a TCP socket instead of a UNIX domain socket. This
|
||||
switch has no effect on Windows.
|
||||
|
||||
--socketFile FILENAME
|
||||
Use the given FILENAME as the path to the UNIX domain socket. Using
|
||||
this switch is an error on Windows.`, programName);
|
||||
}
|
||||
|
||||
TcpSocket createSocket(ushort port)
|
||||
Socket createSocket(string socketFile, ushort port)
|
||||
{
|
||||
import core.time : dur;
|
||||
|
||||
TcpSocket socket = new TcpSocket(AddressFamily.INET);
|
||||
Socket socket;
|
||||
if (socketFile is null)
|
||||
{
|
||||
socket = new TcpSocket(AddressFamily.INET);
|
||||
socket.connect(new InternetAddress("localhost", port));
|
||||
}
|
||||
else
|
||||
{
|
||||
socket = new Socket(AddressFamily.UNIX, SocketType.STREAM);
|
||||
socket.connect(new UnixAddress(socketFile));
|
||||
}
|
||||
socket.setOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, dur!"seconds"(5));
|
||||
socket.connect(new InternetAddress("localhost", port));
|
||||
socket.blocking = true;
|
||||
return socket;
|
||||
}
|
||||
|
@ -283,7 +323,7 @@ TcpSocket createSocket(ushort port)
|
|||
/**
|
||||
* Returns: true on success
|
||||
*/
|
||||
bool sendRequest(TcpSocket socket, AutocompleteRequest request)
|
||||
bool sendRequest(Socket socket, AutocompleteRequest request)
|
||||
{
|
||||
ubyte[] message = msgpack.pack(request);
|
||||
ubyte[] messageBuffer = new ubyte[message.length + message.length.sizeof];
|
||||
|
@ -296,7 +336,7 @@ bool sendRequest(TcpSocket socket, AutocompleteRequest request)
|
|||
/**
|
||||
* Gets the response from the server
|
||||
*/
|
||||
AutocompleteResponse getResponse(TcpSocket socket)
|
||||
AutocompleteResponse getResponse(Socket socket)
|
||||
{
|
||||
ubyte[1024 * 16] buffer;
|
||||
auto bytesReceived = socket.receive(buffer);
|
||||
|
|
|
@ -21,7 +21,7 @@ module common.dcd_version;
|
|||
/**
|
||||
* Human-readable version number
|
||||
*/
|
||||
enum DCD_VERSION = "v0.7.5";
|
||||
enum DCD_VERSION = "v0.8.0-alpha1";
|
||||
|
||||
version (Windows) {}
|
||||
else version (built_with_dub) {}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* This file is part of DCD, a development tool for the D programming language.
|
||||
* Copyright (C) 2015 Brian Schott
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module common.socket;
|
||||
|
||||
import core.sys.posix.unistd; // getuid
|
||||
import std.format;
|
||||
import std.process;
|
||||
import std.path;
|
||||
|
||||
version (OSX) version = haveUnixSockets;
|
||||
version (linux) version = haveUnixSockets;
|
||||
version (BSD) version = haveUnixSockets;
|
||||
version (FreeBSD) version = haveUnixSockets;
|
||||
|
||||
string generateSocketName()
|
||||
{
|
||||
version (haveUnixSockets)
|
||||
{
|
||||
immutable string socketFileName = "dcd-%d.socket".format(getuid());
|
||||
version (OSX)
|
||||
return buildPath("/", "var", "tmp", socketFileName);
|
||||
else
|
||||
{
|
||||
immutable string xdg = environment.get("XDG_RUNTIME_DIR");
|
||||
return xdg is null ? buildPath("/", "tmp", socketFileName) : buildPath(xdg,
|
||||
"dcd.socket");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,30 +18,33 @@
|
|||
|
||||
module server.server;
|
||||
|
||||
import std.socket;
|
||||
import std.stdio;
|
||||
import std.getopt;
|
||||
import core.sys.posix.sys.stat;
|
||||
import std.algorithm;
|
||||
import std.path;
|
||||
import std.file;
|
||||
import std.array;
|
||||
import std.process;
|
||||
import std.datetime;
|
||||
import std.conv;
|
||||
import std.datetime;
|
||||
import std.exception : enforce;
|
||||
import std.experimental.allocator;
|
||||
import std.experimental.allocator.mallocator;
|
||||
import std.exception : enforce;
|
||||
import std.experimental.logger;
|
||||
import std.file;
|
||||
import std.file;
|
||||
import std.getopt;
|
||||
import std.path;
|
||||
import std.process;
|
||||
import std.socket;
|
||||
import std.stdio;
|
||||
|
||||
import msgpack;
|
||||
|
||||
import dsymbol.string_interning;
|
||||
|
||||
import common.dcd_version;
|
||||
import common.messages;
|
||||
import server.autocomplete;
|
||||
import common.socket;
|
||||
import dsymbol.modulecache;
|
||||
import dsymbol.symbol;
|
||||
import common.dcd_version;
|
||||
import server.autocomplete;
|
||||
|
||||
/// Name of the server configuration file
|
||||
enum CONFIG_FILE_NAME = "dcd.conf";
|
||||
|
@ -59,12 +62,22 @@ int main(string[] args)
|
|||
bool ignoreConfig;
|
||||
string[] importPaths;
|
||||
LogLevel level = globalLogLevel;
|
||||
version(Windows)
|
||||
{
|
||||
bool useTCP = true;
|
||||
string socketFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool useTCP = false;
|
||||
string socketFile = generateSocketName();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
getopt(args, "port|p", &port, "I", &importPaths, "help|h", &help,
|
||||
"version", &printVersion, "ignoreConfig", &ignoreConfig,
|
||||
"logLevel", &level);
|
||||
"logLevel", &level, "tcp", &useTCP, "socketFile", &socketFile);
|
||||
}
|
||||
catch (ConvException e)
|
||||
{
|
||||
|
@ -73,11 +86,6 @@ int main(string[] args)
|
|||
return 1;
|
||||
}
|
||||
|
||||
globalLogLevel = level;
|
||||
|
||||
info("Starting up...");
|
||||
StopWatch sw = StopWatch(AutoStart.yes);
|
||||
|
||||
if (printVersion)
|
||||
{
|
||||
version (Windows)
|
||||
|
@ -95,19 +103,52 @@ int main(string[] args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
version (Windows) if (socketFile !is null)
|
||||
{
|
||||
fatal("UNIX domain sockets not supported on Windows");
|
||||
return 1;
|
||||
}
|
||||
|
||||
globalLogLevel = level;
|
||||
|
||||
info("Starting up...");
|
||||
StopWatch sw = StopWatch(AutoStart.yes);
|
||||
|
||||
if (!ignoreConfig)
|
||||
importPaths ~= loadConfiguredImportDirs();
|
||||
|
||||
auto socket = new TcpSocket(AddressFamily.INET);
|
||||
socket.blocking = true;
|
||||
socket.setOption(SocketOptionLevel.SOCKET, SocketOption.REUSEADDR, true);
|
||||
socket.bind(new InternetAddress("localhost", port));
|
||||
Socket socket;
|
||||
if (useTCP)
|
||||
{
|
||||
socket = new TcpSocket(AddressFamily.INET);
|
||||
socket.blocking = true;
|
||||
socket.setOption(SocketOptionLevel.SOCKET, SocketOption.REUSEADDR, true);
|
||||
socket.bind(new InternetAddress("localhost", port));
|
||||
info("Listening on port ", port);
|
||||
}
|
||||
else
|
||||
{
|
||||
socket = new Socket(AddressFamily.UNIX, SocketType.STREAM);
|
||||
if (exists(socketFile))
|
||||
{
|
||||
info("Cleaning up old socket file at ", socketFile);
|
||||
remove(socketFile);
|
||||
}
|
||||
socket.blocking = true;
|
||||
socket.setOption(SocketOptionLevel.SOCKET, SocketOption.REUSEADDR, true);
|
||||
socket.bind(new UnixAddress(socketFile));
|
||||
setAttributes(socketFile, S_IRUSR | S_IWUSR);
|
||||
info("Listening at ", socketFile);
|
||||
}
|
||||
socket.listen(0);
|
||||
|
||||
scope (exit)
|
||||
{
|
||||
info("Shutting down sockets...");
|
||||
socket.shutdown(SocketShutdown.BOTH);
|
||||
socket.close();
|
||||
if (!useTCP)
|
||||
remove(socketFile);
|
||||
info("Sockets shut down.");
|
||||
}
|
||||
|
||||
|
@ -126,22 +167,28 @@ int main(string[] args)
|
|||
version (Posix) chdir("/");
|
||||
|
||||
version (LittleEndian)
|
||||
immutable expectedClient = IPv4Union([127, 0, 0, 1]);
|
||||
else
|
||||
immutable expectedClient = IPv4Union([1, 0, 0, 127]);
|
||||
else
|
||||
immutable expectedClient = IPv4Union([127, 0, 0, 1]);
|
||||
|
||||
serverLoop: while (true)
|
||||
{
|
||||
auto s = socket.accept();
|
||||
s.blocking = true;
|
||||
|
||||
// Only accept connections from localhost
|
||||
IPv4Union actual;
|
||||
InternetAddress clientAddr = cast(InternetAddress) s.remoteAddress();
|
||||
actual.i = clientAddr.addr;
|
||||
// Shut down if somebody tries connecting from outside
|
||||
enforce(actual.i = expectedClient.i, "Connection attempted from "
|
||||
~ clientAddr.toAddrString());
|
||||
if (useTCP)
|
||||
{
|
||||
// Only accept connections from localhost
|
||||
IPv4Union actual;
|
||||
InternetAddress clientAddr = cast(InternetAddress) s.remoteAddress();
|
||||
actual.i = clientAddr.addr;
|
||||
// Shut down if somebody tries connecting from outside
|
||||
if (actual.i != expectedClient.i)
|
||||
{
|
||||
fatal("Connection attempted from ", clientAddr.toAddrString());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
scope (exit)
|
||||
{
|
||||
|
@ -340,9 +387,18 @@ options:
|
|||
Prints the version number and then exits.
|
||||
|
||||
--port PORTNUMBER | -pPORTNUMBER
|
||||
Listens on PORTNUMBER instead of the default port 9166.
|
||||
Listens on PORTNUMBER instead of the default port 9166 when TCP sockets
|
||||
are used.
|
||||
|
||||
--logLevel LEVEL
|
||||
The logging level. Valid values are 'all', 'trace', 'info', 'warning',
|
||||
'error', 'critical', 'fatal', and 'off'`, programName);
|
||||
'error', 'critical', 'fatal', and 'off'.
|
||||
|
||||
--tcp
|
||||
Listen on a TCP socket instead of a UNIX domain socket. This switch
|
||||
has no effect on Windows.
|
||||
|
||||
--socketFile FILENAME
|
||||
Use the given FILENAME as the path to the UNIX domain socket. Using
|
||||
this switch is an error on Windows.`, programName);
|
||||
}
|
||||
|
|
|
@ -11,35 +11,52 @@ pass_count=0
|
|||
# Make sure that the server is shut down
|
||||
echo "Shutting down currently-running server..."
|
||||
../bin/dcd-client --shutdown 2>/dev/null > /dev/null
|
||||
../bin/dcd-client --shutdown --tcp 2>/dev/null > /dev/null
|
||||
sleep 1s;
|
||||
|
||||
# Start up the server
|
||||
echo "Starting server..."
|
||||
../bin/dcd-server --ignoreConfig -I $IMPORTS 2>stderr.txt > stdout.txt &
|
||||
sleep 1s;
|
||||
for socket in unix tcp; do
|
||||
echo "Running tests for $socket sockets"
|
||||
|
||||
# Run tests
|
||||
for testCase in tc*; do
|
||||
cd $testCase;
|
||||
|
||||
./run.sh;
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${YELLOW}$testCase:${NORMAL} ... ${GREEN}Pass${NORMAL}";
|
||||
let pass_count=pass_count+1
|
||||
# Start up the server
|
||||
echo "Starting server..."
|
||||
if [[ $socket == "unix" ]]; then
|
||||
../bin/dcd-server --ignoreConfig -I $IMPORTS 2>stderr.txt > stdout.txt &
|
||||
else
|
||||
echo -e "${YELLOW}$testCase:${NORMAL} ... ${RED}Fail${NORMAL}";
|
||||
let fail_count=fail_count+1
|
||||
../bin/dcd-server --tcp --ignoreConfig -I $IMPORTS 2>stderr.txt > stdout.txt &
|
||||
fi
|
||||
sleep 1s;
|
||||
|
||||
cd - > /dev/null;
|
||||
# Run tests
|
||||
for testCase in tc*; do
|
||||
cd $testCase
|
||||
|
||||
if [[ $socket == "unix" ]]; then
|
||||
./run.sh ""
|
||||
else
|
||||
./run.sh "--tcp"
|
||||
fi
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo -e "${YELLOW}$socket:$testCase:${NORMAL} ... ${GREEN}Pass${NORMAL}";
|
||||
let pass_count=pass_count+1
|
||||
else
|
||||
echo -e "${YELLOW}$socket:$testCase:${NORMAL} ... ${RED}Fail${NORMAL}";
|
||||
let fail_count=fail_count+1
|
||||
fi
|
||||
|
||||
cd - > /dev/null;
|
||||
done
|
||||
|
||||
# Shut down
|
||||
echo "Shutting down server..."
|
||||
if [[ $socket == "unix" ]]; then
|
||||
../bin/dcd-client --shutdown 2>/dev/null > /dev/null
|
||||
else
|
||||
../bin/dcd-client --shutdown --tcp 2>/dev/null > /dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# Shut down
|
||||
echo "Shutting down server..."
|
||||
../bin/dcd-client --shutdown 2>/dev/null > /dev/null
|
||||
|
||||
# Report
|
||||
if [ $fail_count -eq 0 ]; then
|
||||
if [[ $fail_count -eq 0 ]]; then
|
||||
echo -e "${GREEN}${pass_count} tests passed and ${fail_count} failed.${NORMAL}"
|
||||
else
|
||||
echo -e "${RED}${pass_count} tests passed and ${fail_count} failed.${NORMAL}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c12 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c12 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c52 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c52 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c839 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c839 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c862 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c862 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c13 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c13 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c154 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c154 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c184 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c184 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c199 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c199 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
||||
../../bin/dcd-client file.d -c216 > actual3.txt
|
||||
../../bin/dcd-client $1 file.d -c216 > actual3.txt
|
||||
diff actual3.txt expected3.txt
|
||||
|
||||
../../bin/dcd-client file.d -c231 > actual4.txt
|
||||
../../bin/dcd-client $1 file.d -c231 > actual4.txt
|
||||
diff actual4.txt expected4.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c97 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c97 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c130 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c130 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c113 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c113 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c83 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c83 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c93 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c93 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
||||
../../bin/dcd-client file.d -c148 > actual3.txt
|
||||
../../bin/dcd-client $1 file.d -c148 > actual3.txt
|
||||
diff actual3.txt expected3.txt
|
||||
|
|
|
@ -6,12 +6,12 @@ cp testfile1_old.d ../imports/testfile1.d
|
|||
# than one second
|
||||
sleep 1s;
|
||||
|
||||
../../bin/dcd-client file.d -c84 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c84 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
cp testfile1_new.d ../imports/testfile1.d
|
||||
# Same here
|
||||
sleep 1s;
|
||||
|
||||
../../bin/dcd-client file.d -c84 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c84 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c48 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c48 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c35 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c35 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c61 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c61 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c187 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c187 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c211 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c211 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -6,12 +6,12 @@ cp testfile2_old.d ../imports/testfile2.d
|
|||
# than one second
|
||||
sleep 1s;
|
||||
|
||||
../../bin/dcd-client file.d -c39 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c39 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
cp testfile2_new.d ../imports/testfile2.d
|
||||
# Same here
|
||||
sleep 1s;
|
||||
|
||||
../../bin/dcd-client file.d -c39 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c39 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file1.d -c84 > actual1.txt
|
||||
../../bin/dcd-client $1 file1.d -c84 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file2.d -c73 > actual2.txt
|
||||
../../bin/dcd-client $1 file2.d -c73 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c24 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c24 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c57 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c57 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c33 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c33 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c61 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c61 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c88 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c88 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c84 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c84 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c111 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c111 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c159 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c159 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c199 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c199 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c1 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c1 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c16 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c16 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c117 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c117 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c89 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c89 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c286 -d > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c286 -d > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client file.d -c290 -d > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c290 -d > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
||||
../../bin/dcd-client file.d -c294 -d > actual3.txt
|
||||
../../bin/dcd-client $1 file.d -c294 -d > actual3.txt
|
||||
diff actual3.txt expected3.txt
|
||||
|
||||
../../bin/dcd-client file.d -c298 -d> actual4.txt
|
||||
../../bin/dcd-client $1 file.d -c298 -d> actual4.txt
|
||||
diff actual4.txt expected4.txt
|
||||
|
||||
../../bin/dcd-client file.d -c302 -d> actual5.txt
|
||||
../../bin/dcd-client $1 file.d -c302 -d> actual5.txt
|
||||
diff actual5.txt expected5.txt
|
||||
|
||||
../../bin/dcd-client file.d -c306 -d> actual6.txt
|
||||
../../bin/dcd-client $1 file.d -c306 -d> actual6.txt
|
||||
diff actual6.txt expected6.txt
|
||||
|
||||
../../bin/dcd-client file.d -c313 -d> actual7.txt
|
||||
../../bin/dcd-client $1 file.d -c313 -d> actual7.txt
|
||||
diff actual7.txt expected7.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c94 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c94 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client file.d -c53 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c53 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
|
Loading…
Reference in New Issue