origen_sim 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b31bfc2f252031780f05373507dbbb75db36300
4
- data.tar.gz: fb37cfeb67cde82e1f829630b36ea6752e581189
3
+ metadata.gz: d7effe33984317ccde4bbf6f5d09f584b07a3b10
4
+ data.tar.gz: b31096962de3a27c1768bf461bdb84221fad70cd
5
5
  SHA512:
6
- metadata.gz: f86cbee77db2cd17707e7c68aa96a70a18922772207e302b7abf6c416d9e28a2a0c2035339d28f3fde56214a6331a6e657a0be3b1b3945dfc5b1566d673d1e91
7
- data.tar.gz: 865533e70e134f220837accecdbefa616f1df14f8cf185bc3584a923e3c5af4afe2d5a3b7662221de125b0b45c5eb975569bfe51da679dc442d10e4c5f38e0df
6
+ metadata.gz: 0aaa884d3836bb39262e3116e3cfe5125c6c32447b7b4ab30613aad0c90948eb205e559f544615cebde8c0768fe148fad0180f115a0aa56a2fc57dc799007b40
7
+ data.tar.gz: a795ad25a6ea90ad158f27861730f9a5e365f7b022ac92edf87242fc1113e57fe1b992f19c1475c8cc189c35bf52c1976c96b4fccd74f0f20cdd9d336ba42905
@@ -1,6 +1,6 @@
1
1
  module OrigenSim
2
2
  MAJOR = 0
3
- MINOR = 10
3
+ MINOR = 11
4
4
  BUGFIX = 0
5
5
  DEV = nil
6
6
 
@@ -1,6 +1,8 @@
1
1
  require 'socket'
2
2
  require 'io/wait'
3
3
  require 'origen_sim/heartbeat'
4
+ require 'origen_sim/stdout_reader'
5
+ require 'origen_sim/stderr_reader'
4
6
  module OrigenSim
5
7
  # Responsible for managing each individual simulation that is run in an
6
8
  # Origen thread e.g. If multiple patterns are run in separate simulations, then one
@@ -12,7 +14,7 @@ module OrigenSim
12
14
  attr_reader :view_wave_command, :id
13
15
 
14
16
  attr_accessor :logged_errors, :error_count, :failed_to_start, :completed_cleanly
15
- attr_accessor :pid, :stderr_logged_errors
17
+ attr_accessor :pid
16
18
  # Returns the communication socket used for sending commands to the Origen VPI running
17
19
  # in the simulation process
18
20
  attr_reader :socket
@@ -23,7 +25,6 @@ module OrigenSim
23
25
  @completed_cleanly = false
24
26
  @failed_to_start = false
25
27
  @logged_errors = false
26
- @stderr_logged_errors = false
27
28
  @error_count = 0
28
29
  @socket_ids = {}
29
30
 
@@ -42,6 +43,14 @@ module OrigenSim
42
43
  end
43
44
  end
44
45
 
46
+ def logged_errors
47
+ @logged_errors || @stdout_reader.logged_errors
48
+ end
49
+
50
+ def stderr_logged_errors
51
+ @stderr_reader.logged_errors
52
+ end
53
+
45
54
  def log_results(in_progress = false)
46
55
  if failed?(in_progress)
47
56
  if failed_to_start
@@ -85,6 +94,8 @@ module OrigenSim
85
94
  @stdout = @server_stdout.accept
86
95
  @stderr = @server_stderr.accept
87
96
  @socket = @server.accept
97
+ @stdout_reader = StdoutReader.new(@stdout)
98
+ @stderr_reader = StderrReader.new(@stderr)
88
99
  @opened = true
89
100
  end
90
101
 
@@ -92,6 +103,8 @@ module OrigenSim
92
103
  def close
93
104
  return unless @opened
94
105
  stop_heartbeat
106
+ @stdout_reader.stop
107
+ @stderr_reader.stop
95
108
  @heartbeat.close
96
109
  @socket.close
97
110
  @stderr.close
@@ -102,37 +115,6 @@ module OrigenSim
102
115
  File.unlink(socket_id(:stdout)) if File.exist?(socket_id(:stdout))
103
116
  end
104
117
 
105
- def read_sim_output
106
- while @stdout.ready?
107
- line = @stdout.gets.chomp
108
- if OrigenSim.error_strings.any? { |s| line =~ /#{s}/ } &&
109
- !OrigenSim.error_string_exceptions.any? { |s| line =~ /#{s}/ }
110
- @logged_errors = true
111
- Origen.log.error "(STDOUT): #{line}"
112
- else
113
- if OrigenSim.verbose? ||
114
- OrigenSim.log_strings.any? { |s| line =~ /#{s}/ }
115
- Origen.log.info line
116
- else
117
- Origen.log.debug line
118
- end
119
- end
120
- end
121
- while @stderr.ready?
122
- line = @stderr.gets.chomp
123
- if OrigenSim.fail_on_stderr && !line.empty? &&
124
- !OrigenSim.stderr_string_exceptions.any? { |s| line =~ /#{s}/ }
125
- # We're failing on stderr, so print its results and log as errors if its not an exception.
126
- @stderr_logged_errors = true
127
- Origen.log.error "(STDERR): #{line}"
128
- elsif OrigenSim.verbose?
129
- # We're not failing on stderr, or the string in stderr is an exception.
130
- # Print the string as regular output if verbose is set, otherwise just ignore.
131
- Origen.log.info line
132
- end
133
- end
134
- end
135
-
136
118
  # Returns true if the simulation is running
137
119
  def running?
138
120
  return false unless pid
@@ -599,7 +599,6 @@ module OrigenSim
599
599
 
600
600
  def cycle(number_of_cycles)
601
601
  put("3^#{number_of_cycles}")
602
- simulation.read_sim_output
603
602
  end
604
603
 
605
604
  # Blocks the Origen process until the simulator indicates that it has
@@ -610,7 +609,6 @@ module OrigenSim
610
609
  unless data.strip == 'OK!'
611
610
  fail 'Origen and the simulator are out of sync!'
612
611
  end
613
- simulation.read_sim_output
614
612
  end
615
613
 
616
614
  def error(message)
@@ -717,7 +715,6 @@ module OrigenSim
717
715
  # Stop the simulator
718
716
  def stop
719
717
  @simulation_open = false
720
- simulation.read_sim_output
721
718
  simulation.error_count = error_count
722
719
  Origen.listeners_for(:simulation_shutdown).each(&:simulation_shutdown)
723
720
  ended = Time.now
@@ -0,0 +1,34 @@
1
+ require 'thread'
2
+ require 'io/wait'
3
+ module OrigenSim
4
+ class StderrReader < Thread
5
+ attr_reader :socket, :logged_errors
6
+
7
+ def initialize(socket)
8
+ @socket = socket
9
+ @continue = true
10
+ @logged_errors = false
11
+ super do
12
+ while @continue
13
+ while @socket.ready?
14
+ line = @socket.gets.chomp
15
+ if OrigenSim.fail_on_stderr && !line.empty? &&
16
+ !OrigenSim.stderr_string_exceptions.any? { |s| line =~ /#{s}/ }
17
+ # We're failing on stderr, so print its results and log as errors if its not an exception.
18
+ @logged_errors = true
19
+ Origen.log.error "(STDERR): #{line}"
20
+ elsif OrigenSim.verbose?
21
+ Origen.log.info line
22
+ else
23
+ Origen.log.debug line
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ def stop
31
+ @continue = false
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ require 'thread'
2
+ require 'io/wait'
3
+ module OrigenSim
4
+ class StdoutReader < Thread
5
+ attr_reader :socket, :logged_errors
6
+
7
+ def initialize(socket)
8
+ @socket = socket
9
+ @continue = true
10
+ @logged_errors = false
11
+ super do
12
+ while @continue
13
+ while @socket.ready?
14
+ line = @socket.gets.chomp
15
+ if OrigenSim.error_strings.any? { |s| line =~ /#{s}/ } &&
16
+ !OrigenSim.error_string_exceptions.any? { |s| line =~ /#{s}/ }
17
+ @logged_errors = true
18
+ Origen.log.error "(STDOUT): #{line}"
19
+ else
20
+ if OrigenSim.verbose? ||
21
+ OrigenSim.log_strings.any? { |s| line =~ /#{s}/ }
22
+ Origen.log.info line
23
+ else
24
+ Origen.log.debug line
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ def stop
33
+ @continue = false
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen_sim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-18 00:00:00.000000000 Z
11
+ date: 2018-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: origen
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.33.1
19
+ version: 0.33.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.33.1
26
+ version: 0.33.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: origen_testers
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +88,8 @@ files:
88
88
  - lib/origen_sim/origen_testers/api.rb
89
89
  - lib/origen_sim/simulation.rb
90
90
  - lib/origen_sim/simulator.rb
91
+ - lib/origen_sim/stderr_reader.rb
92
+ - lib/origen_sim/stdout_reader.rb
91
93
  - lib/origen_sim/tester.rb
92
94
  - lib/origen_sim_dev/dut.rb
93
95
  - lib/tasks/origen_sim.rake