Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
eef4f79e
Kaydet (Commit)
eef4f79e
authored
Eki 09, 2014
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More specific
Change-Id: I7e6490c5b50a236a5f070e98d4501e7dd5a90307
üst
d3a04fde
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
50 deletions
+41
-50
osl_process.cxx
sal/qa/osl/process/osl_process.cxx
+41
-50
No files found.
sal/qa/osl/process/osl_process.cxx
Dosyayı görüntüle @
eef4f79e
...
...
@@ -38,7 +38,9 @@
#include <sal/macros.h>
#if defined HAVE_VALGRIND_HEADERS
#include <valgrind/memcheck.h>
#include <valgrind/valgrind.h>
#else
#define RUNNING_ON_VALGRIND false
#endif
#if ( defined WNT ) // Windows
...
...
@@ -90,11 +92,11 @@ inline ::rtl::OUString getExecutablePath( void )
//rtl::OUString CWD = getExecutablePath();
typedef
std
::
vector
<
std
::
string
>
string_container_t
;
typedef
std
::
vector
<
OString
>
string_container_t
;
typedef
string_container_t
::
const_iterator
string_container_const_iter_t
;
typedef
string_container_t
::
iterator
string_container_iter_t
;
class
exclude
:
public
std
::
unary_function
<
std
::
s
tring
,
bool
>
class
exclude
:
public
std
::
unary_function
<
OS
tring
,
bool
>
{
public
:
...
...
@@ -106,7 +108,7 @@ public:
exclude_list_
.
push_back
(
env_var_name
(
*
iter
));
}
bool
operator
()
(
const
std
::
s
tring
&
env_var
)
const
bool
operator
()
(
const
OS
tring
&
env_var
)
const
{
return
(
exclude_list_
.
end
()
!=
std
::
find
(
...
...
@@ -119,15 +121,15 @@ private:
// extract the name from an environment variable
// that is given in the form "NAME=VALUE"
std
::
string
env_var_name
(
const
std
::
s
tring
&
env_var
)
const
OString
env_var_name
(
const
OS
tring
&
env_var
)
const
{
s
td
::
string
::
size_type
pos_equal_sign
=
env_var
.
find_first_of
(
"="
);
s
al_Int32
pos_equal_sign
=
env_var
.
indexOf
(
'='
);
if
(
std
::
string
::
npos
!=
pos_equal_sign
)
return
std
::
string
(
env_var
,
0
,
pos_equal_sign
);
if
(
-
1
!=
pos_equal_sign
)
return
env_var
.
copy
(
0
,
pos_equal_sign
);
return
std
::
s
tring
();
return
OS
tring
();
}
private
:
...
...
@@ -136,27 +138,20 @@ private:
namespace
{
class
starts_with
:
public
std
::
unary_function
<
const
std
::
string
&
,
bool
>
{
private
:
const
std
::
string
m_rString
;
public
:
starts_with
(
const
char
*
pString
)
:
m_rString
(
pString
)
{}
bool
operator
()(
const
std
::
string
&
rEntry
)
const
{
return
rEntry
.
find
(
m_rString
)
==
0
;
}
};
void
tidy_container
(
string_container_t
&
env_container
)
{
//sort them because there are no guarantees to ordering
std
::
sort
(
env_container
.
begin
(),
env_container
.
end
());
//remove LD_PRELOAD because valgrind injects that into the
//parent process
env_container
.
erase
(
std
::
remove_if
(
env_container
.
begin
(),
env_container
.
end
(),
starts_with
(
"LD_PRELOAD="
)),
env_container
.
end
());
if
(
RUNNING_ON_VALGRIND
)
{
env_container
.
erase
(
std
::
remove_if
(
env_container
.
begin
(),
env_container
.
end
(),
[](
OString
const
&
s
)
{
return
s
.
startsWith
(
"LD_PRELOAD="
)
||
s
.
startsWith
(
"VALGRIND_LIB="
);
}),
env_container
.
end
());
}
}
}
...
...
@@ -168,7 +163,7 @@ namespace
while
(
size_t
l
=
_tcslen
(
p
))
{
env_container
->
push_back
(
std
::
s
tring
(
p
));
env_container
->
push_back
(
OS
tring
(
p
));
p
+=
l
+
1
;
}
FreeEnvironmentStrings
(
env
);
...
...
@@ -178,7 +173,7 @@ namespace
void
read_parent_environment
(
string_container_t
*
env_container
)
{
for
(
int
i
=
0
;
NULL
!=
environ
[
i
];
i
++
)
env_container
->
push_back
(
std
::
s
tring
(
environ
[
i
]));
env_container
->
push_back
(
OS
tring
(
environ
[
i
]));
tidy_container
(
*
env_container
);
}
#endif
...
...
@@ -246,14 +241,14 @@ public:
std
::
string
line
;
line
.
reserve
(
1024
);
while
(
std
::
getline
(
file
,
line
,
'\0'
))
env_container
->
push_back
(
line
);
env_container
->
push_back
(
OString
(
line
.
c_str
())
);
tidy_container
(
*
env_container
);
}
// environment of the child process that was
// started. The child process writes his
// environment into a file
bool
compare_environments
()
void
compare_environments
()
{
string_container_t
parent_env
;
read_parent_environment
(
&
parent_env
);
...
...
@@ -261,8 +256,20 @@ public:
string_container_t
child_env
;
read_child_environment
(
&
child_env
);
return
((
parent_env
.
size
()
==
child_env
.
size
())
&&
(
std
::
equal
(
child_env
.
begin
(),
child_env
.
end
(),
parent_env
.
begin
())));
OString
msg
(
OString
::
number
(
parent_env
.
size
())
+
"/"
+
OString
::
number
(
child_env
.
size
()));
auto
min
=
std
::
min
(
parent_env
.
size
(),
child_env
.
size
());
for
(
decltype
(
min
)
i
=
0
;
i
!=
min
;
++
i
)
{
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
msg
.
getStr
(),
parent_env
[
i
],
child_env
[
i
]);
}
if
(
parent_env
.
size
()
!=
child_env
.
size
())
{
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
(
parent_env
.
size
()
>=
child_env
.
size
()
?
parent_env
.
back
()
:
child_env
.
back
()).
getStr
(),
parent_env
.
size
(),
child_env
.
size
());
}
}
// compare the equal environment parts and the
...
...
@@ -367,17 +374,7 @@ public:
osl_freeProcessHandle
(
process
);
#if defined HAVE_VALGRIND_HEADERS
//valgrind makes these not match
if
(
RUNNING_ON_VALGRIND
)
return
;
#endif
CPPUNIT_ASSERT_MESSAGE
(
"Parent and child environment not equal"
,
compare_environments
()
);
compare_environments
();
}
#define ENV1 "PAT=a:\\"
...
...
@@ -431,12 +428,6 @@ public:
different_child_env_vars
.
push_back
(
ENV2
);
different_child_env_vars
.
push_back
(
ENV4
);
#if defined HAVE_VALGRIND_HEADERS
//valgrind makes these not match
if
(
RUNNING_ON_VALGRIND
)
return
;
#endif
CPPUNIT_ASSERT_MESSAGE
(
"osl_execProc_merged_child_environment"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment