chromium/mojo/public/tools/fuzzers/mojolpm_generator_templates/mojolpm_generator.proto.tmpl

syntax = "proto2";

package mojolpmgenerator.{{basename}};

{% for import in imports %}
import "{{import}}";
{% endfor %}

message RunThreadAction {
  required uint32 id = 1;
}

{% for new_message in new_messages %}
message {{new_message}} {
    required uint32 id = 1;
}
{% endfor %}

{% for actions in actions_list %}
message RemoteAction{{loop.index}} {
{% set new_actions = [] -%}
{% if ensure_remote %}
{% set oneof_actions = actions|rejectattr("is_new_action")|list -%}
{% else %}
{% set oneof_actions = actions -%}
{% endif %}
{% for action in new_actions %}
  required {{action['proto_type']}} {{action['proto_identifier']}} = {{loop.index}};
{% endfor %}
{% if oneof_actions|length > 0 %}
  oneof action {
{%    for action in oneof_actions %}
    {{action['proto_type']}} {{action['proto_identifier']}} = {{loop.index + 1}};
{%    endfor %}
  }
{% endif %}
}
{% endfor %}

{% for actions in actions_list %}
message Remote{{loop.index}} {
{% if ensure_remote %}
{% for action in actions|selectattr("is_new_action") %}
  required {{action['proto_type']}} {{action['proto_identifier']}} = {{loop.index}};
{% endfor %}
{% endif %}
  repeated RemoteAction{{loop.index}} remote_{{loop.index}} = {{loop.index + 1}};
}
{% endfor %}


message Action {
    oneof action {
        RunThreadAction run_thread_action = 1;
{% for action_set in actions_list %}
        Remote{{loop.index}} action_{{loop.index}} = {{loop.index + 1}};
{% endfor %}
    }
}

// Sequence provides a level of indirection which allows Testcase to compactly
// express repeated sequences of actions.
message Sequence {
  repeated uint32 action_indexes = 1 [packed = true];
}

// Testcase is the top-level message type interpreted by the fuzzer.
message Testcase {
  repeated Action actions = 1;
  repeated Sequence sequences = 2;
  repeated uint32 sequence_indexes = 3 [packed = true];
}