BOOST_AUTO_TEST_CASE(FreeDiskSpace1)
{
- string dfstr=capture_exec("df -B 1 --output=avail /tmp | tail -n 1");
+ long long dfout;
+ long long get_free_diskspace_tmp;
- long long dfout=-1;
- string_to<long long>(dfstr,dfout);
+ // we need a partition to do this test. we can't create our own because that would require root
+ // so we use /tmp and retry it a few times in case of an error
+ int retries = 5;
+ while (retries > 0)
+ {
+ string dfstr=capture_exec("df -B 1 --output=avail /tmp | tail -n 1");
+
+ dfout=-1;
+ string_to<long long>(dfstr,dfout);
+
+ get_free_diskspace_tmp=get_free_diskspace("/tmp");
+
+ if ( dfout == get_free_diskspace_tmp )
+ break;
+
+ retries--;
+ }
- BOOST_CHECK_EQUAL( dfout, get_free_diskspace("/tmp") );
+ // do the check again with BOOST_CHECK_EQUAL to show it in the unit test output
+ BOOST_CHECK_EQUAL( dfout, get_free_diskspace_tmp );
}
BOOST_AUTO_TEST_CASE(FreeDiskSpace2)