def assert_message_is_correct(message, command): a = BashShellApp('a', 'a', command=command) b = FileDROP('b', 'b') a.addOutput(b) with DROPWaiterCtx(self, b, 100): a.async_execute() self.assertEqual(six.b(message), droputils.allDropContents(b))
def assert_message_is_correct(message, command): a = BashShellApp("a", "a", command=command) b = FileDROP("b", "b") a.addOutput(b) with DROPWaiterCtx(self, b, 100): a.async_execute() self.assertEqual(message.encode("utf8"), droputils.allDropContents(b))
def assert_envvar_is_there(varname, value): command = "echo -n $%s > %%o0" % (varname) a = BashShellApp(app_uid, app_uid, dlg_session=session, command=command) b = FileDROP('b', 'b') a.addOutput(b) with DROPWaiterCtx(self, b, 100): a.async_execute() self.assertEqual(six.b(value), droputils.allDropContents(b))
def test_echo(self): a = FileDROP('a', 'a') b = BashShellApp('b', 'b', command='cp %i0 %o0') c = FileDROP('c', 'c') b.addInput(a) b.addOutput(c) # Random data so we always check different contents data = os.urandom(10) with DROPWaiterCtx(self, c, 100): a.write(data) a.setCompleted() self.assertEqual(data, droputils.allDropContents(c)) # We own the file, not root uid = os.getuid() self.assertEqual(uid, os.stat(c.path).st_uid)
def test_reproducibility(self): from dlg.common.reproducibility.constants import ReproducibilityFlags from dlg.drop import NullDROP a = BashShellApp('a', 'a', command="echo 'Hello world'") a.reproducibility_level = ReproducibilityFlags.RERUN a.setCompleted() b = NullDROP('b', 'b') b.reproducibility_level = ReproducibilityFlags.RERUN b.setCompleted() self.assertEqual(a.merkleroot, b.merkleroot) a.reproducibility_level = ReproducibilityFlags.REPEAT self.assertEqual(a.merkleroot, b.merkleroot) a.reproducibility_level = ReproducibilityFlags.RECOMPUTE self.assertNotEqual(a.merkleroot, b.merkleroot) self.assertEqual(a.generate_merkle_data(), {'command': "echo 'Hello world'"}) a.reproducibility_level = ReproducibilityFlags.REPRODUCE self.assertNotEqual(a.merkleroot, b.merkleroot) self.assertEqual(a.generate_merkle_data(), {}) a.reproducibility_level = ReproducibilityFlags.REPLICATE_SCI self.assertEqual(a.merkleroot, b.merkleroot) self.assertEqual(a.generate_merkle_data(), a.generate_rerun_data()) a.reproducibility_level = ReproducibilityFlags.REPLICATE_COMP self.assertNotEqual(a.merkleroot, b.merkleroot) self.assertEqual(a.generate_merkle_data(), a.generate_recompute_data()) a.reproducibility_level = ReproducibilityFlags.REPLICATE_TOTAL self.assertEqual(a.merkleroot, b.merkleroot) self.assertEqual(a.generate_merkle_data(), a.generate_repeat_data())