From 0208f3bfd132d58c31d5db06db6378277fa71c7b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Sep 2013 02:06:51 +0000 Subject: player: add "state dump" command to serialize state This helps in case dtas-player is hit with SIGKILL or the system crashes. This does not fsync(2) as that could introduce delays on slow filesystems. Users should open the file manually and fsync themselves if they need to. --- test/test_player_integration.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/test_player_integration.rb') diff --git a/test/test_player_integration.rb b/test/test_player_integration.rb index b60ed36..e7f7306 100644 --- a/test/test_player_integration.rb +++ b/test/test_player_integration.rb @@ -188,6 +188,24 @@ class TestPlayerIntegration < Minitest::Unit::TestCase assert_equal "/", s.req("pwd") end + def test_state_file + state = Tempfile.new(%w(state .yml)) + state_path = state.path + state.close! + s = client_socket + s.req_ok(%W(state dump #{state_path})) + hash = YAML.load(IO.binread(state_path)) + assert_equal @sock_path, hash["socket"] + assert_equal "default", hash["sinks"][0]["name"] + + assert_equal "", IO.binread(@state_tmp.path) + s.req_ok(%W(state dump)) + orig = YAML.load(IO.binread(@state_tmp.path)) + assert_equal orig, hash + ensure + File.unlink(state_path) + end + def test_source_ed s = client_socket assert_equal "sox av ff", s.req("source ls") -- cgit v1.2.3-24-ge0c7