protobuf/ruby/tests/stress.rb
Joshua Haberman c649397029
Set execute bit on files if and only if they begin with (#!). (#7347)
* Set execute bit on files if and only if they begin with (#!).

Git only tracks the 'x' (executable) bit on each file. Prior to this
CL, our files were a random mix of executable and non-executable.
This change imposes some order by making files executable if and only
if they have shebang (#!) lines at the beginning.

We don't have any executable binaries checked into the repo, so
we shouldn't need to worry about that case.

* Added fix_permissions.sh script to set +x iff a file begins with (#!).
2020-04-01 15:28:25 -07:00

39 lines
907 B
Ruby
Executable File

#!/usr/bin/ruby
require 'google/protobuf'
require 'test/unit'
module StressTest
pool = Google::Protobuf::DescriptorPool.new
pool.build do
add_message "TestMessage" do
optional :a, :int32, 1
repeated :b, :message, 2, "M"
end
add_message "M" do
optional :foo, :string, 1
end
end
TestMessage = pool.lookup("TestMessage").msgclass
M = pool.lookup("M").msgclass
class StressTest < Test::Unit::TestCase
def get_msg
TestMessage.new(:a => 1000,
:b => [M.new(:foo => "hello"),
M.new(:foo => "world")])
end
def test_stress
m = get_msg
data = TestMessage.encode(m)
100_000.times do
mnew = TestMessage.decode(data)
mnew = mnew.dup
assert_equal mnew.inspect, m.inspect
assert TestMessage.encode(mnew) == data
end
end
end
end