Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
7fd281ac
Commit
7fd281ac
authored
13 years ago
by
Nat Goodspeed
Browse files
Options
Downloads
Patches
Plain Diff
Reduce redundancy in llprocess_test.cpp using get_test_name().
parent
063edac4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llcommon/tests/llprocess_test.cpp
+23
-23
23 additions, 23 deletions
indra/llcommon/tests/llprocess_test.cpp
with
23 additions
and
23 deletions
indra/llcommon/tests/llprocess_test.cpp
+
23
−
23
View file @
7fd281ac
...
@@ -620,7 +620,7 @@ namespace tut
...
@@ -620,7 +620,7 @@ namespace tut
// guaranteed to exist on every machine, under every OS? Have to
// guaranteed to exist on every machine, under every OS? Have to
// create one. Naturally, ensure we clean it up when done.
// create one. Naturally, ensure we clean it up when done.
NamedTempDir
tempdir
;
NamedTempDir
tempdir
;
PythonProcessLauncher
py
(
"
get
cwd
()
"
,
PythonProcessLauncher
py
(
get
_test_name
(),
"from __future__ import with_statement
\n
"
"from __future__ import with_statement
\n
"
"import os, sys
\n
"
"import os, sys
\n
"
"with open(sys.argv[1], 'w') as f:
\n
"
"with open(sys.argv[1], 'w') as f:
\n
"
...
@@ -634,7 +634,7 @@ namespace tut
...
@@ -634,7 +634,7 @@ namespace tut
void
object
::
test
<
3
>
()
void
object
::
test
<
3
>
()
{
{
set_test_name
(
"arguments"
);
set_test_name
(
"arguments"
);
PythonProcessLauncher
py
(
"args"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"from __future__ import with_statement
\n
"
"from __future__ import with_statement
\n
"
"import sys
\n
"
"import sys
\n
"
// note nonstandard output-file arg!
// note nonstandard output-file arg!
...
@@ -668,7 +668,7 @@ namespace tut
...
@@ -668,7 +668,7 @@ namespace tut
void
object
::
test
<
4
>
()
void
object
::
test
<
4
>
()
{
{
set_test_name
(
"exit(0)"
);
set_test_name
(
"exit(0)"
);
PythonProcessLauncher
py
(
"exit(0)"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"import sys
\n
"
"import sys
\n
"
"sys.exit(0)
\n
"
);
"sys.exit(0)
\n
"
);
py
.
run
();
py
.
run
();
...
@@ -680,7 +680,7 @@ namespace tut
...
@@ -680,7 +680,7 @@ namespace tut
void
object
::
test
<
5
>
()
void
object
::
test
<
5
>
()
{
{
set_test_name
(
"exit(2)"
);
set_test_name
(
"exit(2)"
);
PythonProcessLauncher
py
(
"exit(2)"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"import sys
\n
"
"import sys
\n
"
"sys.exit(2)
\n
"
);
"sys.exit(2)
\n
"
);
py
.
run
();
py
.
run
();
...
@@ -692,7 +692,7 @@ namespace tut
...
@@ -692,7 +692,7 @@ namespace tut
void
object
::
test
<
6
>
()
void
object
::
test
<
6
>
()
{
{
set_test_name
(
"syntax_error:"
);
set_test_name
(
"syntax_error:"
);
PythonProcessLauncher
py
(
"syntax_error:"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"syntax_error:
\n
"
);
"syntax_error:
\n
"
);
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
// inherit stdin
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
// inherit stdin
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
// inherit stdout
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
// inherit stdout
...
@@ -713,7 +713,7 @@ namespace tut
...
@@ -713,7 +713,7 @@ namespace tut
void
object
::
test
<
7
>
()
void
object
::
test
<
7
>
()
{
{
set_test_name
(
"explicit kill()"
);
set_test_name
(
"explicit kill()"
);
PythonProcessLauncher
py
(
"kill
()
"
,
PythonProcessLauncher
py
(
get_test_name
(),
"from __future__ import with_statement
\n
"
"from __future__ import with_statement
\n
"
"import sys, time
\n
"
"import sys, time
\n
"
"with open(sys.argv[1], 'w') as f:
\n
"
"with open(sys.argv[1], 'w') as f:
\n
"
...
@@ -750,7 +750,7 @@ namespace tut
...
@@ -750,7 +750,7 @@ namespace tut
// If kill() failed, the script would have woken up on its own and
// If kill() failed, the script would have woken up on its own and
// overwritten the file with 'bad'. But if kill() succeeded, it should
// overwritten the file with 'bad'. But if kill() succeeded, it should
// not have had that chance.
// not have had that chance.
ensure_equals
(
"kill()
script output"
,
readfile
(
out
.
getName
()),
"ok"
);
ensure_equals
(
get_test_name
()
+
"
script output"
,
readfile
(
out
.
getName
()),
"ok"
);
}
}
template
<
>
template
<
>
template
<
>
template
<
>
...
@@ -760,7 +760,7 @@ namespace tut
...
@@ -760,7 +760,7 @@ namespace tut
NamedTempFile
out
(
"out"
,
"not started"
);
NamedTempFile
out
(
"out"
,
"not started"
);
LLProcess
::
handle
phandle
(
0
);
LLProcess
::
handle
phandle
(
0
);
{
{
PythonProcessLauncher
py
(
"kill
()
"
,
PythonProcessLauncher
py
(
get_test_name
(),
"from __future__ import with_statement
\n
"
"from __future__ import with_statement
\n
"
"import sys, time
\n
"
"import sys, time
\n
"
"with open(sys.argv[1], 'w') as f:
\n
"
"with open(sys.argv[1], 'w') as f:
\n
"
...
@@ -792,7 +792,7 @@ namespace tut
...
@@ -792,7 +792,7 @@ namespace tut
// If kill() failed, the script would have woken up on its own and
// If kill() failed, the script would have woken up on its own and
// overwritten the file with 'bad'. But if kill() succeeded, it should
// overwritten the file with 'bad'. But if kill() succeeded, it should
// not have had that chance.
// not have had that chance.
ensure_equals
(
"kill()
script output"
,
readfile
(
out
.
getName
()),
"ok"
);
ensure_equals
(
get_test_name
()
+
"
script output"
,
readfile
(
out
.
getName
()),
"ok"
);
}
}
template
<
>
template
<
>
template
<
>
template
<
>
...
@@ -803,7 +803,7 @@ namespace tut
...
@@ -803,7 +803,7 @@ namespace tut
NamedTempFile
to
(
"to"
,
""
);
NamedTempFile
to
(
"to"
,
""
);
LLProcess
::
handle
phandle
(
0
);
LLProcess
::
handle
phandle
(
0
);
{
{
PythonProcessLauncher
py
(
"autokill"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"from __future__ import with_statement
\n
"
"from __future__ import with_statement
\n
"
"import sys, time
\n
"
"import sys, time
\n
"
"with open(sys.argv[1], 'w') as f:
\n
"
"with open(sys.argv[1], 'w') as f:
\n
"
...
@@ -852,7 +852,7 @@ namespace tut
...
@@ -852,7 +852,7 @@ namespace tut
waitfor
(
phandle
,
"autokill script"
);
waitfor
(
phandle
,
"autokill script"
);
// If the LLProcess destructor implicitly called kill(), the
// If the LLProcess destructor implicitly called kill(), the
// script could not have written 'ack' as we expect.
// script could not have written 'ack' as we expect.
ensure_equals
(
"autokill
script output"
,
readfile
(
from
.
getName
()),
"ack"
);
ensure_equals
(
get_test_name
()
+
"
script output"
,
readfile
(
from
.
getName
()),
"ack"
);
}
}
template
<
>
template
<
>
template
<
>
template
<
>
...
@@ -860,7 +860,7 @@ namespace tut
...
@@ -860,7 +860,7 @@ namespace tut
{
{
set_test_name
(
"'bogus' test"
);
set_test_name
(
"'bogus' test"
);
TestRecorder
recorder
;
TestRecorder
recorder
;
PythonProcessLauncher
py
(
"'bogus' test"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"print 'Hello world'
\n
"
);
"print 'Hello world'
\n
"
);
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"bogus"
));
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"bogus"
));
py
.
mPy
=
LLProcess
::
create
(
py
.
mParams
);
py
.
mPy
=
LLProcess
::
create
(
py
.
mParams
);
...
@@ -876,7 +876,7 @@ namespace tut
...
@@ -876,7 +876,7 @@ namespace tut
set_test_name
(
"'file' test"
);
set_test_name
(
"'file' test"
);
// Replace this test with one or more real 'file' tests when we
// Replace this test with one or more real 'file' tests when we
// implement 'file' support
// implement 'file' support
PythonProcessLauncher
py
(
"'file' test"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"print 'Hello world'
\n
"
);
"print 'Hello world'
\n
"
);
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"file"
));
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"file"
));
...
@@ -891,7 +891,7 @@ namespace tut
...
@@ -891,7 +891,7 @@ namespace tut
// Replace this test with one or more real 'tpipe' tests when we
// Replace this test with one or more real 'tpipe' tests when we
// implement 'tpipe' support
// implement 'tpipe' support
TestRecorder
recorder
;
TestRecorder
recorder
;
PythonProcessLauncher
py
(
"'tpipe' test"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"print 'Hello world'
\n
"
);
"print 'Hello world'
\n
"
);
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"tpipe"
));
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"tpipe"
));
...
@@ -909,7 +909,7 @@ namespace tut
...
@@ -909,7 +909,7 @@ namespace tut
// Replace this test with one or more real 'npipe' tests when we
// Replace this test with one or more real 'npipe' tests when we
// implement 'npipe' support
// implement 'npipe' support
TestRecorder
recorder
;
TestRecorder
recorder
;
PythonProcessLauncher
py
(
"'npipe' test"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"print 'Hello world'
\n
"
);
"print 'Hello world'
\n
"
);
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
...
@@ -926,7 +926,7 @@ namespace tut
...
@@ -926,7 +926,7 @@ namespace tut
{
{
set_test_name
(
"internal pipe name warning"
);
set_test_name
(
"internal pipe name warning"
);
TestRecorder
recorder
;
TestRecorder
recorder
;
PythonProcessLauncher
py
(
"pipe warning"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"import sys
\n
"
"import sys
\n
"
"sys.exit(7)
\n
"
);
"sys.exit(7)
\n
"
);
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"pipe"
,
"somename"
));
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"pipe"
,
"somename"
));
...
@@ -990,7 +990,7 @@ namespace tut
...
@@ -990,7 +990,7 @@ namespace tut
void
object
::
test
<
15
>
()
void
object
::
test
<
15
>
()
{
{
set_test_name
(
"get*Pipe() validation"
);
set_test_name
(
"get*Pipe() validation"
);
PythonProcessLauncher
py
(
"just stderr"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"print 'this output is expected'
\n
"
);
"print 'this output is expected'
\n
"
);
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"pipe"
));
// pipe for stdin
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
(
"pipe"
));
// pipe for stdin
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
// inherit stdout
py
.
mParams
.
files
.
add
(
LLProcess
::
FileParam
());
// inherit stdout
...
@@ -1010,7 +1010,7 @@ namespace tut
...
@@ -1010,7 +1010,7 @@ namespace tut
void
object
::
test
<
16
>
()
void
object
::
test
<
16
>
()
{
{
set_test_name
(
"talk to stdin/stdout"
);
set_test_name
(
"talk to stdin/stdout"
);
PythonProcessLauncher
py
(
"stdin/stdout"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"import sys, time
\n
"
"import sys, time
\n
"
"print 'ok'
\n
"
"print 'ok'
\n
"
"sys.stdout.flush()
\n
"
"sys.stdout.flush()
\n
"
...
@@ -1071,7 +1071,7 @@ namespace tut
...
@@ -1071,7 +1071,7 @@ namespace tut
void
object
::
test
<
17
>
()
void
object
::
test
<
17
>
()
{
{
set_test_name
(
"listen for ReadPipe events"
);
set_test_name
(
"listen for ReadPipe events"
);
PythonProcessLauncher
py
(
"ReadPipe listener"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"import sys
\n
"
"import sys
\n
"
"sys.stdout.write('abc')
\n
"
"sys.stdout.write('abc')
\n
"
"sys.stdout.flush()
\n
"
"sys.stdout.flush()
\n
"
...
@@ -1131,7 +1131,7 @@ namespace tut
...
@@ -1131,7 +1131,7 @@ namespace tut
void
object
::
test
<
18
>
()
void
object
::
test
<
18
>
()
{
{
set_test_name
(
"setLimit()"
);
set_test_name
(
"setLimit()"
);
PythonProcessLauncher
py
(
"setLimit
()
"
,
PythonProcessLauncher
py
(
get_test_name
(),
"import sys
\n
"
"import sys
\n
"
"sys.stdout.write(sys.argv[1])
\n
"
);
"sys.stdout.write(sys.argv[1])
\n
"
);
std
::
string
abc
(
"abcdefghijklmnopqrstuvwxyz"
);
std
::
string
abc
(
"abcdefghijklmnopqrstuvwxyz"
);
...
@@ -1160,7 +1160,7 @@ namespace tut
...
@@ -1160,7 +1160,7 @@ namespace tut
void
object
::
test
<
19
>
()
void
object
::
test
<
19
>
()
{
{
set_test_name
(
"peek() ReadPipe data"
);
set_test_name
(
"peek() ReadPipe data"
);
PythonProcessLauncher
py
(
"peek() ReadPipe"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"import sys
\n
"
"import sys
\n
"
"sys.stdout.write(sys.argv[1])
\n
"
);
"sys.stdout.write(sys.argv[1])
\n
"
);
std
::
string
abc
(
"abcdefghijklmnopqrstuvwxyz"
);
std
::
string
abc
(
"abcdefghijklmnopqrstuvwxyz"
);
...
@@ -1213,7 +1213,7 @@ namespace tut
...
@@ -1213,7 +1213,7 @@ namespace tut
void
object
::
test
<
20
>
()
void
object
::
test
<
20
>
()
{
{
set_test_name
(
"good postend"
);
set_test_name
(
"good postend"
);
PythonProcessLauncher
py
(
"postend"
,
PythonProcessLauncher
py
(
get_test_name
()
,
"import sys
\n
"
"import sys
\n
"
"sys.exit(35)
\n
"
);
"sys.exit(35)
\n
"
);
std
::
string
pumpname
(
"postend"
);
std
::
string
pumpname
(
"postend"
);
...
@@ -1247,7 +1247,7 @@ namespace tut
...
@@ -1247,7 +1247,7 @@ namespace tut
std
::
string
pumpname
(
"postend"
);
std
::
string
pumpname
(
"postend"
);
EventListener
listener
(
LLEventPumps
::
instance
().
obtain
(
pumpname
));
EventListener
listener
(
LLEventPumps
::
instance
().
obtain
(
pumpname
));
LLProcess
::
Params
params
;
LLProcess
::
Params
params
;
params
.
desc
=
"bad postend"
;
params
.
desc
=
get_test_name
()
;
params
.
postend
=
pumpname
;
params
.
postend
=
pumpname
;
LLProcessPtr
child
=
LLProcess
::
create
(
params
);
LLProcessPtr
child
=
LLProcess
::
create
(
params
);
ensure
(
"shouldn't have launched"
,
!
child
);
ensure
(
"shouldn't have launched"
,
!
child
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment