- struct thread_options o;
- struct thread_options_pack top1, top2;
-
- memset(&top1, 0, sizeof(top1));
- memset(&top2, 0, sizeof(top2));
-
- convert_thread_options_to_net(&top1, __o);
- memset(&o, 0, sizeof(o));
- convert_thread_options_to_cpu(&o, &top1);
- convert_thread_options_to_net(&top2, &o);
-
- free_thread_options_to_cpu(&o);
-
- return memcmp(&top1, &top2, sizeof(top1));
+ struct thread_options o1 = *__o, o2;
+ struct thread_options_pack *top1, *top2;
+ size_t top_sz;
+ int ret;
+
+ o1.verify_pattern_bytes = 61;
+ o1.verify_pattern = malloc(o1.verify_pattern_bytes);
+ memset(o1.verify_pattern, 'V', o1.verify_pattern_bytes);
+ o1.buffer_pattern_bytes = 15;
+ o1.buffer_pattern = malloc(o1.buffer_pattern_bytes);
+ memset(o1.buffer_pattern, 'B', o1.buffer_pattern_bytes);
+
+ top_sz = thread_options_pack_size(&o1);
+ top1 = calloc(1, top_sz);
+ top2 = calloc(1, top_sz);
+
+ convert_thread_options_to_net(top1, &o1);
+ memset(&o2, 0, sizeof(o2));
+ ret = convert_thread_options_to_cpu(&o2, top1, top_sz);
+ if (ret)
+ goto out;
+
+ convert_thread_options_to_net(top2, &o2);
+ ret = memcmp(top1, top2, top_sz);
+
+out:
+ free_thread_options_to_cpu(&o2);
+ free(top2);
+ free(top1);
+ free(o1.buffer_pattern);
+ free(o1.verify_pattern);
+ return ret;