def test_local_output(self): set_local_input_output(True) # Set up the function msg = { "user": "******", "function": "py_func", "py_user": "******", "py_func": "echo", } json_msg = dumps(msg) set_emulator_message(json_msg) # Check output is initially empty self.assertIsNone(get_output()) # Set output and check output_a = b'12345' set_output(output_a) self.assertEqual(get_output(), output_a) # Set output again and check updated output_b = b'666777' set_output(output_b) self.assertEqual(get_output(), output_b)
def faasm_main(): i = get_input() print("Got input {}".format(i)) set_output(bytes(i)) return 0
def test_changing_function_clears_local_output(self): set_local_input_output(True) # Set output and check output_a = b'12345' set_output(output_a) self.assertEqual(get_output(), output_a) # Change function msg = { "user": "******", "function": "bar", } json_msg = dumps(msg) set_emulator_message(json_msg) # Check output is now empty self.assertIsNone(get_output())
def faasm_main(): path = get_input() if not path: print("Input must be a path") return 1 path = path.decode() print("Path = {}, cwd = {}".format(path, os.getcwd())) dirlist = os.listdir(path) dirlist.sort() dir_list_str = ",".join(dirlist) print(dir_list_str) set_output(bytes(dir_list_str, "utf-8")) return 0
def divide_and_conquer(): print("Kicking off divide and conquer") mat.divide_and_conquer() output = "Matrix multiplication finished" set_output(output.encode("utf-8"))
def faasm_main(): output = "Hello! Running Python version {}".format(sys.version) print(output) set_output(output.encode("utf-8"))