aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2013-06-29 06:39:02 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2013-06-29 06:39:02 (GMT)
commitf464f24eb3a5872404f60356009f466d5f79f2b1 (patch)
tree285557bd93d1f1825f21ced9766e1bcfeb2f90fc /src/tests
parent2efd4b823082efb45cb351c7185d510ccb1dd32a (diff)
downloadfluxbox-f464f24eb3a5872404f60356009f466d5f79f2b1.zip
fluxbox-f464f24eb3a5872404f60356009f466d5f79f2b1.tar.bz2
fix detection of $HOME folder
usually $HOME is set when fluxbox runs. in some rare scenarios (eg., fuzzying binaries to detect bugs) one could launch fluxbox by using 'env -i' and thus eliminating $HOME from the environment. to prevent crashes fluxbox uses now 'getpwuid()' when $HOME is not set to detect the home folder.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/StringUtiltest.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/tests/StringUtiltest.cc b/src/tests/StringUtiltest.cc
index e5e8419..a821184 100644
--- a/src/tests/StringUtiltest.cc
+++ b/src/tests/StringUtiltest.cc
@@ -46,11 +46,16 @@ void testStringtok() {
46void testExpandFilename() { 46void testExpandFilename() {
47 string filename(StringUtil::expandFilename("~/filename/~filename2/file3~/file4")); 47 string filename(StringUtil::expandFilename("~/filename/~filename2/file3~/file4"));
48 cerr<<"test "; 48 cerr<<"test ";
49 string test = string(getenv("HOME"))+"/filename/~filename2/file3~/file4"; 49 const char* home = getenv("HOME");
50 if (test == filename) 50 if (home) {
51 cerr<<"ok."; 51 string test = string(home)+"/filename/~filename2/file3~/file4";
52 else 52 if (test == filename)
53 cerr<<"faild"; 53 cerr<<"ok.";
54 else
55 cerr<<"failed";
56 } else {
57 cerr << "failed, can't get $HOME.";
58 }
54 cerr<<endl; 59 cerr<<endl;
55} 60}
56 61