1 // This file is automatically generated from 2 // frameworks/rs/tests/java_api/RSUnitTests/RSUnitTests.py 3 /* 4 * Copyright (C) 2017 The Android Open Source Project 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package com.android.rs.unittest; 20 21 import android.content.Context; 22 import android.support.v8.renderscript.RenderScript; 23 24 public class UT_struct_field_simple extends UnitTest { 25 26 public UT_struct_field_simple(Context ctx) { 27 super("Structure Fields", ctx); 28 } 29 30 public void run() { 31 RenderScript pRS = createRenderScript(true); 32 ScriptC_struct_field_simple s = new ScriptC_struct_field_simple(pRS); 33 34 ScriptField_Simple.Item simple = new ScriptField_Simple.Item(); 35 final int I = 0x12345678; 36 final long L = 0x76543210fedcba98L; 37 simple.I = I; 38 simple.L = L; 39 s.set_simple(simple); 40 41 s.invoke_checkSimple(I, L); 42 43 pRS.finish(); 44 pRS.destroy(); 45 } 46 } 47 48 // struct Simple { 49 // int I; 50 // long L; 51 // }; 52 // 53 // Consistently padded, we expect: 54 // I = 0x12345678 55 // L.lo = 0xfedcba98 56 // L.hi = 0x76543210 57 // 58 // And indeed on N9 --abi armeabi-v7a (i.e., ARM-32) we see: 59 // 60 // 09-23 21:55:51.026 5990 6005 D RenderScript: argI 305419896 0x12345678 61 // 09-23 21:55:51.026 5990 6005 D RenderScript: simple.I 305419896 0x12345678 62 // 09-23 21:55:51.026 5990 6005 D RenderScript: argL.lo 4275878552 0xfedcba98 63 // 09-23 21:55:51.026 5990 6005 D RenderScript: simple.L.lo 4275878552 0xfedcba98 64 // 09-23 21:55:51.026 5990 6005 D RenderScript: argL.hi 1985229328 0x76543210 65 // 09-23 21:55:51.026 5990 6005 D RenderScript: simple.L.hi 1985229328 0x76543210 66 // 09-23 21:55:51.026 5990 6005 D RenderScript: struct_field_simple PASSED 0 0x0 67 // 68 // Inconsistently padded (Java pads, x86-32 script does not), we expect: 69 // I = 0x12345678 // fine 70 // L.lo = 0 // oops, script read the padding 71 // L.hi = 0xfedcba98 // oops, script read L.lo 72 // 73 // And indeed on fugu (i.e., x86-32) before the fix for http://b/29154200 and http://b/28070272 74 // we see: 75 // 76 // 09-23 21:39:19.775 4090 4107 D RenderScript: argI 305419896 0x12345678 77 // 09-23 21:39:19.775 4090 4107 D RenderScript: simple.I 305419896 0x12345678 78 // 09-23 21:39:19.775 4090 4107 D RenderScript: argL.lo 4275878552 0xfedcba98 79 // 09-23 21:39:19.775 4090 4107 D RenderScript: simple.L.lo 0 0x0 80 // 09-23 21:39:19.775 4090 4107 D RenderScript: argL.hi 1985229328 0x76543210 81 // 09-23 21:39:19.775 4090 4107 D RenderScript: simple.L.hi 4275878552 0xfedcba98 82 // 09-23 21:39:19.775 4090 4107 D RenderScript: simple.L == argL FAILED 0 0x0 83 // 09-23 21:39:19.775 4090 4107 D RenderScript: struct_field_simple FAILED 0 0x0 84